Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Importers/HydraulicLocationConfigurationDatabaseImporterTest.cs =================================================================== diff -u -r213009c55db126accc5c1a525986abdfa7b90fa4 -r82e011f6483819792f86f0f33e3b64b81acac480 --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Importers/HydraulicLocationConfigurationDatabaseImporterTest.cs (.../HydraulicLocationConfigurationDatabaseImporterTest.cs) (revision 213009c55db126accc5c1a525986abdfa7b90fa4) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Importers/HydraulicLocationConfigurationDatabaseImporterTest.cs (.../HydraulicLocationConfigurationDatabaseImporterTest.cs) (revision 82e011f6483819792f86f0f33e3b64b81acac480) @@ -1,4 +1,4 @@ -// Copyright (C) Stichting Deltares 2018. All rights reserved. +// Copyright (C) Stichting Deltares 2018. All rights reserved. // // This file is part of Ringtoets. // @@ -22,12 +22,15 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; +using Core.Common.Base; 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.HydraRing.IO.HydraulicLocationConfigurationDatabase; using Ringtoets.Integration.IO.Handlers; using Ringtoets.Integration.IO.Importers; @@ -265,6 +268,8 @@ // Setup var mocks = new MockRepository(); var handler = mocks.Stub(); + handler.Stub(h => h.InquireConfirmation()).Return(true); + handler.Stub(h => h.Update(null, null, null)).IgnoreArguments().Return(Enumerable.Empty()); mocks.ReplayAll(); var progressChangeNotifications = new List(); @@ -357,6 +362,68 @@ mocks.VerifyAll(); } + [Test] + public void Import_ValidFileWithoutScenarioInformation_UpdatesHydraulicBoundaryDatabaseWithImportedData() + { + // Setup + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validHrdFilePath + }; + + string filePath = Path.Combine(testDataPath, "hlcdWithoutScenarioInformation.sqlite"); + + var mocks = new MockRepository(); + var handler = mocks.StrictMock(); + handler.Expect(h => h.InquireConfirmation()).Return(true); + handler.Expect(h => h.Update(Arg.Is.Same(hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings), + Arg.Is.Null, + Arg.Is.Equal(filePath))) + .Return(Enumerable.Empty()); + mocks.ReplayAll(); + + var importer = new HydraulicLocationConfigurationDatabaseImporter(hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings, handler, + hydraulicBoundaryDatabase, filePath); + + // Call + bool importResult = importer.Import(); + + // Assert + Assert.IsTrue(importResult); + mocks.VerifyAll(); + } + + [Test] + public void Import_ValidFileWithScenarioInformation_UpdatesHydraulicBoundaryDatabaseWithImportedData() + { + // Setup + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validHrdFilePath + }; + + string filePath = Path.Combine(testDataPath, "hlcdWithValidScenarioInformation.sqlite"); + + var mocks = new MockRepository(); + var handler = mocks.StrictMock(); + handler.Expect(h => h.InquireConfirmation()).Return(true); + handler.Expect(h => h.Update(Arg.Is.Same(hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings), + Arg.Is.NotNull, + Arg.Is.Equal(filePath))) + .Return(Enumerable.Empty()); + mocks.ReplayAll(); + + var importer = new HydraulicLocationConfigurationDatabaseImporter(hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings, handler, + hydraulicBoundaryDatabase, filePath); + + // Call + bool importResult = importer.Import(); + + // Assert + Assert.IsTrue(importResult); + mocks.VerifyAll(); + } + private static void AssertImportFailed(Action call, string errorMessage, ref bool importSuccessful) { string expectedMessage = $"{errorMessage}" +