public void Import_CancelOfImportWhileCreateProfiles_ContinueImportAndLogWarning() { // Setup const string addingDataToModel = "Adding Data to Model"; var messageProvider = mocks.Stub <IImporterMessageProvider>(); messageProvider.Stub(mp => mp.GetAddDataToModelProgressText()).Return(addingDataToModel); mocks.ReplayAll(); string filePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO, Path.Combine("DikeProfiles", "AllOkTestData", "Voorlanden 12-2.shp")); ReferenceLine referenceLine = CreateMatchingReferenceLine(); var testProfilesImporter = new TestProfilesImporter(testImportTarget, referenceLine, filePath, messageProvider); testProfilesImporter.SetProgressChanged((description, step, steps) => { if (description.Contains(addingDataToModel)) { testProfilesImporter.Cancel(); } }); var importResult = false; // Call Action call = () => importResult = testProfilesImporter.Import(); // Assert const string expectedMessage = "Huidige actie was niet meer te annuleren en is daarom voortgezet."; TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Warn), 2); Assert.IsTrue(importResult); }
public void Import_ReuseOfCanceledImportToValidTargetWithValidFile_True() { // Setup var messageProvider = mocks.Stub <IImporterMessageProvider>(); mocks.ReplayAll(); string filePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO, Path.Combine("DikeProfiles", "AllOkTestData", "Voorlanden 12-2.shp")); ReferenceLine referenceLine = CreateMatchingReferenceLine(); var testProfilesImporter = new TestProfilesImporter(new ObservableList <object>(), referenceLine, filePath, messageProvider); testProfilesImporter.SetProgressChanged((description, step, steps) => testProfilesImporter.Cancel()); bool importResult = testProfilesImporter.Import(); // Precondition Assert.IsFalse(importResult); testProfilesImporter.SetProgressChanged(null); // Call importResult = testProfilesImporter.Import(); // Assert Assert.IsTrue(importResult); }
public void Import_CancelOfImportWhileReadingDikeProfileLocations_ReturnsFalse() { // Setup var messageProvider = mocks.Stub <IImporterMessageProvider>(); mocks.ReplayAll(); string filePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO, Path.Combine("DikeProfiles", "AllOkTestData", "Voorlanden 12-2.shp")); ReferenceLine referenceLine = CreateMatchingReferenceLine(); var testProfilesImporter = new TestProfilesImporter(testImportTarget, referenceLine, filePath, messageProvider); testProfilesImporter.SetProgressChanged((description, step, steps) => { if (description.Contains("Inlezen van profielgegevens uit een prfl bestand.")) { testProfilesImporter.Cancel(); } }); // Call bool importResult = testProfilesImporter.Import(); // Assert Assert.IsFalse(importResult); }