public void properties_raise_property_changed() { 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>(), Substitute.For <IDispatcher>(), mode, activationButtonList); profileVm.ProfileName = string.Empty; profileVm.DeviceName = string.Empty; profileVm.ActivationButtonName = string.Empty; profileVm.IsActivationErrorVisible = false; profileVm.IsShift = false; Assert.PropertyChanged(profileVm, "ProfileName", () => profileVm.ProfileName = "changed'"); Assert.PropertyChanged(profileVm, "DeviceName", () => profileVm.DeviceName = "changed'"); Assert.PropertyChanged(profileVm, "ActivationButtonName", () => profileVm.ActivationButtonName = "changed'"); Assert.PropertyChanged(profileVm, "IsActivationErrorVisible", () => profileVm.IsActivationErrorVisible = true); Assert.PropertyChanged(profileVm, "IsShift", () => profileVm.IsShift = true); }
public void basic_constructor_template_not_visible_by_mode() { const int mode = 1; var profileVm = new ModeProfileConfigWindowViewModel(Substitute.For <IEventAggregator>(), Substitute.For <IDispatcher>(), mode, new Dictionary <int, ModeActivationItem>()); Assert.False(profileVm.IsTemplateModeVisible); }
public void is_shift_visible() { var mode = 0; var profileVm = new ModeProfileConfigWindowViewModel(Substitute.For <IEventAggregator>(), Substitute.For <IDispatcher>(), mode, new Dictionary <int, ModeActivationItem>()); Assert.True(profileVm.IsShiftVisible); mode = 1; profileVm = new ModeProfileConfigWindowViewModel(Substitute.For <IEventAggregator>(), Substitute.For <IDispatcher>(), mode, new Dictionary <int, ModeActivationItem>()); Assert.False(profileVm.IsShiftVisible); }
public ModeProfileConfigWindow(IEventAggregator eventAggregator, IDispatcher appDispatcher, int mode, Dictionary <int, ModeActivationItem> activationButtonList, Action <EventHandler <ButtonPressedEventArgs> > pressedHandler, Action <EventHandler <ButtonPressedEventArgs> > removePressedHandler, Action cancelCallback) { InitializeComponent(); ModeProfileConfigViewModel = new ModeProfileConfigWindowViewModel(eventAggregator, appDispatcher, mode, activationButtonList); ModeProfileConfigViewModel.SaveCancelled += SaveCancelled; ModeProfileConfigViewModel.NewModeProfileSaved += NewModeProfileSaved; Closed += OnClosed; DataContext = ModeProfileConfigViewModel; pressedHandler(PressedHandler); _removePressedHandler = removePressedHandler; _cancelCallback = cancelCallback; }
public void basic_constructor_shift_not_set() { 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>(), Substitute.For <IDispatcher>(), mode, activationButtonList); Assert.False(profileVm.IsShift); }
public void basic_constructor_no_mode() { const int mode = 0; var activationButtonList = new Dictionary <int, ModeActivationItem> { { 1, new ModeActivationItem() { ButtonId = 1, ButtonName = "test button" } } }; var profileVm = new ModeProfileConfigWindowViewModel(Substitute.For <IEventAggregator>(), Substitute.For <IDispatcher>(), mode, activationButtonList); Assert.Equal(2, profileVm.TemplateModes.Count); Assert.True(profileVm.IsTemplateModeVisible); Assert.Null(profileVm.ProfileName); }
public void save_mode_profile_command_remove_existing_activation_button() { const int modeToRemove = 2; var activationButton = new ModeActivationItem() { ButtonId = 1, ButtonName = "test button 1", ProfileName = "select combat mode" }; var removeThisItem = new ModeActivationItem() { ButtonId = 2, ButtonName = "test button 2", ProfileName = "select nav mode" }; var activationButtonList = new Dictionary <int, ModeActivationItem> { { 1, activationButton }, { 2, removeThisItem } }; var subEventAggregator = Substitute.For <IEventAggregator>(); var profileVm = new ModeProfileConfigWindowViewModel(subEventAggregator, Substitute.For <IDispatcher>(), modeToRemove, activationButtonList); profileVm.SaveModeProfileCommand.Execute(default);
public void basic_constructor_no_valid_mode() { const int mode = 1; var deviceId = Guid.NewGuid(); var activationButtonList = new Dictionary <int, ModeActivationItem> { { 1, new ModeActivationItem() { ButtonId = 1, ButtonName = "test button", ProfileName = "select combat mode", IsShift = true, DeviceId = deviceId } } }; var dispatcher = new TestDispatcher(); var profileVm = new ModeProfileConfigWindowViewModel(Substitute.For <IEventAggregator>(), dispatcher, mode, activationButtonList); Assert.Equal(2, profileVm.TemplateModes.Count); Assert.False(profileVm.IsTemplateModeVisible); Assert.Equal("select combat mode", profileVm.ProfileName); Assert.Equal("test button", profileVm.ActivationButtonName); Assert.True(profileVm.IsShift); }
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); }
public void basic_constructor_template_not_visible_by_null_activation_button_list() { var profileVm = new ModeProfileConfigWindowViewModel(); Assert.False(profileVm.IsTemplateModeVisible); }
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); }