public void ShouldUnsubscribeFromTreeUpdates()
        {
            TestableGenericPlcViewModel viewModel = CreateTestableGenericPlcViewModel(moduleName: _randomModule);

            viewModel.Deactivate();
            _informationProvider.Verify(i => i.UnsubscribeFromTreeUpdate(_randomModule, It.IsAny <Action <Controller> >()));
        }
        public void OnTreeWithoutManualModeController_ShouldNotAskUser()
        {
            TestableGenericPlcViewModel viewModel = CreateTestableGenericPlcViewModel();

            viewModel.Deactivate();
            _askUser.Verify(a => a.AskYesOrNoQuestion(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
        }
        public void WithCloseTrue_OnTreeWithControllersInManualMode_ShouldNotAskUser()
        {
            TestableGenericPlcViewModel viewModel = CreateTestableGenericPlcViewModel(_randomModule);

            viewModel.MasterTree.Add(ControllerInManualMode());
            viewModel.Deactivate(close: true);
            _askUser.Verify(a => a.AskYesOrNoQuestion(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
        }
        public void OnTreeWithControllersInManualMode_ShouldAskUserAboutAutoMode()
        {
            TestableGenericPlcViewModel viewModel = CreateTestableGenericPlcViewModel(_randomModule);

            viewModel.MasterTree.Add(ControllerInManualMode());
            viewModel.Deactivate();
            _askUser.Verify(a => a.AskYesOrNoQuestion(It.IsAny <string>(), It.IsAny <string>()));
        }
        public void ShouldUnsubscribeFromSelectedItem()
        {
            int randomController = CreateRandom.Int();
            TestableGenericPlcViewModel viewModel = CreateTestableGenericPlcViewModel(moduleName: _randomModule);

            viewModel.SelectedItem = MasterDetailViewModel(_randomModule, randomController);
            viewModel.Deactivate();
            _informationProvider.Verify(i => i.UnsubscribeFromControllerChanges(_randomModule, randomController, It.IsAny <Action <Controller> >()));
        }
        public void OnTreeWithManualModeControllerAndUserNotSettingToAuto_ShouldNotSetAllControllersToAutoMode()
        {
            TestableGenericPlcViewModel viewModel = CreateTestableGenericPlcViewModel(_randomModule);

            viewModel.MasterTree.Add(ControllerInManualMode());
            _askUser.Setup(a => a.AskYesOrNoQuestion(It.IsAny <string>(), It.IsAny <string>())).Returns(false);

            viewModel.Deactivate();

            _informationProvider.Verify(i => i.SetAllControllersToMode(_randomModule, Controller.Mode.Auto), Times.Never);
        }
Exemple #7
0
        public void OnPreviouslyDeactivatedViewModel_ShouldSubscribeForSelectedItem()
        {
            int randomController = CreateRandom.Int();
            TestableGenericPlcViewModel viewModel     = CreateTestableGenericPlcViewModel(moduleName: _randomModule);
            MasterDetailViewModel       anyController = MasterDetailViewModel(_randomModule, randomController);

            viewModel.MasterTree.Add(anyController);
            viewModel.SelectedItem = anyController;
            viewModel.Deactivate();
            viewModel.Activate();
            _informationProvider.Verify(x => x.SubscribeForControllerChanges(_randomModule, randomController, It.IsAny <Action <Controller> >()));
        }