Index: Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationService.cs
===================================================================
diff -u -r1ba24804e524f95f26c795226aa7d9a4c33a2424 -r7dce1ceb498815baa3486f459710c77327d4ef10
--- Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationService.cs (.../WaveHeightCalculationService.cs) (revision 1ba24804e524f95f26c795226aa7d9a4c33a2424)
+++ Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationService.cs (.../WaveHeightCalculationService.cs) (revision 7dce1ceb498815baa3486f459710c77327d4ef10)
@@ -94,13 +94,15 @@
///
/// Performs a calculation for wave height.
///
- /// 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.WaveHeightCalculationService_Calculate_Calculation_temporary_directory_can_be_found_on_location_0, calculator.OutputDirectory);
Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationServiceTest.cs
===================================================================
diff -u -r639ed2d13b89000c99295422e20162320a1456cb -r7dce1ceb498815baa3486f459710c77327d4ef10
--- Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationServiceTest.cs (.../WaveHeightCalculationServiceTest.cs) (revision 639ed2d13b89000c99295422e20162320a1456cb)
+++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationServiceTest.cs (.../WaveHeightCalculationServiceTest.cs) (revision 7dce1ceb498815baa3486f459710c77327d4ef10)
@@ -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 WaveHeightCalculationService().Calculate(null, testDataPath, validPreprocessorDirectory, 1, calculationMessageProvider);
+ TestDelegate test = () => new WaveHeightCalculationService().Calculate(null,
+ new HydraulicBoundaryLocationCalculation(),
+ testDataPath,
+ validPreprocessorDirectory,
+ 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 WaveHeightCalculationService().Calculate(new TestHydraulicBoundaryLocation(),
+ null,
+ testDataPath,
+ validPreprocessorDirectory,
+ 1,
+ calculationMessageProvider);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("hydraulicBoundaryLocationCalculation", exception.ParamName);
+ }
+
+ [Test]
[TestCase(true)]
[TestCase(false)]
public void Calculate_ValidWaveHeightCalculationAndConverges_StartsCalculationWithRightParametersAndLogs(bool readIllustrationPoints)
@@ -181,7 +208,8 @@
using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
{
- Action call = () => new WaveHeightCalculationService().Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation),
+ Action call = () => new WaveHeightCalculationService().Calculate(location,
+ calculation,
validFilePath,
validPreprocessorDirectory,
norm,
@@ -237,7 +265,8 @@
using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
{
// Call
- new WaveHeightCalculationService().Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation),
+ new WaveHeightCalculationService().Calculate(location,
+ calculation,
validFilePath,
preprocessorDirectory,
1.0 / 30,
@@ -282,7 +311,8 @@
using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
{
- Action call = () => new WaveHeightCalculationService().Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation),
+ Action call = () => new WaveHeightCalculationService().Calculate(location,
+ calculation,
validFilePath,
validPreprocessorDirectory,
1.0 / 30,
@@ -336,7 +366,8 @@
using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
{
// Call
- Action call = () => new WaveHeightCalculationService().Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation),
+ Action call = () => new WaveHeightCalculationService().Calculate(location,
+ calculation,
validFilePath,
validPreprocessorDirectory,
1.0 / 30,
@@ -394,7 +425,8 @@
using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
{
// Call
- Action call = () => new WaveHeightCalculationService().Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation),
+ Action call = () => new WaveHeightCalculationService().Calculate(location,
+ calculation,
validFilePath,
validPreprocessorDirectory,
1.0 / 30,
@@ -449,12 +481,12 @@
using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
{
// Call
- TestDelegate call = () => new WaveHeightCalculationService()
- .Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation),
- validFilePath,
- validPreprocessorDirectory,
- 1.0 / 30,
- calculationMessageProvider);
+ TestDelegate call = () => new WaveHeightCalculationService().Calculate(location,
+ calculation,
+ validFilePath,
+ validPreprocessorDirectory,
+ 1.0 / 30,
+ calculationMessageProvider);
// Assert
var thrownException = Assert.Throws(call);
@@ -494,12 +526,12 @@
using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
{
// Call
- Action call = () => new WaveHeightCalculationService()
- .Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation),
- validFilePath,
- validPreprocessorDirectory,
- 1.0 / 30,
- calculationMessageProvider);
+ Action call = () => new WaveHeightCalculationService().Calculate(location,
+ calculation,
+ validFilePath,
+ validPreprocessorDirectory,
+ 1.0 / 30,
+ calculationMessageProvider);
// Assert
TestHelper.AssertLogMessages(call, messages =>
@@ -541,12 +573,12 @@
using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
{
// Call
- Action call = () => new WaveHeightCalculationService()
- .Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation),
- validFilePath,
- validPreprocessorDirectory,
- 1.0 / 30,
- calculationMessageProvider);
+ Action call = () => new WaveHeightCalculationService().Calculate(location,
+ calculation,
+ validFilePath,
+ validPreprocessorDirectory,
+ 1.0 / 30,
+ calculationMessageProvider);
// Assert
TestHelper.AssertLogMessages(call, messages =>
@@ -587,7 +619,8 @@
calculator.CalculationFinishedHandler += (s, e) => service.Cancel();
// Call
- service.Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation),
+ service.Calculate(location,
+ calculation,
validFilePath,
validPreprocessorDirectory,
norm,
@@ -650,7 +683,8 @@
{
try
{
- new WaveHeightCalculationService().Calculate(new HydraulicBoundaryCalculationWrapper(location, calculation),
+ new WaveHeightCalculationService().Calculate(location,
+ calculation,
validFilePath,
validPreprocessorDirectory,
norm,