Esempio n. 1
0
        public void device_list_button_pressed_button_not_found()
        {
            const int    mode = 1;
            const string expectedDeviceName   = "not set";
            var          activationButtonList = new Dictionary <int, ModeActivationItem>
            {
                { 1, new ModeActivationItem()
                  {
                      ButtonId = 1, ButtonName = "test button", ProfileName = "select combat mode"
                  } }
            };

            var profileVm = new ModeProfileConfigWindowViewModel(Substitute.For <IEventAggregator>(), Substitute.For <IDispatcher>(), mode, activationButtonList);

            profileVm.DeviceName = expectedDeviceName;

            var device = new HOTASDevice();

            profileVm.DeviceList_ButtonPressed(new object(), new ButtonPressedEventArgs()
            {
                ButtonId = 1, Device = device
            });
            Assert.Equal(expectedDeviceName, profileVm.DeviceName);
        }
Esempio n. 2
0
        public void device_list_button_pressed_button_found()
        {
            const int mode = 1;
            var       activationButtonList = new Dictionary <int, ModeActivationItem>
            {
                { 1, new ModeActivationItem()
                  {
                      ButtonId = 1, ButtonName = "test button", ProfileName = "select combat mode"
                  } }
            };

            var profileVm = new ModeProfileConfigWindowViewModel(Substitute.For <IEventAggregator>(), new TestDispatcher(), mode, activationButtonList);

            profileVm.DeviceName = "not set";

            var device1 = new HOTASDevice(Substitute.For <IDirectInput>(), Guid.NewGuid(), Guid.NewGuid(), "test device 1", Substitute.For <IHOTASQueue>());

            device1.ButtonMap.Add(new HOTASButton()
            {
                MapId = 1
            });
            device1.ButtonMap.Add(new HOTASButton()
            {
                MapId = 2
            });

            profileVm.DeviceList_ButtonPressed(new object(), new ButtonPressedEventArgs()
            {
                ButtonId = 1, Device = device1
            });
            Assert.Equal("test device 1", profileVm.DeviceName);

            var device2 = new HOTASDevice(Substitute.For <IDirectInput>(), Guid.NewGuid(), Guid.NewGuid(), "test device 2", Substitute.For <IHOTASQueue>());

            device2.ButtonMap.Add(new HOTASButton()
            {
                MapId = 4, MapName = "test activation name"
            });
            device2.ButtonMap.Add(new HOTASButton()
            {
                MapId = 5
            });

            //button and device do not match up so devicename does not change
            profileVm.DeviceList_ButtonPressed(new object(), new ButtonPressedEventArgs()
            {
                ButtonId = 1, Device = device2
            });
            Assert.Equal("test device 1", profileVm.DeviceName);

            profileVm.PropertyChanged += ProfileVm_PropertyChanged_for_basic_constructor_no_valid_mode_test;
            property_chagned_for_basic_constructor_no_valid_mode_test = false;
            profileVm.DeviceList_ButtonPressed(new object(), new ButtonPressedEventArgs()
            {
                ButtonId = 4, Device = device2
            });
            Assert.Equal("test device 2", profileVm.DeviceName);
            Assert.Equal("test activation name", profileVm.ActivationButtonName);
            Assert.False(profileVm.IsActivationErrorVisible);
            Assert.True(property_chagned_for_basic_constructor_no_valid_mode_test);
        }