Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Importers/HydraulicLocationConfigurationDatabaseImporter.cs =================================================================== diff -u -r43aaedc15ee45c14645d300e75953bf550ab5ed4 -raeb8b7cf8ba81e69086ea6e8d06fcd73592152b2 --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Importers/HydraulicLocationConfigurationDatabaseImporter.cs (.../HydraulicLocationConfigurationDatabaseImporter.cs) (revision 43aaedc15ee45c14645d300e75953bf550ab5ed4) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Importers/HydraulicLocationConfigurationDatabaseImporter.cs (.../HydraulicLocationConfigurationDatabaseImporter.cs) (revision aeb8b7cf8ba81e69086ea6e8d06fcd73592152b2) @@ -39,6 +39,7 @@ /// public class HydraulicLocationConfigurationDatabaseImporter : FileImporterBase { + private const int numberOfSteps = 2; private readonly HydraulicBoundaryDatabase hydraulicBoundaryDatabase; /// @@ -109,6 +110,7 @@ private ReadResult ReadTrackId() { + NotifyProgress(Resources.HydraulicBoundaryDatabaseImporter_ProgressText_Reading_HRD_file, 1, numberOfSteps); try { using (var reader = new HydraulicBoundaryDatabaseReader(hydraulicBoundaryDatabase.FilePath)) @@ -130,6 +132,7 @@ private ReadResult ReadHydraulicLocationConfigurationDatabase(long trackId) { + NotifyProgress(Resources.HydraulicBoundaryDatabaseImporter_ProgressText_Reading_HLCD_file, 2, numberOfSteps); try { using (var reader = new HydraulicLocationConfigurationDatabaseReader(FilePath)) Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Importers/HydraulicLocationConfigurationDatabaseImporterTest.cs =================================================================== diff -u -r43aaedc15ee45c14645d300e75953bf550ab5ed4 -raeb8b7cf8ba81e69086ea6e8d06fcd73592152b2 --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Importers/HydraulicLocationConfigurationDatabaseImporterTest.cs (.../HydraulicLocationConfigurationDatabaseImporterTest.cs) (revision 43aaedc15ee45c14645d300e75953bf550ab5ed4) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Importers/HydraulicLocationConfigurationDatabaseImporterTest.cs (.../HydraulicLocationConfigurationDatabaseImporterTest.cs) (revision aeb8b7cf8ba81e69086ea6e8d06fcd73592152b2) @@ -20,12 +20,14 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.IO; using Core.Common.Base.IO; using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.IO.TestUtil; using Ringtoets.Integration.IO.Handlers; using Ringtoets.Integration.IO.Importers; @@ -34,17 +36,19 @@ [TestFixture] public class HydraulicLocationConfigurationDatabaseImporterTest { + private const int totalNumberOfSteps = 2; private static readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.IO, nameof(HydraulicLocationConfigurationDatabaseImporter)); private readonly string validHrdFilePath = Path.Combine(testDataPath, "completeHrd.sqlite"); + private readonly string validHlcdFilePath = Path.Combine(testDataPath, "HLCD.sqlite"); [Test] public void Constructor_UpdateHandlerNull_ThrowsArgumentNullException() { // Call TestDelegate call = () => new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), null, - new HydraulicBoundaryDatabase(), ""); + new HydraulicBoundaryDatabase(), validHlcdFilePath); // Assert var exception = Assert.Throws(call); @@ -60,7 +64,8 @@ mocks.ReplayAll(); // Call - TestDelegate call = () => new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, null, ""); + TestDelegate call = () => new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, + null, validHlcdFilePath); // Assert var exception = Assert.Throws(call); @@ -77,7 +82,7 @@ // Call var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, - new HydraulicBoundaryDatabase(), ""); + new HydraulicBoundaryDatabase(), validHlcdFilePath); // Assert Assert.IsInstanceOf>(importer); @@ -93,22 +98,21 @@ mocks.ReplayAll(); string hydraulicBoundaryDatabasePath = Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.IO, - nameof(HydraulicBoundaryDatabaseImporter)), "complete.sqlite"); - string path = Path.Combine(testDataPath, "hlcd.sqlite"); - + nameof(HydraulicBoundaryDatabaseImporter)),"complete.sqlite"); var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { FilePath = hydraulicBoundaryDatabasePath }; - var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, hydraulicBoundaryDatabase, path); + var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, + hydraulicBoundaryDatabase, validHlcdFilePath); // 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."; + string expectedMessage = $"Fout bij het lezen van bestand '{validHlcdFilePath}': het HLCD bestand is niet gevonden in dezelfde map als het HRD bestand."; AssertImportFailed(call, expectedMessage, ref importSuccessful); mocks.VerifyAll(); } @@ -184,7 +188,8 @@ FilePath = validHrdFilePath }; - var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, hydraulicBoundaryDatabase, path); + var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, + hydraulicBoundaryDatabase, path); // Call var importSuccessful = true; @@ -211,7 +216,8 @@ FilePath = validHrdFilePath }; - var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, hydraulicBoundaryDatabase, path); + var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, + hydraulicBoundaryDatabase, path); // Call var importSuccessful = true; @@ -240,7 +246,8 @@ FilePath = validHrdFilePath }; - var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, hydraulicBoundaryDatabase, path); + var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, + hydraulicBoundaryDatabase, path); // Call var importSuccessful = true; @@ -252,6 +259,39 @@ mocks.VerifyAll(); } + [Test] + public void Import_ValidFiles_ExpectedProgressNotifications() + { + // Setup + var mocks = new MockRepository(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var progressChangeNotifications = new List(); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validHrdFilePath + }; + + var importer = new HydraulicLocationConfigurationDatabaseImporter(new HydraulicLocationConfigurationSettings(), handler, + hydraulicBoundaryDatabase, validHlcdFilePath); + importer.SetProgressChanged((description, step, steps) => progressChangeNotifications.Add(new ProgressNotification(description, step, steps))); + + // Call + bool importResult = importer.Import(); + + // Assert + Assert.IsTrue(importResult); + var expectedProgressNotifications = new[] + { + new ProgressNotification("Inlezen van het hydraulische belastingen bestand.", 1, totalNumberOfSteps), + new ProgressNotification("Inlezen van het hydraulische locatie configuratie bestand.", 2, totalNumberOfSteps), + }; + ProgressNotificationTestHelper.AssertProgressNotificationsAreEqual(expectedProgressNotifications, progressChangeNotifications); + mocks.VerifyAll(); + } + private static void AssertImportFailed(Action call, string errorMessage, ref bool importSuccessful) { string expectedMessage = $"{errorMessage}" +