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); }
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(); }
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)))); }
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)); }
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)))); }