Index: Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationActivity.cs
===================================================================
diff -u -r2a81f01756e227d5ce93717b21b87e8a5cd5fcbb -r51e4c5dc8ba6f7fe7f923418fa4af2d2c2f46196
--- Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationActivity.cs (.../DesignWaterLevelCalculationActivity.cs) (revision 2a81f01756e227d5ce93717b21b87e8a5cd5fcbb)
+++ Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationActivity.cs (.../DesignWaterLevelCalculationActivity.cs) (revision 51e4c5dc8ba6f7fe7f923418fa4af2d2c2f46196)
@@ -77,8 +77,7 @@
protected override void PerformCalculation()
{
calculationService.Calculate(hydraulicBoundaryLocationCalculation,
- hydraulicBoundaryDatabaseFilePath,
- preprocessorDirectory,
+ new HydraulicBoundaryCalculationSettings(string.Empty, string.Empty, string.Empty),
norm,
messageProvider);
}
Index: Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs
===================================================================
diff -u -r9221d5b4bed48e979f493dd290255bb4285f112f -r51e4c5dc8ba6f7fe7f923418fa4af2d2c2f46196
--- Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs (.../DesignWaterLevelCalculationService.cs) (revision 9221d5b4bed48e979f493dd290255bb4285f112f)
+++ Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs (.../DesignWaterLevelCalculationService.cs) (revision 51e4c5dc8ba6f7fe7f923418fa4af2d2c2f46196)
@@ -51,30 +51,28 @@
/// Performs a calculation for the design water level.
///
/// The hydraulic boundary location calculation to perform.
- /// The path which points to the hydraulic boundary database file.
- /// The preprocessor directory.
/// The norm to use during the calculation.
+ /// The containing all data
+ /// to perform a hydraulic boundary calculation.
/// The object which is used to build log messages.
- /// Preprocessing is disabled when
- /// equals .
- /// Thrown when or
- /// is null.
+ /// Preprocessing is disabled when the preprocessor directory equals .
+ /// Thrown when ,
+ /// or is null.
/// Thrown when
///
- /// - contains invalid characters.
+ /// - the hydraulic boundary database file path contains invalid characters.
/// - The target probability or the calculated probability falls outside the [0.0, 1.0] range and is not .
///
/// Thrown when:
///
- /// - No settings database file could be found at the location of
+ ///
- No settings database file could be found at the location of hydraulic boundary database file path.
/// with the same name.
/// - Unable to open settings database file.
/// - Unable to read required data from database file.
///
/// Thrown when an error occurs while performing the calculation.
public void Calculate(HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation,
- string hydraulicBoundaryDatabaseFilePath,
- string preprocessorDirectory,
+ HydraulicBoundaryCalculationSettings calculationSettings,
double norm,
ICalculationMessageProvider messageProvider)
{
@@ -83,6 +81,11 @@
throw new ArgumentNullException(nameof(hydraulicBoundaryLocationCalculation));
}
+ if (calculationSettings == null)
+ {
+ throw new ArgumentNullException(nameof(calculationSettings));
+ }
+
if (messageProvider == null)
{
throw new ArgumentNullException(nameof(messageProvider));
@@ -92,16 +95,15 @@
CalculationServiceHelper.LogCalculationBegin();
- var settings = new HydraRingCalculationSettings(hydraulicBoundaryDatabaseFilePath, preprocessorDirectory);
- calculator = HydraRingCalculatorFactory.Instance.CreateDesignWaterLevelCalculator(settings);
+ HydraRingCalculationSettings hydraRingCalculationSettings = HydraRingCalculationSettingsFactory.CreateSettings(calculationSettings);
+ calculator = HydraRingCalculatorFactory.Instance.CreateDesignWaterLevelCalculator(hydraRingCalculationSettings);
var exceptionThrown = false;
try
{
PerformCalculation(hydraulicBoundaryLocationCalculation,
- hydraulicBoundaryDatabaseFilePath,
- !string.IsNullOrEmpty(preprocessorDirectory),
+ calculationSettings,
norm,
messageProvider);
}
@@ -150,27 +152,26 @@
/// Performs a calculation for the design water level.
///
/// The hydraulic boundary location calculation to perform.
- /// The path which points to the hydraulic boundary database file.
- /// Indicator whether to use the preprocessor in the calculation.
+ /// The containing all data
+ /// to perform a hydraulic boundary calculation.
/// The norm of the assessment section.
/// The object which is used to build log messages.
/// Thrown when:
///
- /// - No settings database file could be found at the location of
+ ///
- No settings database file could be found at the location of the hydraulic boundary database file path
/// with the same name.
/// - Unable to open settings database file.
/// - Unable to read required data from database file.
///
/// Thrown when an error occurs while performing the calculation.
private void PerformCalculation(HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation,
- string hydraulicBoundaryDatabaseFilePath,
- bool usePreprocessor,
+ HydraulicBoundaryCalculationSettings calculationSettings,
double norm,
ICalculationMessageProvider messageProvider)
{
HydraulicBoundaryLocation hydraulicBoundaryLocation = hydraulicBoundaryLocationCalculation.HydraulicBoundaryLocation;
- AssessmentLevelCalculationInput calculationInput = CreateInput(hydraulicBoundaryLocation.Id, norm, hydraulicBoundaryDatabaseFilePath, usePreprocessor);
+ AssessmentLevelCalculationInput calculationInput = CreateInput(hydraulicBoundaryLocation.Id, norm, calculationSettings);
calculator.Calculate(calculationInput);
@@ -266,28 +267,27 @@
///
/// The id of the hydraulic boundary location.
/// The norm to use during the calculation.
- /// The file path to the hydraulic
- /// boundary database.
- /// Indicator whether to use the preprocessor in the calculation.
+ ///
/// An .
- /// Thrown when the
+ /// Thrown when the hydraulic boundary database file path
/// contains invalid characters.
/// Thrown when:
///
- /// - No settings database file could be found at the location of
+ ///
- No settings database file could be found at the location of the hydraulic boundary database file path.
/// with the same name.
/// - Unable to open settings database file.
/// - Unable to read required data from database file.
///
///
private static AssessmentLevelCalculationInput CreateInput(long hydraulicBoundaryLocationId,
double norm,
- string hydraulicBoundaryDatabaseFilePath,
- bool usePreprocessor)
+ HydraulicBoundaryCalculationSettings calculationSettings)
{
var assessmentLevelCalculationInput = new AssessmentLevelCalculationInput(1, hydraulicBoundaryLocationId, norm);
- HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(assessmentLevelCalculationInput, hydraulicBoundaryDatabaseFilePath, usePreprocessor);
+ HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(assessmentLevelCalculationInput,
+ calculationSettings.HydraulicBoundaryDatabaseFilePath,
+ !string.IsNullOrEmpty(calculationSettings.PreprocessorDirectory));
return assessmentLevelCalculationInput;
}
Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs
===================================================================
diff -u -r2c4404936f53178d527072729e7af7f41fc9fe71 -r51e4c5dc8ba6f7fe7f923418fa4af2d2c2f46196
--- Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs (.../DesignWaterLevelCalculationServiceTest.cs) (revision 2c4404936f53178d527072729e7af7f41fc9fe71)
+++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs (.../DesignWaterLevelCalculationServiceTest.cs) (revision 51e4c5dc8ba6f7fe7f923418fa4af2d2c2f46196)
@@ -45,7 +45,8 @@
public class DesignWaterLevelCalculationServiceTest
{
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 +69,7 @@
// Call
TestDelegate test = () => new DesignWaterLevelCalculationService().Calculate(null,
- string.Empty,
- string.Empty,
+ HydraulicBoundaryCalculationSettingsTestFactory.CreateSettings(),
1,
calculationMessageProvider);
@@ -80,12 +80,31 @@
}
[Test]
+ public void Calculate_CalculationSettingsNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var calculationMessageProvider = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new DesignWaterLevelCalculationService().Calculate(new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()),
+ null,
+ 1,
+ calculationMessageProvider);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("calculationSettings", exception.ParamName);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
public void Calculate_MessageProviderNull_ThrowArgumentNullException()
{
// Call
TestDelegate test = () => new DesignWaterLevelCalculationService().Calculate(new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()),
- string.Empty,
- string.Empty,
+ HydraulicBoundaryCalculationSettingsTestFactory.CreateSettings(),
1,
null);
@@ -97,65 +116,54 @@
[Test]
[TestCase(true)]
[TestCase(false)]
- public void Calculate_ValidDesignWaterLevelCalculationAndConverges_StartsCalculationWithRightParametersAndLogs(bool readIllustrationPoints)
+ public void Calculate_ValidData_StartsCalculationWithRightParameters(bool usePreprocessor)
{
// Setup
const double norm = 1.0 / 30;
+ string preprocessorDirectory = usePreprocessor
+ ? validPreprocessorDirectory
+ : string.Empty;
var calculator = new TestDesignWaterLevelCalculator
{
- IllustrationPointsResult = new TestGeneralResult(),
Converged = true
};
+ var calculationSettings = new HydraulicBoundaryCalculationSettings(validHydraulicBoundaryDatabaseFilePath,
+ validHlcdFilePath,
+ preprocessorDirectory);
+
var mockRepository = new MockRepository();
var calculatorFactory = mockRepository.StrictMock();
calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(Arg.Is.NotNull))
.WhenCalled(invocation =>
{
- var settings = (HydraRingCalculationSettings)invocation.Arguments[0];
- Assert.AreEqual(validFilePath, settings.HlcdFilePath);
- Assert.AreEqual(validPreprocessorDirectory, settings.PreprocessorDirectory);
+ var hydraRingCalculationSettings = (HydraRingCalculationSettings) invocation.Arguments[0];
+ HydraRingCalculationSettingsTestHelper.AssertHydraRingCalculationSettings(calculationSettings,
+ hydraRingCalculationSettings);
})
.Return(calculator);
var calculationMessageProvider = mockRepository.StrictMock();
mockRepository.ReplayAll();
var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
- var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)
- {
- InputParameters =
- {
- ShouldIllustrationPointsBeCalculated = readIllustrationPoints
- }
- };
+ var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation);
using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
{
// Call
- Action call = () => new DesignWaterLevelCalculationService().Calculate(hydraulicBoundaryLocationCalculation,
- validFilePath,
- validPreprocessorDirectory,
- norm,
- calculationMessageProvider);
+ new DesignWaterLevelCalculationService().Calculate(hydraulicBoundaryLocationCalculation,
+ calculationSettings,
+ norm,
+ calculationMessageProvider);
// Assert
- TestHelper.AssertLogMessages(call, messages =>
- {
- string[] msgs = messages.ToArray();
- Assert.AreEqual(3, msgs.Length);
- CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]);
- Assert.AreEqual($"Waterstand berekening is uitgevoerd op de tijdelijke locatie '{calculator.OutputDirectory}'. " +
- "Gedetailleerde invoer en uitvoer kan in de bestanden op deze locatie worden gevonden.", msgs[1]);
- CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[2]);
- });
-
AssessmentLevelCalculationInput expectedInput = CreateInput(hydraulicBoundaryLocation.Id, norm);
- AssertInput(expectedInput, calculator.ReceivedInputs.Single());
+ AssessmentLevelCalculationInput actualInput = calculator.ReceivedInputs.Single();
+ AssertInput(expectedInput, actualInput);
Assert.IsFalse(calculator.IsCanceled);
-
- Assert.AreEqual(readIllustrationPoints, hydraulicBoundaryLocationCalculation.Output.HasGeneralResult);
+ Assert.AreEqual(usePreprocessor, actualInput.PreprocessorSetting.RunPreprocessor);
}
mockRepository.VerifyAll();
@@ -164,13 +172,9 @@
[Test]
[TestCase(true)]
[TestCase(false)]
- public void Calculate_ValidDesignWaterLevelCalculationWithPreprocessorDirectory_StartsCalculationWithRightParameters(bool usePreprocessor)
+ public void Calculate_ValidDesignWaterLevelCalculationAndConverges_SetsOutputAndLogs(bool readIllustrationPoints)
{
// Setup
- string preprocessorDirectory = usePreprocessor
- ? validPreprocessorDirectory
- : string.Empty;
-
var calculator = new TestDesignWaterLevelCalculator
{
IllustrationPointsResult = new TestGeneralResult(),
@@ -179,31 +183,45 @@
var mockRepository = new MockRepository();
var calculatorFactory = mockRepository.StrictMock();
- calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(Arg.Is.NotNull))
- .WhenCalled(invocation =>
- {
- var settings = (HydraRingCalculationSettings)invocation.Arguments[0];
- Assert.AreEqual(validFilePath, settings.HlcdFilePath);
- Assert.AreEqual(preprocessorDirectory, settings.PreprocessorDirectory);
- })
+ calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(null))
+ .IgnoreArguments()
.Return(calculator);
var calculationMessageProvider = mockRepository.StrictMock();
mockRepository.ReplayAll();
- var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation());
+ var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
+ var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)
+ {
+ InputParameters =
+ {
+ ShouldIllustrationPointsBeCalculated = readIllustrationPoints
+ }
+ };
using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
{
// Call
- new DesignWaterLevelCalculationService().Calculate(hydraulicBoundaryLocationCalculation,
- validFilePath,
- preprocessorDirectory,
- 1.0 / 30,
- calculationMessageProvider);
+ Action call = () => new DesignWaterLevelCalculationService().Calculate(hydraulicBoundaryLocationCalculation,
+ CreateCalculationSettings(),
+ 1.0 / 30,
+ calculationMessageProvider);
// Assert
- Assert.AreEqual(usePreprocessor, calculator.ReceivedInputs.Single().PreprocessorSetting.RunPreprocessor);
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ string[] msgs = messages.ToArray();
+ Assert.AreEqual(3, msgs.Length);
+ CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]);
+ Assert.AreEqual($"Waterstand berekening is uitgevoerd op de tijdelijke locatie '{calculator.OutputDirectory}'. " +
+ "Gedetailleerde invoer en uitvoer kan in de bestanden op deze locatie worden gevonden.", msgs[1]);
+ CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[2]);
+ });
+
+ Assert.IsFalse(calculator.IsCanceled);
+ HydraulicBoundaryLocationCalculationOutput actualOutput = hydraulicBoundaryLocationCalculation.Output;
+ Assert.IsNotNull(actualOutput);
+ Assert.AreEqual(readIllustrationPoints, actualOutput.HasGeneralResult);
}
mockRepository.VerifyAll();
@@ -215,7 +233,6 @@
public void Calculate_ValidDesignWaterLevelCalculationAndDoesNotConverge_SetsOutputAndLogs(bool readIllustrationPoints)
{
// Setup
- const double norm = 1.0 / 30;
const string locationName = "locationName";
const string failedConvergenceMessage = "failedConvergenceMessage";
@@ -227,13 +244,8 @@
var mockRepository = new MockRepository();
var calculatorFactory = mockRepository.StrictMock();
- calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(Arg.Is.NotNull))
- .WhenCalled(invocation =>
- {
- var settings = (HydraRingCalculationSettings)invocation.Arguments[0];
- Assert.AreEqual(validFilePath, settings.HlcdFilePath);
- Assert.AreEqual(validPreprocessorDirectory, settings.PreprocessorDirectory);
- })
+ calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(null))
+ .IgnoreArguments()
.Return(calculator);
var calculationMessageProvider = mockRepository.StrictMock();
@@ -253,9 +265,8 @@
{
// Call
Action call = () => new DesignWaterLevelCalculationService().Calculate(hydraulicBoundaryLocationCalculation,
- validFilePath,
- validPreprocessorDirectory,
- norm,
+ CreateCalculationSettings(),
+ 1.0 / 30,
calculationMessageProvider);
// Assert
@@ -270,11 +281,10 @@
CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[3]);
});
- AssessmentLevelCalculationInput expectedInput = CreateInput(hydraulicBoundaryLocation.Id, norm);
- AssertInput(expectedInput, calculator.ReceivedInputs.Single());
Assert.IsFalse(calculator.IsCanceled);
- Assert.IsNotNull(hydraulicBoundaryLocationCalculation.Output);
- Assert.AreEqual(readIllustrationPoints, hydraulicBoundaryLocationCalculation.Output.HasGeneralResult);
+ HydraulicBoundaryLocationCalculationOutput actualOutput = hydraulicBoundaryLocationCalculation.Output;
+ Assert.IsNotNull(actualOutput);
+ Assert.AreEqual(readIllustrationPoints, actualOutput.HasGeneralResult);
}
mockRepository.VerifyAll();
@@ -292,13 +302,8 @@
var mockRepository = new MockRepository();
var calculatorFactory = mockRepository.StrictMock();
- calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(Arg.Is.NotNull))
- .WhenCalled(invocation =>
- {
- var settings = (HydraRingCalculationSettings)invocation.Arguments[0];
- Assert.AreEqual(validFilePath, settings.HlcdFilePath);
- Assert.AreEqual(validPreprocessorDirectory, settings.PreprocessorDirectory);
- })
+ calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(null))
+ .IgnoreArguments()
.Return(calculator);
var calculationMessageProvider = mockRepository.StrictMock();
@@ -316,8 +321,7 @@
{
// Call
Action call = () => new DesignWaterLevelCalculationService().Calculate(hydraulicBoundaryLocationCalculation,
- validFilePath,
- validPreprocessorDirectory,
+ CreateCalculationSettings(),
1.0 / 30,
calculationMessageProvider);
@@ -358,13 +362,8 @@
var mockRepository = new MockRepository();
var calculatorFactory = mockRepository.StrictMock();
- calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(Arg.Is.NotNull))
- .WhenCalled(invocation =>
- {
- var settings = (HydraRingCalculationSettings)invocation.Arguments[0];
- Assert.AreEqual(validFilePath, settings.HlcdFilePath);
- Assert.AreEqual(validPreprocessorDirectory, settings.PreprocessorDirectory);
- })
+ calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(null))
+ .IgnoreArguments()
.Return(calculator);
var calculationMessageProvider = mockRepository.StrictMock();
@@ -382,8 +381,7 @@
{
// Call
Action call = () => new DesignWaterLevelCalculationService().Calculate(hydraulicBoundaryLocationCalculation,
- validFilePath,
- validPreprocessorDirectory,
+ CreateCalculationSettings(),
1.0 / 30,
calculationMessageProvider);
@@ -426,13 +424,8 @@
calculator.Stub(c => c.OutputDirectory).Return(string.Empty);
var calculatorFactory = mockRepository.StrictMock();
- calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(Arg.Is.NotNull))
- .WhenCalled(invocation =>
- {
- var settings = (HydraRingCalculationSettings)invocation.Arguments[0];
- Assert.AreEqual(validFilePath, settings.HlcdFilePath);
- Assert.AreEqual(validPreprocessorDirectory, settings.PreprocessorDirectory);
- })
+ calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(null))
+ .IgnoreArguments()
.Return(calculator);
var calculationMessageProvider = mockRepository.Stub();
@@ -445,8 +438,7 @@
{
// Call
TestDelegate call = () => new DesignWaterLevelCalculationService().Calculate(hydraulicBoundaryLocationCalculation,
- validFilePath,
- validPreprocessorDirectory,
+ CreateCalculationSettings(),
1.0 / 30,
calculationMessageProvider);
@@ -471,13 +463,8 @@
};
var calculatorFactory = mockRepository.StrictMock();
- calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(Arg.Is.NotNull))
- .WhenCalled(invocation =>
- {
- var settings = (HydraRingCalculationSettings)invocation.Arguments[0];
- Assert.AreEqual(validFilePath, settings.HlcdFilePath);
- Assert.AreEqual(validPreprocessorDirectory, settings.PreprocessorDirectory);
- })
+ calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(null))
+ .IgnoreArguments()
.Return(calculator);
var calculationMessageProvider = mockRepository.Stub();
@@ -495,8 +482,7 @@
{
// Call
Action call = () => new DesignWaterLevelCalculationService().Calculate(hydraulicBoundaryLocationCalculation,
- validFilePath,
- validPreprocessorDirectory,
+ CreateCalculationSettings(),
1.0 / 30,
calculationMessageProvider);
@@ -529,13 +515,8 @@
};
var calculatorFactory = mockRepository.StrictMock();
- calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(Arg.Is.NotNull))
- .WhenCalled(invocation =>
- {
- var settings = (HydraRingCalculationSettings)invocation.Arguments[0];
- Assert.AreEqual(validFilePath, settings.HlcdFilePath);
- Assert.AreEqual(validPreprocessorDirectory, settings.PreprocessorDirectory);
- })
+ calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(null))
+ .IgnoreArguments()
.Return(calculator);
var calculationMessageProvider = mockRepository.Stub();
@@ -547,8 +528,7 @@
{
// Call
Action call = () => new DesignWaterLevelCalculationService().Calculate(hydraulicBoundaryLocationCalculation,
- validFilePath,
- validPreprocessorDirectory,
+ CreateCalculationSettings(),
1.0 / 30,
calculationMessageProvider);
@@ -575,13 +555,8 @@
var mockRepository = new MockRepository();
var calculatorFactory = mockRepository.StrictMock();
- calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(Arg.Is.NotNull))
- .WhenCalled(invocation =>
- {
- var settings = (HydraRingCalculationSettings)invocation.Arguments[0];
- Assert.AreEqual(validFilePath, settings.HlcdFilePath);
- Assert.AreEqual(validPreprocessorDirectory, settings.PreprocessorDirectory);
- })
+ calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(null))
+ .IgnoreArguments()
.Return(calculator);
var calculationMessageProvider = mockRepository.Stub();
@@ -596,8 +571,7 @@
// Call
service.Calculate(hydraulicBoundaryLocationCalculation,
- validFilePath,
- validPreprocessorDirectory,
+ CreateCalculationSettings(),
1.0 / 30,
calculationMessageProvider);
@@ -627,13 +601,8 @@
var mockRepository = new MockRepository();
var calculatorFactory = mockRepository.StrictMock();
- calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(Arg.Is.NotNull))
- .WhenCalled(invocation =>
- {
- var settings = (HydraRingCalculationSettings)invocation.Arguments[0];
- Assert.AreEqual(validFilePath, settings.HlcdFilePath);
- Assert.AreEqual(validPreprocessorDirectory, settings.PreprocessorDirectory);
- })
+ calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(null))
+ .IgnoreArguments()
.Return(calculator);
var calculationMessageProvider = mockRepository.Stub();
@@ -664,8 +633,7 @@
try
{
new DesignWaterLevelCalculationService().Calculate(hydraulicBoundaryLocationCalculation,
- validFilePath,
- validPreprocessorDirectory,
+ CreateCalculationSettings(),
1.0 / 30,
calculationMessageProvider);
}
@@ -693,6 +661,13 @@
mockRepository.VerifyAll();
}
+ private static HydraulicBoundaryCalculationSettings CreateCalculationSettings()
+ {
+ return new HydraulicBoundaryCalculationSettings(validHydraulicBoundaryDatabaseFilePath,
+ validHlcdFilePath,
+ string.Empty);
+ }
+
private static void AssertInput(AssessmentLevelCalculationInput expectedInput, HydraRingCalculationInput hydraRingCalculationInput)
{
Assert.AreEqual(expectedInput.Section.SectionId, hydraRingCalculationInput.Section.SectionId);