示例#1
0
        public void OnLoaderReturningEmptyString_ShouldNotImport()
        {
            _loader.Setup(x => x.LoadFromFile(Loa1, It.IsAny <string>())).Returns(Task.FromResult(string.Empty));
            GenericPlcViewModel viewModel = CreateGenericPlcViewModel();

            viewModel.Import();
            _informationProvider.Verify(x => x.Import(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
        }
示例#2
0
        public void ShouldDisplayImportFeedback()
        {
            _loader.Setup(x => x.LoadFromFile(Loa1, ".xml")).Returns(Task.FromResult("<anyresult/>"));
            _informationProvider.Setup(x => x.Import(Loa1, "<anyresult/>")).Returns(Task.FromResult(new ImportExportResultViewModel()));
            GenericPlcViewModel viewModel = CreateGenericPlcViewModel();

            viewModel.Import();
            viewModel.ImportResultViewModel.IsVisible.Should().BeTrue();
        }
示例#3
0
        public void OnFailingLoader_ShouldDisplayErrorMessage()
        {
            string randomError = CreateRandom.String();

            _loader.Setup(x => x.LoadFromFile(It.IsAny <string>(), It.IsAny <string>())).Throws(new Exception(randomError));
            GenericPlcViewModel viewModel = CreateGenericPlcViewModel();

            viewModel.Import();
            _states.Verify(x => x.ChangeToErrorState(It.Is <string>(s => s.Contains(randomError))));
        }
示例#4
0
        public void ShouldImportLoadedFile()
        {
            string randomControllerTree = CreateRandom.String();

            _loader.Setup(x => x.LoadFromFile(_randomModule, ".xml")).Returns(Task.FromResult(randomControllerTree));
            GenericPlcViewModel viewModel = CreateGenericPlcViewModel(_randomModule);

            viewModel.Import();
            _informationProvider.Verify(x => x.Import(_randomModule, randomControllerTree));
        }
示例#5
0
        public void OnFailingImport_ShouldDisplayErrorMessage()
        {
            string randomError = CreateRandom.String();

            _loader.Setup(x => x.LoadFromFile(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult("My controller tree."));
            _informationProvider.Setup(x => x.Import(It.IsAny <string>(), It.IsAny <string>())).Throws(new Exception(randomError));
            GenericPlcViewModel viewModel = CreateGenericPlcViewModel();

            viewModel.Import();
            _states.Verify(x => x.ChangeToErrorState(It.Is <string>(s => s.Contains(randomError))));
        }