Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Importers/HydraulicLocationConfigurationDatabaseImporterTest.cs =================================================================== diff -u -r3485eb4a889b222fb4ee148d38b7916e96034482 -re2e1d9ca600ee1370b26d091469cca85142e10e2 --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Importers/HydraulicLocationConfigurationDatabaseImporterTest.cs (.../HydraulicLocationConfigurationDatabaseImporterTest.cs) (revision 3485eb4a889b222fb4ee148d38b7916e96034482) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Importers/HydraulicLocationConfigurationDatabaseImporterTest.cs (.../HydraulicLocationConfigurationDatabaseImporterTest.cs) (revision e2e1d9ca600ee1370b26d091469cca85142e10e2) @@ -20,7 +20,9 @@ // All rights reserved. using System; +using System.IO; using Core.Common.Base.IO; +using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.Hydraulics; @@ -32,6 +34,9 @@ [TestFixture] public class HydraulicLocationConfigurationDatabaseImporterTest { + private static readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.IO, + nameof(HydraulicLocationConfigurationDatabaseImporter)); + [Test] public void Constructor_UpdateHandlerNull_ThrowsArgumentNullException() { @@ -76,5 +81,42 @@ Assert.IsInstanceOf>(importer); mocks.VerifyAll(); } + + [Test] + public void Import_FilePathIsDifferentFromHydraulicBoundaryDatabasesFilePath_CancelImportWithErrorMessage() + { + // Setup + var mocks = new MockRepository(); + var handler = mocks.StrictMock(); + mocks.ReplayAll(); + + string hydraulicBoundaryDatabasePath = Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.IO, + nameof(HydraulicBoundaryDatabaseImporter)), "complete.sqlite"); + string path = Path.Combine(testDataPath, "hlcd.sqlite"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = hydraulicBoundaryDatabasePath + }; + + var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, hydraulicBoundaryDatabase, path); + + // Call + var importSuccessful = true; + Action call = () => importSuccessful = importer.Import(); + + // Assert + string expectedMessage = $"Fout bij het lezen van bestand '{path}': het HLCD bestand is niet gevonden in dezelfde map als het HRD bestand."; + AssertImportFailed(call, expectedMessage, ref importSuccessful); + mocks.VerifyAll(); + } + + private static void AssertImportFailed(Action call, string errorMessage, ref bool importSuccessful) + { + string expectedMessage = $"{errorMessage}" + + $"{Environment.NewLine}Er is geen HLCD geïmporteerd."; + TestHelper.AssertLogMessageWithLevelIsGenerated(call, new Tuple(expectedMessage, LogLevelConstant.Error), 1); + Assert.IsFalse(importSuccessful); + } } } \ No newline at end of file