Пример #1
0
        public void OnRandomModule_ShouldGetRootControllerOfRandomModule()
        {
            TestableGenericPlcViewModel viewModel = CreateTestableGenericPlcViewModel(moduleName: _randomModule);

            viewModel.Activate();
            _informationProvider.Verify(x => x.LoadRootController(_randomModule));
        }
Пример #2
0
        public void ShouldChangeToLoadingState()
        {
            TestableGenericPlcViewModel viewModel = CreateTestableGenericPlcViewModel();

            viewModel.Activate();
            _states.Verify(x => x.ChangeToLoadingState());
        }
Пример #3
0
        public void OnInformationProviderWithError_ShouldChangeToErrorState()
        {
            _informationProvider.Setup(x => x.LoadRootController(It.IsAny <string>())).Throws(new InvalidOperationException());
            TestableGenericPlcViewModel viewModel = CreateTestableGenericPlcViewModel();

            viewModel.Activate();
            _states.Verify(x => x.ChangeToErrorState(It.IsAny <string>()));
        }
Пример #4
0
        public void OnExistingModule_ShouldChangeToContentState()
        {
            _informationProvider.Setup(x => x.LoadRootController(It.IsAny <string>())).Returns(Task.FromResult(new Controller()));
            TestableGenericPlcViewModel viewModel = CreateTestableGenericPlcViewModel();

            viewModel.Activate();
            _states.Verify(x => x.ChangeToContentState());
        }
Пример #5
0
        public void OnInformationProviderWithRandomError_ShouldExposeRandomError()
        {
            string randomError = CreateRandom.String();

            _informationProvider.Setup(x => x.LoadRootController(It.IsAny <string>())).Throws(new InvalidOperationException(randomError));
            TestableGenericPlcViewModel viewModel = CreateTestableGenericPlcViewModel();

            viewModel.MonitorEvents();
            viewModel.Activate();
            _states.Verify(s => s.ChangeToErrorState(It.Is <string>(e => e.Contains(randomError))));
        }
Пример #6
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> >()));
        }