public void assign_actions() { var catalog = new ActionCatalogItem() { ActionName = "test action" }; catalog.Actions = new ObservableCollection <ButtonAction>() { new ButtonAction() { ScanCode = 1 }, new ButtonAction() { ScanCode = 2 }, new ButtonAction() { ScanCode = 3 }, }; var map = new HOTASButton() { MapName = "test map", MapId = 43, Type = HOTASButton.ButtonType.Button }; var mapVm = new ButtonMapViewModel(map); Assert.Empty(mapVm.Actions); mapVm.AssignActions(catalog); Assert.NotEmpty(mapVm.GetHotasActions()); Assert.NotEmpty(mapVm.Actions); Assert.Same(catalog, mapVm.ActionItem); }
public void record_macro_start_can_execute_not_disabled() { var catalog = new ActionCatalogItem() { ActionName = "test action" }; catalog.Actions = new ObservableCollection <ButtonAction>() { new ButtonAction() { ScanCode = 1 }, new ButtonAction() { ScanCode = 2 }, new ButtonAction() { ScanCode = 3 }, }; var map = new HOTASButton() { MapName = "test map", MapId = 43, Type = HOTASButton.ButtonType.Button, ActionCatalogItem = catalog }; var mapVm = new ButtonMapViewModel(map); mapVm.IsDisabledForced = false; Assert.True(mapVm.RecordMacroStartCommand.CanExecute(default));
public void add_item_then_value_exists() { var catalog = new ActionCatalogViewModel(); var item = new ActionCatalogItem() { ActionName = "testitem1" }; catalog.Add(item); Assert.True(catalog.Contains(item.ActionName)); }
public void add_item_twice_then_not_added() { var catalog = new ActionCatalogViewModel(); var item = new ActionCatalogItem() { ActionName = "testitem1" }; catalog.Add(item); Assert.Equal(2, catalog.Catalog.Count); catalog.Add(item); Assert.Equal(2, catalog.Catalog.Count); }
public void Add(ActionCatalogItem item) { if (Catalog.Contains(item)) { return; } if (Contains(item.ActionName)) { var i = Catalog.First(x => x.ActionName == item.ActionName); Catalog.Remove(i); } Catalog.Add(item); }
public void add_item_with_same_name_then_not_added() { var sameName = "samename"; var catalog = new ActionCatalogViewModel(); var item1 = new ActionCatalogItem() { ActionName = sameName }; catalog.Add(item1); Assert.Equal(2, catalog.Catalog.Count); var item2 = new ActionCatalogItem() { ActionName = sameName }; catalog.Add(item2); Assert.Equal(2, catalog.Catalog.Count); }
public void action_name_changed() { var catalog = new ActionCatalogItem() { ActionName = "test action" }; catalog.Actions = new ObservableCollection <ButtonAction>() { new ButtonAction() { ScanCode = 1 }, new ButtonAction() { ScanCode = 2 }, new ButtonAction() { ScanCode = 3 }, }; var map = new HOTASButton() { MapName = "test map", MapId = 43, Type = HOTASButton.ButtonType.Button }; var mapVm = new ButtonMapViewModel(map); mapVm.AssignActions(catalog); Assert.Equal("test action", mapVm.ActionName); var newActionName = "new action name"; Assert.PropertyChanged(mapVm, "ActionName", () => mapVm.ActionName = newActionName); Assert.Equal(newActionName, mapVm.ActionItem.ActionName); }
public void activate_shift_mode_page() { var shiftModePage = 43; var newShiftModePage = 1; var catalog = new ActionCatalogItem() { ActionName = "test action" }; catalog.Actions = new ObservableCollection <ButtonAction>() { new ButtonAction() { ScanCode = 1 }, new ButtonAction() { ScanCode = 2 }, new ButtonAction() { ScanCode = 3 }, }; var map = new HOTASButton() { MapName = "test map", MapId = 43, Type = HOTASButton.ButtonType.Button, ShiftModePage = shiftModePage }; var mapVm = new ButtonMapViewModel(map); mapVm.AssignActions(catalog); Assert.Equal(shiftModePage, mapVm.ActivateShiftModePage); Assert.PropertyChanged(mapVm, "ActivateShiftModePage", () => mapVm.ActivateShiftModePage = 1); Assert.NotEqual(shiftModePage, mapVm.ActivateShiftModePage); Assert.Equal(newShiftModePage, mapVm.ActivateShiftModePage); }
public void rebuild_button_action_view_model() { var catalog = new ActionCatalogItem() { ActionName = "test action" }; catalog.Actions = new ObservableCollection <ButtonAction>() { new ButtonAction() { ScanCode = 1 }, new ButtonAction() { ScanCode = 2 }, new ButtonAction() { ScanCode = 3 }, }; var map = new HOTASButton() { MapName = "test map", MapId = 43, Type = HOTASButton.ButtonType.Button }; var mapVm = new ButtonMapViewModel(map); mapVm.AssignActions(catalog); Assert.NotEmpty(mapVm.Actions); mapVm.Actions.Clear(); mapVm.ReBuildButtonActionViewModel(); Assert.NotEmpty(mapVm.Actions); Assert.Equal("ESCAPE", mapVm.Actions[0].ScanCode); }