Ejemplo n.º 1
0
        public void auto_set_mode()
        {
            var subDevice = Substitute.For <IHOTASDevice>();
            var buttonMap = new ObservableCollection <IHotasBaseMap>();

            buttonMap.Add(new HOTASButton()
            {
                ShiftModePage = 43
            });
            subDevice.IsDeviceLoaded.Returns(true);
            subDevice.ButtonMap.Returns(buttonMap);
            subDevice.GetButtonState(Arg.Any <int>()).Returns(true);

            var subDeviceFactory = Substitute.For <HOTASDeviceFactory>();

            subDeviceFactory.CreateHOTASDevice(Arg.Any <IDirectInput>(), Arg.Any <Guid>(), Arg.Any <Guid>(), Arg.Any <string>(), Arg.Any <IHOTASQueue>()).Returns(subDevice);

            var list = new HOTASCollection(Substitute.For <DirectInputFactory>(), Substitute.For <JoystickFactory>(), Substitute.For <HOTASQueueFactory>(Substitute.For <IKeyboard>()), subDeviceFactory);

            list.Mode = 1;
            list.AddDevice(subDevice);
            list.ListenToAllDevices();

            list.AutoSetMode();
            Assert.Equal(43, list.Mode);
        }