Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Importers/HydraulicLocationConfigurationDatabaseImporterTest.cs =================================================================== diff -u -raeb8b7cf8ba81e69086ea6e8d06fcd73592152b2 -r3a3b726aad1fb814bd89643bebe825692f16b13c --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Importers/HydraulicLocationConfigurationDatabaseImporterTest.cs (.../HydraulicLocationConfigurationDatabaseImporterTest.cs) (revision aeb8b7cf8ba81e69086ea6e8d06fcd73592152b2) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Importers/HydraulicLocationConfigurationDatabaseImporterTest.cs (.../HydraulicLocationConfigurationDatabaseImporterTest.cs) (revision 3a3b726aad1fb814bd89643bebe825692f16b13c) @@ -292,6 +292,42 @@ mocks.VerifyAll(); } + [Test] + [TestCase(1)] + [TestCase(2)] + public void Import_CancelOfImportWhilePerformingStep_CancelsImportAndLogs(int stepNumber) + { + // Setup + var mocks = new MockRepository(); + var handler = mocks.StrictMock(); + mocks.ReplayAll(); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validHrdFilePath + }; + + var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, + hydraulicBoundaryDatabase, validHlcdFilePath); + importer.SetProgressChanged((description, currentStep, steps) => + { + if (currentStep == stepNumber) + { + importer.Cancel(); + } + }); + + // Call + var importResult = true; + Action call = () => importResult = importer.Import(); + + // Assert + const string expectedMessage = "HLCD importeren afgebroken. Geen gegevens gewijzigd."; + TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Info), 1); + Assert.IsFalse(importResult); + mocks.VerifyAll(); + } + private static void AssertImportFailed(Action call, string errorMessage, ref bool importSuccessful) { string expectedMessage = $"{errorMessage}" +