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 get_hotas_devices_no_scanned_devices() { var subDirectInputFactory = Substitute.For <DirectInputFactory>(); var subDirectInput = Substitute.For <IDirectInput>(); subDirectInputFactory.CreateDirectInput().Returns(subDirectInput); subDirectInput.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly).Returns(x => null); var subHotasDeviceFactory = Substitute.For <HOTASDeviceFactory>(); var subHotasQueueFactory = Substitute.For <HOTASQueueFactory>(Substitute.For <IKeyboard>()); var list = new HOTASCollection(subDirectInputFactory, Substitute.For <JoystickFactory>(), subHotasQueueFactory, subHotasDeviceFactory); var devices = list.RefreshMissingDevices(); Assert.NotNull(devices); Assert.Empty(devices); subHotasDeviceFactory.DidNotReceive().CreateHOTASDevice(Arg.Any <IDirectInput>(), Arg.Any <Guid>(), Arg.Any <Guid>(), Arg.Any <string>(), Arg.Any <IHOTASQueue>()); subHotasQueueFactory.DidNotReceive().CreateHOTASQueue(); }