public void constructor() { var mapVm = new ButtonMapViewModel(); Assert.Empty(mapVm.Actions); Assert.NotNull(mapVm.ActionItem); }
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 to_string() { var map = new HOTASButton() { MapName = "test map", MapId = 43, Type = HOTASButton.ButtonType.Button, ActionCatalogItem = new ActionCatalogItem() { ActionName = "test action" } }; var mapVm = new ButtonMapViewModel(map); Assert.Equal($"ButtonMap MapId:{map.MapId}, {map.MapName}", mapVm.ToString()); }
public void add_map_then_value_exists() { var catalog = new ActionCatalogViewModel(); var item = new ButtonMapViewModel() { ActionItem = new ActionCatalogItem() { ActionName = "testitem", NoAction = false } }; catalog.Add(item); Assert.True(catalog.Contains(item.ActionName)); }
public void add_map_with_blank_buttonName_generates_new_name() { var catalog = new ActionCatalogViewModel(); var item = new ButtonMapViewModel() { ButtonName = "Buttons0", ActionItem = new ActionCatalogItem() { ActionName = "", NoAction = false } }; catalog.Add(item); Assert.Equal("Action for Buttons0", item.ActionName); }
public void add_map_twice_then_not_added() { var catalog = new ActionCatalogViewModel(); var item = new ButtonMapViewModel() { ActionItem = new ActionCatalogItem() { ActionName = "testitem", NoAction = false } }; catalog.Add(item); Assert.Equal(2, catalog.Catalog.Count); catalog.Add(item); Assert.Equal(2, catalog.Catalog.Count); }
public void constructor_param() { var map = new HOTASButton() { MapName = "test map", MapId = 43, Type = HOTASButton.ButtonType.Button, ActionCatalogItem = new ActionCatalogItem() { ActionName = "test action" } }; var mapVm = new ButtonMapViewModel(map); Assert.Empty(mapVm.Actions); Assert.NotNull(mapVm.ActionItem); Assert.Equal(43, mapVm.ButtonId); Assert.Equal("test map", mapVm.ButtonName); Assert.Equal(HOTASButton.ButtonType.Button, mapVm.Type); Assert.Equal("test action", mapVm.ActionItem.ActionName); Assert.False(mapVm.IsRecording); Assert.False(mapVm.IsDisabledForced); }
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); }