public void get_hotas_devices_no_existing_device_capabilities_not_null() { var subDirectInputFactory = Substitute.For <DirectInputFactory>(); var subDirectInput = Substitute.For <IDirectInput>(); var deviceId = Guid.NewGuid(); var subDevice = Substitute.For <IHOTASDevice>(); subDevice.DeviceId.Returns(deviceId); subDevice.Capabilities.Returns(new Capabilities()); var subDeviceFactory = Substitute.For <HOTASDeviceFactory>(); subDeviceFactory.CreateHOTASDevice(Arg.Any <IDirectInput>(), Arg.Any <JoystickFactory>(), Arg.Any <Guid>(), Arg.Any <Guid>(), Arg.Any <string>(), Arg.Any <IHOTASQueue>()).Returns(subDevice); var deviceInstances = new List <DeviceInstance>(); var instance = new DeviceInstance { InstanceGuid = deviceId }; deviceInstances.Add(instance); subDirectInputFactory.CreateDirectInput().Returns(subDirectInput); subDirectInput.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly).Returns(deviceInstances); var list = new HOTASCollection(subDirectInputFactory, Substitute.For <JoystickFactory>(), Substitute.For <HOTASQueueFactory>(Substitute.For <IKeyboard>()), subDeviceFactory); list.Start(); var addedDevice = list.Devices[0]; var deviceList = list.RefreshMissingDevices(); Assert.Empty(deviceList); }
public void start() { var subDirectInputFactory = Substitute.For <DirectInputFactory>(); var subDirectInput = Substitute.For <IDirectInput>(); var deviceId = Guid.NewGuid(); var subDevice = Substitute.For <IHOTASDevice>(); subDevice.DeviceId.Returns(deviceId); var subDeviceFactory = Substitute.For <HOTASDeviceFactory>(); subDeviceFactory.CreateHOTASDevice(Arg.Any <IDirectInput>(), Arg.Any <JoystickFactory>(), Arg.Any <Guid>(), Arg.Any <Guid>(), Arg.Any <string>(), Arg.Any <IHOTASQueue>()).Returns(subDevice); var deviceInstances = new List <DeviceInstance>(); var subInstance = Substitute.For <DeviceInstance>(); deviceInstances.Add(subInstance); subDirectInputFactory.CreateDirectInput().Returns(subDirectInput); subDirectInput.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly).Returns(deviceInstances); var list = new HOTASCollection(subDirectInputFactory, Substitute.For <JoystickFactory>(), Substitute.For <HOTASQueueFactory>(Substitute.For <IKeyboard>()), subDeviceFactory); list.Start(); var addedDevice = list.Devices[0]; Assert.Equal(deviceId, addedDevice.DeviceId); addedDevice.Received(1).ListenAsync(); }