Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Importers/HydraulicLocationConfigurationDatabaseImporterTest.cs =================================================================== diff -u -r7f9914406799f37e7969a4c0061693772788d0ec -r43aaedc15ee45c14645d300e75953bf550ab5ed4 --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Importers/HydraulicLocationConfigurationDatabaseImporterTest.cs (.../HydraulicLocationConfigurationDatabaseImporterTest.cs) (revision 7f9914406799f37e7969a4c0061693772788d0ec) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Importers/HydraulicLocationConfigurationDatabaseImporterTest.cs (.../HydraulicLocationConfigurationDatabaseImporterTest.cs) (revision 43aaedc15ee45c14645d300e75953bf550ab5ed4) @@ -37,6 +37,8 @@ private static readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.IO, nameof(HydraulicLocationConfigurationDatabaseImporter)); + private readonly string validHrdFilePath = Path.Combine(testDataPath, "completeHrd.sqlite"); + [Test] public void Constructor_UpdateHandlerNull_ThrowsArgumentNullException() { @@ -110,8 +112,64 @@ AssertImportFailed(call, expectedMessage, ref importSuccessful); mocks.VerifyAll(); } + + [Test] + public void Import_HrdInvalidSchema_CancelImportWithErrorMessage() + { + // Setup + var mocks = new MockRepository(); + var handler = mocks.StrictMock(); + mocks.ReplayAll(); + string path = Path.Combine(testDataPath, "CorruptHrd"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = Path.Combine(path, "corruptschema.sqlite") + }; + + var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, + hydraulicBoundaryDatabase, Path.Combine(path, "HLCD.sqlite")); + + // Call + var importSuccessful = true; + Action call = () => importSuccessful = importer.Import(); + + // Assert + string expectedMessage = $"Fout bij het lezen van bestand '{hydraulicBoundaryDatabase.FilePath}': kritieke fout opgetreden bij het uitlezen van waardes uit kolommen in de database."; + AssertImportFailed(call, expectedMessage, ref importSuccessful); + mocks.VerifyAll(); + } + [Test] + public void Import_HrdEmptySchema_CancelImportWithErrorMessage() + { + // Setup + var mocks = new MockRepository(); + var handler = mocks.StrictMock(); + mocks.ReplayAll(); + + string path = Path.Combine(testDataPath, "EmptyHrd"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = Path.Combine(path, "empty.sqlite") + }; + + var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, + hydraulicBoundaryDatabase, Path.Combine(path, "HLCD.sqlite")); + + // Call + var importSuccessful = true; + Action call = () => importSuccessful = importer.Import(); + + // Assert + string expectedMessage = $"Fout bij het lezen van bestand '{hydraulicBoundaryDatabase.FilePath}': kon geen locaties verkrijgen van de database."; + AssertImportFailed(call, expectedMessage, ref importSuccessful); + mocks.VerifyAll(); + } + + [Test] public void Import_EmptySchema_CancelImportWithErrorMessage() { // Setup @@ -123,7 +181,7 @@ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { - FilePath = path + FilePath = validHrdFilePath }; var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, hydraulicBoundaryDatabase, path); @@ -150,8 +208,7 @@ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { - FilePath = path, - TrackId = 13 + FilePath = validHrdFilePath }; var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, hydraulicBoundaryDatabase, path); @@ -180,8 +237,7 @@ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { - FilePath = path, - TrackId = 13 + FilePath = validHrdFilePath }; var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, hydraulicBoundaryDatabase, path);