Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
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);
        }
Exemple #4
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);
        }