示例#1
0
        public void constructor()
        {
            var mapVm = new ButtonMapViewModel();

            Assert.Empty(mapVm.Actions);
            Assert.NotNull(mapVm.ActionItem);
        }
示例#2
0
        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);
        }
示例#3
0
        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));
示例#4
0
        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);
        }
示例#8
0
        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);
        }
示例#9
0
        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);
        }
示例#10
0
        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);
        }
示例#11
0
        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);
        }