public void OnFailingSaver_ShouldDisplayErrorMessage() { string randomErrorMessage = CreateRandom.String(); _saver.Setup(x => x.SaveStringToFile(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Throws(new Exception(randomErrorMessage)); GenericPlcViewModel viewModel = CreateGenericPlcViewModel(); viewModel.Export(); _states.Verify(s => s.ChangeToErrorState(It.Is <string>(x => x.Contains(randomErrorMessage)))); }
public void ShouldSaveExportedValue() { string exportedTree = CreateRandom.String(); _informationProvider.Setup(x => x.Export(_randomModule)).Returns(Task.FromResult(exportedTree)); GenericPlcViewModel viewModel = CreateGenericPlcViewModel(moduleName: _randomModule); viewModel.Export(); _saver.Verify(x => x.SaveStringToFile(exportedTree, _randomModule, ".xml")); }
public void ShouldDisplayFeedbackDialog() { string exportedTree = CreateRandom.String(); _informationProvider.Setup(x => x.Export(_randomModule)).Returns(Task.FromResult(exportedTree)); _saver.Setup(x => x.SaveStringToFile(exportedTree, _randomModule, ".xml")).Returns(Task.FromResult(true)); GenericPlcViewModel viewModel = CreateGenericPlcViewModel(moduleName: _randomModule); viewModel.Export(); viewModel.ExportResultViewModel.IsVisible.Should().BeTrue(); }