Exemple #1
0
        public void CreateDeviceList()
        {
            var title        = "Test device";
            var providerName = "Test provider";
            var deviceList   = DeviceFactory.CreateDeviceList(title, providerName, 4);

            Assert.That(deviceList.Count, Is.EqualTo(4));
            Assert.That(deviceList[0].Title, Is.Not.EqualTo(deviceList[1].Title));
            Assert.That(deviceList[0].ProviderName, Is.EqualTo(deviceList[1].ProviderName));
            Assert.That(deviceList[0].DeviceHandle, Is.EqualTo(0.ToString()));
            Assert.That(deviceList[3].DeviceHandle, Is.EqualTo(3.ToString()));
        }
Exemple #2
0
        public void DeviceListContext()
        {
            var context      = new Context();
            var joystickGuid = context.DeviceGroupsManager.AddDeviceGroup("Joystick 1", DeviceIoType.Input);

            context.DeviceGroupsManager.AddDeviceGroup("Joystick 2", DeviceIoType.Input);
            context.DeviceGroupsManager.AddDeviceGroup("Joystick 3", DeviceIoType.Input);
            context.DeviceGroupsManager.AddDeviceGroup("Joystick 4", DeviceIoType.Input);
            var keyboardGuid = context.DeviceGroupsManager.AddDeviceGroup("Keyboard", DeviceIoType.Output);

            var joystickDeviceGroup = context.DeviceGroupsManager.GetDeviceGroup(DeviceIoType.Input, joystickGuid);

            joystickDeviceGroup.Devices = DeviceFactory.CreateDeviceList("Gamepad", "Gamepad provider", 4);
            var keyboardDeviceGroup = context.DeviceGroupsManager.GetDeviceGroup(DeviceIoType.Output, keyboardGuid);

            keyboardDeviceGroup.Devices = DeviceFactory.CreateDeviceList("Keyboard", "interception", 1);

            context.SaveContext();

            for (var i = 0; i < _saveReloadTimes; i++)
            {
                var newcontext = Context.Load();

                Assert.That(newcontext.InputGroups.Count, Is.EqualTo(context.InputGroups.Count));
                Assert.That(newcontext.OutputGroups.Count, Is.EqualTo(context.OutputGroups.Count));

                for (var j = 0; j < context.InputGroups.Count; j++)
                {
                    Assert.That(newcontext.InputGroups[j].Guid, Is.EqualTo(context.InputGroups[j].Guid));
                    Assert.That(newcontext.InputGroups[j].Title, Is.EqualTo(context.InputGroups[j].Title));

                    for (var k = 0; k < context.InputGroups[j].Devices.Count; k++)
                    {
                        Assert.That(newcontext.InputGroups[j].Devices[k].Title,
                                    Is.EqualTo(context.InputGroups[j].Devices[k].Title));
                        Assert.That(newcontext.InputGroups[j].Devices[k].DeviceHandle,
                                    Is.EqualTo(context.InputGroups[j].Devices[k].DeviceHandle));
                        Assert.That(newcontext.InputGroups[j].Devices[k].ProviderName,
                                    Is.EqualTo(context.InputGroups[j].Devices[k].ProviderName));
                    }
                }

                newcontext.SaveContext();
            }
        }
Exemple #3
0
        public void GetDevice()
        {
            var guid       = _context.DeviceGroupsManager.AddDeviceGroup("Test joysticks", DeviceIoType.Input);
            var deviceList = DeviceFactory.CreateDeviceList("Dummy", "Provider", 1);

            _context.DeviceGroupsManager.GetDeviceGroup(DeviceIoType.Input, guid).Devices = deviceList;
            var deviceBinding = new DeviceBinding(null, null, DeviceIoType.Input)
            {
                IsBound    = true,
                DeviceGuid = deviceList[0].Guid
            };

            Assert.That(_profile.GetDevice(deviceBinding), Is.Null);

            Assert.That(guid, Is.Not.EqualTo(Guid.Empty));
            _profile.SetDeviceGroup(deviceBinding.DeviceIoType, guid);
            Assert.That(_context.IsNotSaved, Is.True);
            Assert.That(_profile.GetDevice(deviceBinding), Is.Not.Null);
            Assert.That(_profile.GetDevice(deviceBinding).Guid, Is.EqualTo(_profile.GetDeviceList(deviceBinding)[0].Guid));
        }
Exemple #4
0
        public void GetDeviceList()
        {
            var deviceBinding = new DeviceBinding(null, null, DeviceIoType.Input)
            {
                IsBound = true
            };

            Assert.That(_profile.GetDeviceList(deviceBinding), Is.Empty);
            var guid = _context.DeviceGroupsManager.AddDeviceGroup("Test joysticks", DeviceIoType.Input);

            _profile.SetDeviceGroup(deviceBinding.DeviceIoType, guid);
            Assert.That(_profile.GetDeviceList(deviceBinding), Is.Not.Null.And.Empty);
            _context.DeviceGroupsManager.GetDeviceGroup(DeviceIoType.Input, guid).Devices = DeviceFactory.CreateDeviceList("Dummy", "Provider", 1);
            Assert.That(_profile.GetDeviceList(deviceBinding), Is.Not.Empty);
        }