Index: Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs =================================================================== diff -u -r1b27e514649c647165943d41ddb6bd6be619df77 -r95e5c7c46e45f5c240cd0c9928484f0f4714e147 --- Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs (.../DesignWaterLevelCalculationService.cs) (revision 1b27e514649c647165943d41ddb6bd6be619df77) +++ Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs (.../DesignWaterLevelCalculationService.cs) (revision 95e5c7c46e45f5c240cd0c9928484f0f4714e147) @@ -93,14 +93,16 @@ /// /// Performs a calculation for the design water level. /// - /// The calculation wrapper to use. + /// The hydraulic boundary location the belongs to. + /// The hydraulic boundary location calculation to perform. /// The path which points to the hydraulic boundary database file. /// The preprocessor directory. /// The norm of the assessment section. /// The object which is used to build log messages. /// Preprocessing is disabled when /// equals . - /// Thrown when is null. + /// Thrown when or + /// is null. /// Thrown when /// /// contains invalid characters. @@ -114,17 +116,23 @@ /// Unable to read required data from database file. /// /// Thrown when an error occurs while performing the calculation. - public void Calculate(HydraulicBoundaryCalculationWrapper calculationWrapper, + public void Calculate(HydraulicBoundaryLocation hydraulicBoundaryLocation, + HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation, string hydraulicBoundaryDatabaseFilePath, string preprocessorDirectory, double norm, ICalculationMessageProvider messageProvider) { - if (calculationWrapper == null) + if (hydraulicBoundaryLocation == null) { - throw new ArgumentNullException(nameof(calculationWrapper)); + throw new ArgumentNullException(nameof(hydraulicBoundaryLocation)); } + if (hydraulicBoundaryLocationCalculation == null) + { + throw new ArgumentNullException(nameof(hydraulicBoundaryLocationCalculation)); + } + string hlcdDirectory = Path.GetDirectoryName(hydraulicBoundaryDatabaseFilePath); CalculationServiceHelper.LogCalculationBegin(); @@ -135,7 +143,8 @@ try { - PerformCalculation(calculationWrapper, + PerformCalculation(hydraulicBoundaryLocation, + hydraulicBoundaryLocationCalculation, hydraulicBoundaryDatabaseFilePath, !string.IsNullOrEmpty(preprocessorDirectory), norm, @@ -147,9 +156,8 @@ { string lastErrorContent = calculator.LastErrorFileContent; log.Error(string.IsNullOrEmpty(lastErrorContent) - ? messageProvider.GetCalculationFailedMessage(calculationWrapper.Name) - : messageProvider.GetCalculationFailedWithErrorReportMessage(calculationWrapper.Name, - lastErrorContent)); + ? messageProvider.GetCalculationFailedMessage(hydraulicBoundaryLocation.Name) + : messageProvider.GetCalculationFailedWithErrorReportMessage(hydraulicBoundaryLocation.Name, lastErrorContent)); exceptionThrown = true; throw; @@ -161,8 +169,7 @@ bool errorOccurred = CalculationServiceHelper.HasErrorOccurred(canceled, exceptionThrown, lastErrorFileContent); if (errorOccurred) { - log.Error(messageProvider.GetCalculationFailedWithErrorReportMessage(calculationWrapper.Name, - lastErrorFileContent)); + log.Error(messageProvider.GetCalculationFailedWithErrorReportMessage(hydraulicBoundaryLocation.Name, lastErrorFileContent)); } log.InfoFormat(Resources.DesignWaterLevelCalculationService_Calculate_Calculation_temporary_directory_can_be_found_on_location_0, calculator.OutputDirectory); Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs =================================================================== diff -u -r90f951ec95877a68c026e026ff0573ddf1eae96d -r95e5c7c46e45f5c240cd0c9928484f0f4714e147 --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs (.../DesignWaterLevelCalculationServiceTest.cs) (revision 90f951ec95877a68c026e026ff0573ddf1eae96d) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs (.../DesignWaterLevelCalculationServiceTest.cs) (revision 95e5c7c46e45f5c240cd0c9928484f0f4714e147) @@ -28,6 +28,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.Exceptions; using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Service.MessageProviders; using Ringtoets.Common.Service.TestUtil; using Ringtoets.HydraRing.Calculation.Calculator; @@ -134,22 +135,48 @@ } [Test] - public void Calculate_CalculationWrapperNull_ThrowArgumentNullException() + public void Calculate_HydraulicBoundaryLocationNull_ThrowArgumentNullException() { // Setup var mockRepository = new MockRepository(); var calculationMessageProvider = mockRepository.Stub(); mockRepository.ReplayAll(); // Call - TestDelegate test = () => new DesignWaterLevelCalculationService().Calculate(null, string.Empty, string.Empty, 1, calculationMessageProvider); + TestDelegate test = () => new DesignWaterLevelCalculationService().Calculate(null, + new HydraulicBoundaryLocationCalculation(), + string.Empty, + string.Empty, + 1, + calculationMessageProvider); // Assert var exception = Assert.Throws(test); - Assert.AreEqual("calculationWrapper", exception.ParamName); + Assert.AreEqual("hydraulicBoundaryLocation", exception.ParamName); } [Test] + public void Calculate_HydraulicBoundaryLocationCalculationNull_ThrowArgumentNullException() + { + // Setup + var mockRepository = new MockRepository(); + var calculationMessageProvider = mockRepository.Stub(); + mockRepository.ReplayAll(); + + // Call + TestDelegate test = () => new DesignWaterLevelCalculationService().Calculate(new TestHydraulicBoundaryLocation(), + null, + string.Empty, + string.Empty, + 1, + calculationMessageProvider); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("hydraulicBoundaryLocationCalculation", exception.ParamName); + } + + [Test] [TestCase(true)] [TestCase(false)] public void Calculate_ValidDesignWaterLevelCalculationAndConverges_StartsCalculationWithRightParametersAndLogs(bool readIllustrationPoints) @@ -180,7 +207,8 @@ using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call - Action call = () => new DesignWaterLevelCalculationService().Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation), + Action call = () => new DesignWaterLevelCalculationService().Calculate(location, + calculation, validFilePath, validPreprocessorDirectory, 1.0 / 30, @@ -235,7 +263,8 @@ using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call - new DesignWaterLevelCalculationService().Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation), + new DesignWaterLevelCalculationService().Calculate(location, + calculation, validFilePath, preprocessorDirectory, 1.0 / 30, @@ -282,7 +311,8 @@ using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call - Action call = () => new DesignWaterLevelCalculationService().Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation), + Action call = () => new DesignWaterLevelCalculationService().Calculate(location, + calculation, validFilePath, validPreprocessorDirectory, norm, @@ -338,7 +368,8 @@ using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call - Action call = () => new DesignWaterLevelCalculationService().Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation), + Action call = () => new DesignWaterLevelCalculationService().Calculate(location, + calculation, validFilePath, validPreprocessorDirectory, 1.0 / 30, @@ -395,7 +426,8 @@ using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call - Action call = () => new DesignWaterLevelCalculationService().Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation), + Action call = () => new DesignWaterLevelCalculationService().Calculate(location, + calculation, validFilePath, validPreprocessorDirectory, 1.0 / 30, @@ -449,12 +481,12 @@ using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call - TestDelegate call = () => new DesignWaterLevelCalculationService() - .Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation), - validFilePath, - validPreprocessorDirectory, - 1.0 / 30, - calculationMessageProvider); + TestDelegate call = () => new DesignWaterLevelCalculationService().Calculate(location, + calculation, + validFilePath, + validPreprocessorDirectory, + 1.0 / 30, + calculationMessageProvider); // Assert var thrownException = Assert.Throws(call); @@ -493,12 +525,12 @@ using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call - Action call = () => new DesignWaterLevelCalculationService() - .Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation), - validFilePath, - validPreprocessorDirectory, - 1.0 / 30, - calculationMessageProvider); + Action call = () => new DesignWaterLevelCalculationService().Calculate(location, + calculation, + validFilePath, + validPreprocessorDirectory, + 1.0 / 30, + calculationMessageProvider); // Assert TestHelper.AssertLogMessages(call, messages => @@ -539,12 +571,12 @@ using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { // Call - Action call = () => new DesignWaterLevelCalculationService() - .Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation), - validFilePath, - validPreprocessorDirectory, - 1.0 / 30, - calculationMessageProvider); + Action call = () => new DesignWaterLevelCalculationService().Calculate(location, + calculation, + validFilePath, + validPreprocessorDirectory, + 1.0 / 30, + calculationMessageProvider); // Assert TestHelper.AssertLogMessages(call, messages => @@ -584,7 +616,8 @@ calculator.CalculationFinishedHandler += (s, e) => service.Cancel(); // Call - service.Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation), + service.Calculate(location, + calculation, validFilePath, validPreprocessorDirectory, norm, @@ -645,7 +678,8 @@ { try { - new DesignWaterLevelCalculationService().Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation), + new DesignWaterLevelCalculationService().Calculate(location, + calculation, validFilePath, validPreprocessorDirectory, norm,