Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Service.Test/DuneLocationCalculationServiceTest.cs =================================================================== diff -u -raac77dabbe6b2ef98dcd61bd84fc5f3efd06bded -rdd347e5ef5916532cce1004e1941e8523ec448b4 --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Service.Test/DuneLocationCalculationServiceTest.cs (.../DuneLocationCalculationServiceTest.cs) (revision aac77dabbe6b2ef98dcd61bd84fc5f3efd06bded) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Service.Test/DuneLocationCalculationServiceTest.cs (.../DuneLocationCalculationServiceTest.cs) (revision dd347e5ef5916532cce1004e1941e8523ec448b4) @@ -1,4 +1,4 @@ -// Copyright (C) Stichting Deltares 2017. All rights reserved. +// Copyright (C) Stichting Deltares 2018. All rights reserved. // // This file is part of Ringtoets. // @@ -27,24 +27,27 @@ using Core.Common.Util; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Service; using Ringtoets.Common.Service.MessageProviders; using Ringtoets.Common.Service.TestUtil; using Ringtoets.DuneErosion.Data; using Ringtoets.DuneErosion.Data.TestUtil; -using Ringtoets.HydraRing.Calculation.Calculator.Factory; -using Ringtoets.HydraRing.Calculation.Data.Input.Hydraulics; -using Ringtoets.HydraRing.Calculation.Exceptions; using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; +using Riskeer.HydraRing.Calculation.Calculator.Factory; +using Riskeer.HydraRing.Calculation.Data.Input; +using Riskeer.HydraRing.Calculation.Data.Input.Hydraulics; +using Riskeer.HydraRing.Calculation.Exceptions; namespace Ringtoets.DuneErosion.Service.Test { [TestFixture] public class DuneLocationCalculationServiceTest { private static readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); - private static readonly string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); + private static readonly string validHydraulicBoundaryDatabaseFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); + private static readonly string validHlcdFilePath = Path.Combine(testDataPath, "hlcd.sqlite"); private static readonly string validPreprocessorDirectory = TestHelper.GetScratchPadPath(); [Test] @@ -68,8 +71,7 @@ // Call TestDelegate test = () => new DuneLocationCalculationService().Calculate(null, 1, - validFilePath, - validPreprocessorDirectory, + CreateCalculationSettings(), calculationMessageProvider); // Assert @@ -85,8 +87,7 @@ // Call TestDelegate test = () => new DuneLocationCalculationService().Calculate(new DuneLocationCalculation(new TestDuneLocation()), 1, - validFilePath, - validPreprocessorDirectory, + CreateCalculationSettings(), null); // Assert @@ -95,6 +96,27 @@ } [Test] + public void Calculate_CalculationSettingsNull_ThrowsArgumentNullException() + { + // Setup + var mockRepository = new MockRepository(); + var calculationMessageProvider = mockRepository.Stub(); + mockRepository.ReplayAll(); + + // Call + TestDelegate call = () => new DuneLocationCalculationService().Calculate(new DuneLocationCalculation(new TestDuneLocation()), + 1, + null, + calculationMessageProvider); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("calculationSettings", exception.ParamName); + + mockRepository.VerifyAll(); + } + + [Test] [TestCase(true)] [TestCase(false)] public void Calculate_ValidData_CalculationStartedWithRightParameters(bool usePreprocessor) @@ -104,6 +126,9 @@ string preprocessorDirectory = usePreprocessor ? validPreprocessorDirectory : string.Empty; + var calculationSettings = new HydraulicBoundaryCalculationSettings(validHydraulicBoundaryDatabaseFilePath, + validHlcdFilePath, + preprocessorDirectory); var calculator = new TestDunesBoundaryConditionsCalculator { @@ -112,7 +137,12 @@ var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock(); - calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(testDataPath, preprocessorDirectory)) + calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(Arg.Is.NotNull)) + .WhenCalled(invocation => + { + HydraRingCalculationSettingsTestHelper.AssertHydraRingCalculationSettings( + calculationSettings, (HydraRingCalculationSettings) invocation.Arguments[0]); + }) .Return(calculator); var calculationMessageProvider = mockRepository.StrictMock(); mockRepository.ReplayAll(); @@ -131,8 +161,7 @@ // Call new DuneLocationCalculationService().Calculate(new DuneLocationCalculation(duneLocation), norm, - validFilePath, - preprocessorDirectory, + calculationSettings, calculationMessageProvider); // Assert @@ -161,7 +190,8 @@ var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock(); - calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(testDataPath, validPreprocessorDirectory)) + calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(null)) + .IgnoreArguments() .Return(calculator); var calculationMessageProvider = mockRepository.StrictMock(); mockRepository.ReplayAll(); @@ -176,8 +206,7 @@ // Call Action test = () => new DuneLocationCalculationService().Calculate(duneLocationCalculation, norm, - validFilePath, - validPreprocessorDirectory, + CreateCalculationSettings(), calculationMessageProvider); // Assert @@ -224,7 +253,8 @@ var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock(); - calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(testDataPath, validPreprocessorDirectory)) + calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(null)) + .IgnoreArguments() .Return(calculator); var calculationMessageProvider = mockRepository.StrictMock(); calculationMessageProvider.Expect(c => c.GetCalculatedNotConvergedMessage(locationName)).Return(failedConvergenceMessage); @@ -238,8 +268,7 @@ // Call Action test = () => new DuneLocationCalculationService().Calculate(duneLocationCalculation, norm, - validFilePath, - validPreprocessorDirectory, + CreateCalculationSettings(), calculationMessageProvider); // Assert @@ -272,7 +301,8 @@ var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock(); - calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(testDataPath, validPreprocessorDirectory)) + calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(null)) + .IgnoreArguments() .Return(calculator); var calculationMessageProvider = mockRepository.StrictMock(); mockRepository.ReplayAll(); @@ -287,8 +317,7 @@ // Call service.Calculate(duneLocationCalculation, norm, - validFilePath, - validPreprocessorDirectory, + CreateCalculationSettings(), calculationMessageProvider); // Assert @@ -315,7 +344,8 @@ var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock(); - calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(testDataPath, validPreprocessorDirectory)) + calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(null)) + .IgnoreArguments() .Return(calculator); var calculationMessageProvider = mockRepository.StrictMock(); calculationMessageProvider.Expect(c => c.GetCalculationFailedWithErrorReportMessage(locationName, errorReport)).Return(errorMessage); @@ -335,8 +365,7 @@ { new DuneLocationCalculationService().Calculate(duneLocationCalculation, norm, - validFilePath, - validPreprocessorDirectory, + CreateCalculationSettings(), calculationMessageProvider); } catch (HydraRingCalculationException) @@ -380,7 +409,8 @@ var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock(); - calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(testDataPath, validPreprocessorDirectory)) + calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(null)) + .IgnoreArguments() .Return(calculator); var calculationMessageProvider = mockRepository.StrictMock(); calculationMessageProvider.Expect(c => c.GetCalculationFailedMessage(locationName)).Return(errorMessage); @@ -400,8 +430,7 @@ { new DuneLocationCalculationService().Calculate(duneLocationCalculation, norm, - validFilePath, - validPreprocessorDirectory, + CreateCalculationSettings(), calculationMessageProvider); } catch (HydraRingCalculationException) @@ -447,7 +476,8 @@ var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock(); - calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(testDataPath, validPreprocessorDirectory)) + calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(null)) + .IgnoreArguments() .Return(calculator); var calculationMessageProvider = mockRepository.StrictMock(); calculationMessageProvider.Expect(c => c.GetCalculationFailedWithErrorReportMessage(locationName, lastErrorFileContent)).Return(errorMessage); @@ -468,8 +498,7 @@ { new DuneLocationCalculationService().Calculate(duneLocationCalculation, norm, - validFilePath, - validPreprocessorDirectory, + CreateCalculationSettings(), calculationMessageProvider); } catch (HydraRingCalculationException e) @@ -500,6 +529,13 @@ mockRepository.VerifyAll(); } + private static HydraulicBoundaryCalculationSettings CreateCalculationSettings() + { + return new HydraulicBoundaryCalculationSettings(validHydraulicBoundaryDatabaseFilePath, + validHlcdFilePath, + string.Empty); + } + private static void AssertInput(DunesBoundaryConditionsCalculationInput expectedInput, DunesBoundaryConditionsCalculationInput actualInput) { Assert.AreEqual(expectedInput.Section.SectionId, actualInput.Section.SectionId);