Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/ClosingStructuresCalculationService.cs =================================================================== diff -u -r19f983eab8eac43d27e39f6eb9de019bad677652 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/ClosingStructuresCalculationService.cs (.../ClosingStructuresCalculationService.cs) (revision 19f983eab8eac43d27e39f6eb9de019bad677652) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Service/ClosingStructuresCalculationService.cs (.../ClosingStructuresCalculationService.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -41,7 +41,8 @@ protected override StructuresClosureCalculationInput CreateInput(ClosingStructuresInput structureInput, GeneralClosingStructuresInput generalInput, - string hydraulicBoundaryDatabaseFilePath) + string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor) { StructuresClosureCalculationInput input; switch (structureInput.InflowModelType) @@ -61,7 +62,7 @@ typeof(ClosingStructureInflowModelType)); } - HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(input, hydraulicBoundaryDatabaseFilePath); + HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(input, hydraulicBoundaryDatabaseFilePath, usePreprocessor); return input; } Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Service.Test/ClosingStructuresCalculationServiceTest.cs =================================================================== diff -u -rd0532a4358c7ad50722fd19082677e43fcb018d8 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Service.Test/ClosingStructuresCalculationServiceTest.cs (.../ClosingStructuresCalculationServiceTest.cs) (revision d0532a4358c7ad50722fd19082677e43fcb018d8) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Service.Test/ClosingStructuresCalculationServiceTest.cs (.../ClosingStructuresCalculationServiceTest.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -40,6 +40,7 @@ using Ringtoets.HydraRing.Calculation.Calculator.Factory; using Ringtoets.HydraRing.Calculation.Data; using Ringtoets.HydraRing.Calculation.Data.Input.Structures; +using Ringtoets.HydraRing.Calculation.Data.Settings; using Ringtoets.HydraRing.Calculation.Exceptions; using Ringtoets.HydraRing.Calculation.TestUtil; using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; @@ -604,6 +605,56 @@ [Test] [Combinatorial] + public void Calculate_PreprocessorDirectorySet_InputPropertiesCorrectlySentToCalculator([Values(true, false)] bool usePreprocessor) + { + // Setup + string preprocessorDirectory = usePreprocessor + ? validPreprocessorDirectory + : string.Empty; + + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var mockRepository = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, + mockRepository); + var calculator = new TestStructuresCalculator(); + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateStructuresCalculator(testDataPath, preprocessorDirectory)) + .Return(calculator); + mockRepository.ReplayAll(); + + var calculation = new TestClosingStructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001) + } + }; + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + new ClosingStructuresCalculationService().Calculate(calculation, + failureMechanism.GeneralInput, + failureMechanism.GeneralInput.N, + assessmentSection.FailureMechanismContribution.Norm, + failureMechanism.Contribution, + validFilePath, + preprocessorDirectory); + + // Assert + StructuresClosureCalculationInput[] calculationInputs = calculator.ReceivedInputs.ToArray(); + Assert.AreEqual(1, calculationInputs.Length); + + StructuresClosureCalculationInput actualInput = calculationInputs[0]; + Assert.AreEqual(usePreprocessor, actualInput.PreprocessorSetting.RunPreprocessor); + Assert.IsFalse(calculator.IsCanceled); + } + mockRepository.VerifyAll(); + } + + [Test] + [Combinatorial] public void Calculate_ValidCalculation_LogStartAndEndAndReturnOutput( [Values(ClosingStructureInflowModelType.VerticalWall, ClosingStructureInflowModelType.LowSill, ClosingStructureInflowModelType.FloodedCulvert)] ClosingStructureInflowModelType inflowModelType, [Values(CalculationType.NoForeshore, CalculationType.ForeshoreWithoutBreakWater, CalculationType.ForeshoreWithValidBreakWater)] CalculationType calculationType) Index: Ringtoets/Common/src/Ringtoets.Common.IO/HydraRing/PreprocessorSettingsProvider.cs =================================================================== diff -u -r5c7da008585a4d2990d41ad2699f6315c34e18de -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/Common/src/Ringtoets.Common.IO/HydraRing/PreprocessorSettingsProvider.cs (.../PreprocessorSettingsProvider.cs) (revision 5c7da008585a4d2990d41ad2699f6315c34e18de) +++ Ringtoets/Common/src/Ringtoets.Common.IO/HydraRing/PreprocessorSettingsProvider.cs (.../PreprocessorSettingsProvider.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -64,7 +64,7 @@ /// The . /// Thrown when a column that is being read doesn't /// contain expected type. - public PreprocessorSetting GetPreprocessorSetting(long locationId, bool usePreprocessor = false) + public PreprocessorSetting GetPreprocessorSetting(long locationId, bool usePreprocessor) { if (!usePreprocessor || LocationExcluded(locationId)) { Index: Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs =================================================================== diff -u -r1a145f35899a4d48d1cf88d12377671ad3f3ed60 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs (.../DesignWaterLevelCalculationService.cs) (revision 1a145f35899a4d48d1cf88d12377671ad3f3ed60) +++ Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationService.cs (.../DesignWaterLevelCalculationService.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -137,6 +137,7 @@ { PerformCalculation(designWaterLevelCalculation, hydraulicBoundaryDatabaseFilePath, + !string.IsNullOrEmpty(preprocessorDirectory), norm, messageProvider); } @@ -188,6 +189,7 @@ /// /// The design water level calculation to use. /// The path which points to the hydraulic boundary database file. + /// Indicator whether to use the preprocessor in the calculation. /// The norm of the assessment section. /// The object which is used to build log messages. /// Thrown when: @@ -200,10 +202,11 @@ /// Thrown when an error occurs while performing the calculation. private void PerformCalculation(IHydraulicBoundaryWrapperCalculation designWaterLevelCalculation, string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor, double norm, ICalculationMessageProvider messageProvider) { - AssessmentLevelCalculationInput calculationInput = CreateInput(designWaterLevelCalculation, norm, hydraulicBoundaryDatabaseFilePath); + AssessmentLevelCalculationInput calculationInput = CreateInput(designWaterLevelCalculation, norm, hydraulicBoundaryDatabaseFilePath, usePreprocessor); calculator.Calculate(calculationInput); @@ -303,6 +306,7 @@ /// 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 /// contains invalid characters. @@ -316,11 +320,12 @@ /// private static AssessmentLevelCalculationInput CreateInput(IHydraulicBoundaryWrapperCalculation designWaterLevelCalculation, double norm, - string hydraulicBoundaryDatabaseFilePath) + string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor) { var assessmentLevelCalculationInput = new AssessmentLevelCalculationInput(1, designWaterLevelCalculation.Id, norm); - HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(assessmentLevelCalculationInput, hydraulicBoundaryDatabaseFilePath); + HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(assessmentLevelCalculationInput, hydraulicBoundaryDatabaseFilePath, usePreprocessor); return assessmentLevelCalculationInput; } Index: Ringtoets/Common/src/Ringtoets.Common.Service/HydraRingSettingsDatabaseHelper.cs =================================================================== diff -u -rea6fd126ba0e7080e9a2fede4559b7f439e091cd -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/Common/src/Ringtoets.Common.Service/HydraRingSettingsDatabaseHelper.cs (.../HydraRingSettingsDatabaseHelper.cs) (revision ea6fd126ba0e7080e9a2fede4559b7f439e091cd) +++ Ringtoets/Common/src/Ringtoets.Common.Service/HydraRingSettingsDatabaseHelper.cs (.../HydraRingSettingsDatabaseHelper.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -23,9 +23,7 @@ using Core.Common.Base.IO; using Core.Common.Utils; using Ringtoets.Common.IO.HydraRing; -using Ringtoets.HydraRing.Calculation.Data; using Ringtoets.HydraRing.Calculation.Data.Input; -using Ringtoets.HydraRing.Calculation.Data.Settings; namespace Ringtoets.Common.Service { @@ -41,6 +39,7 @@ /// /// The calculation input for which the settings are updated. /// The path to the hydraulic boundary database file. + /// Indicator whether to use the preprocessor in the calculation. /// Thrown when the /// contains invalid characters. /// Thrown when: @@ -51,7 +50,7 @@ /// Unable to read required data from database file. /// /// - public static void AssignSettingsFromDatabase(HydraRingCalculationInput calculationInput, string hydraulicBoundaryDatabaseFilePath) + public static void AssignSettingsFromDatabase(HydraRingCalculationInput calculationInput, string hydraulicBoundaryDatabaseFilePath, bool usePreprocessor) { IOUtils.ValidateFilePath(hydraulicBoundaryDatabaseFilePath); @@ -60,7 +59,7 @@ using (var preprocessorSettingsProvider = new PreprocessorSettingsProvider(settingsDatabaseFileName)) { - calculationInput.PreprocessorSetting = preprocessorSettingsProvider.GetPreprocessorSetting(locationId); + calculationInput.PreprocessorSetting = preprocessorSettingsProvider.GetPreprocessorSetting(locationId, usePreprocessor); } using (var designTablesSettingsProviders = new DesignTablesSettingsProvider(settingsDatabaseFileName)) { Index: Ringtoets/Common/src/Ringtoets.Common.Service/Structures/StructuresCalculationServiceBase.cs =================================================================== diff -u -rd604f4a885198a27cb0546d2e77318c1dc6ab3a1 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/Common/src/Ringtoets.Common.Service/Structures/StructuresCalculationServiceBase.cs (.../StructuresCalculationServiceBase.cs) (revision d604f4a885198a27cb0546d2e77318c1dc6ab3a1) +++ Ringtoets/Common/src/Ringtoets.Common.Service/Structures/StructuresCalculationServiceBase.cs (.../StructuresCalculationServiceBase.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -159,7 +159,7 @@ throw new ArgumentNullException(nameof(generalInput)); } - TCalculationInput input = CreateInput(calculation.InputParameters, generalInput, hydraulicBoundaryDatabaseFilePath); + TCalculationInput input = CreateInput(calculation.InputParameters, generalInput, hydraulicBoundaryDatabaseFilePath, !string.IsNullOrEmpty(preprocessorDirectory)); string hlcdDirectory = Path.GetDirectoryName(hydraulicBoundaryDatabaseFilePath); calculator = HydraRingCalculatorFactory.Instance.CreateStructuresCalculator(hlcdDirectory, preprocessorDirectory); @@ -223,6 +223,7 @@ /// The structure input to create the calculation input for. /// The that is used in the calculation. /// The path to the hydraulic boundary database file. + /// Indicator whether to use the preprocessor in the calculation. /// A . /// Thrown when the /// contains invalid characters. @@ -238,7 +239,8 @@ /// protected abstract TCalculationInput CreateInput(TStructureInput structureInput, TGeneralInput generalInput, - string hydraulicBoundaryDatabaseFilePath); + string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor); /// /// Performs a structures calculation. Index: Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationService.cs =================================================================== diff -u -r9ac0d49079a6cc44ea4d5c348a6628e234adc1d5 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationService.cs (.../WaveHeightCalculationService.cs) (revision 9ac0d49079a6cc44ea4d5c348a6628e234adc1d5) +++ Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationService.cs (.../WaveHeightCalculationService.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -138,6 +138,7 @@ { PerformCalculation(waveHeightCalculation, hydraulicBoundaryDatabaseFilePath, + !string.IsNullOrEmpty(preprocessorDirectory), norm, messageProvider); } @@ -189,6 +190,7 @@ /// /// The wave height calculation to use. /// The path which points to the hydraulic boundary database file. + /// Indicator whether to use the preprocessor in the calculation. /// The norm of the assessment section. /// The object which is used to build log messages. /// Thrown when: @@ -201,10 +203,11 @@ /// Thrown when an error occurs while performing the calculation. private void PerformCalculation(IHydraulicBoundaryWrapperCalculation waveHeightCalculation, string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor, double norm, ICalculationMessageProvider messageProvider) { - WaveHeightCalculationInput calculationInput = CreateInput(waveHeightCalculation, norm, hydraulicBoundaryDatabaseFilePath); + WaveHeightCalculationInput calculationInput = CreateInput(waveHeightCalculation, norm, hydraulicBoundaryDatabaseFilePath, usePreprocessor); calculator.Calculate(calculationInput); @@ -303,6 +306,7 @@ /// The norm to use during the calculation. /// The file path to the hydraulic /// boundary database. + /// Indicator whether to use the preprocessor in the calculation. /// A . /// Thrown when the /// contains invalid characters. @@ -316,11 +320,12 @@ /// private static WaveHeightCalculationInput CreateInput(IHydraulicBoundaryWrapperCalculation waveHeightCalculation, double norm, - string hydraulicBoundaryDatabaseFilePath) + string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor) { var waveHeightCalculationInput = new WaveHeightCalculationInput(1, waveHeightCalculation.Id, norm); - HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(waveHeightCalculationInput, hydraulicBoundaryDatabaseFilePath); + HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(waveHeightCalculationInput, hydraulicBoundaryDatabaseFilePath, usePreprocessor); return waveHeightCalculationInput; } Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/HydraRing/PreprocessorSettingsProviderTest.cs =================================================================== diff -u -r5c7da008585a4d2990d41ad2699f6315c34e18de -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/HydraRing/PreprocessorSettingsProviderTest.cs (.../PreprocessorSettingsProviderTest.cs) (revision 5c7da008585a4d2990d41ad2699f6315c34e18de) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/HydraRing/PreprocessorSettingsProviderTest.cs (.../PreprocessorSettingsProviderTest.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -53,7 +53,7 @@ using (var provider = new PreprocessorSettingsProvider(completeDatabaseDataPath)) { // Call - PreprocessorSetting setting = provider.GetPreprocessorSetting(700131); + PreprocessorSetting setting = provider.GetPreprocessorSetting(700131, false); // Assert Assert.IsNaN(setting.ValueMin); Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/HydraulicBoundaryDatabaseImporter/complete.config.sqlite =================================================================== diff -u -r64eede81657b51fb755944fd3939ceefb839e591 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 Binary files differ Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs =================================================================== diff -u -rfd8f3552c5039e206279010483ad04bfb5b6c619 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs (.../DesignWaterLevelCalculationServiceTest.cs) (revision fd8f3552c5039e206279010483ad04bfb5b6c619) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs (.../DesignWaterLevelCalculationServiceTest.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -205,6 +205,50 @@ [Test] [TestCase(true)] [TestCase(false)] + public void Calculate_ValidDesignWaterLevelCalculationWithPreprocessorDirectory_StartsCalculationWithRightParametersAndLogs(bool usePreprocessor) + { + // Setup + string preprocessorDirectory = usePreprocessor + ? validPreprocessorDirectory + : string.Empty; + + var calculator = new TestDesignWaterLevelCalculator + { + IllustrationPointsResult = new TestGeneralResult(), + Converged = true + }; + + var mockRepository = new MockRepository(); + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath, preprocessorDirectory)).Return(calculator); + + var calculation = mockRepository.Stub(); + calculation.Stub(c => c.Name).Return("punt_flw_ 1"); + calculation.Expect(c => c.Id).Return(100); + calculation.Expect(c => c.CalculateIllustrationPoints).Return(false); + + var calculationMessageProvider = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + new DesignWaterLevelCalculationService().Calculate(calculation, + validFilePath, + preprocessorDirectory, + 1.0 / 30, + calculationMessageProvider); + + // Assert + Assert.AreEqual(usePreprocessor, calculator.ReceivedInputs.Single().PreprocessorSetting.RunPreprocessor); + Assert.IsFalse(calculator.IsCanceled); + } + mockRepository.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] public void Calculate_ValidDesignWaterLevelCalculationAndDoesNotConverge_SetsOutputAndLogs(bool readIllustrationPoints) { // Setup Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/HydraRingSettingsDatabaseHelperTest.cs =================================================================== diff -u -r3b5e1adef92f7ce3cf8d896ec310e9203f0e8d7d -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/HydraRingSettingsDatabaseHelperTest.cs (.../HydraRingSettingsDatabaseHelperTest.cs) (revision 3b5e1adef92f7ce3cf8d896ec310e9203f0e8d7d) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/HydraRingSettingsDatabaseHelperTest.cs (.../HydraRingSettingsDatabaseHelperTest.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -38,7 +38,7 @@ public void AssignSettingsFromDatabase_FileWithInvalidCharacters_ThrowsArgumentException() { // Call - TestDelegate test = () => HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(new TestHydraRingCalculationInput(), ">"); + TestDelegate test = () => HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(new TestHydraRingCalculationInput(), ">", false); // Assert Assert.Throws(test); @@ -48,7 +48,7 @@ public void AssignSettingsFromDatabase_FileWithoutSettingsDatabase_ThrowsCriticalFileReadException() { // Call - TestDelegate test = () => HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(new TestHydraRingCalculationInput(), "NoConfig.sqlite"); + TestDelegate test = () => HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(new TestHydraRingCalculationInput(), "NoConfig.sqlite", false); // Assert Assert.Throws(test); @@ -61,14 +61,30 @@ var input = new TestHydraRingCalculationInput(); // Call - HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(input, Path.Combine(testDataPath, "hrd.sqlite")); + HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(input, Path.Combine(testDataPath, "hrd.sqlite"), false); // Assert Assert.NotNull(input.PreprocessorSetting); Assert.NotNull(input.DesignTablesSetting); Assert.NotNull(input.NumericsSettings); Assert.NotNull(input.TimeIntegrationSetting); } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void AssignSettingsFromDatabase_UsePreprocessor_SettingsAdded(bool usePreprocessor) + { + // Setup + var input = new TestHydraRingCalculationInput(); + + // Call + HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(input, Path.Combine(testDataPath, "hrd.sqlite"), usePreprocessor); + + // Assert + Assert.NotNull(input.PreprocessorSetting); + Assert.AreEqual(usePreprocessor, input.PreprocessorSetting.RunPreprocessor); + } } public class TestHydraRingCalculationInput : HydraRingCalculationInput Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/Structures/StructuresCalculationServiceBaseTest.cs =================================================================== diff -u -rfd8f3552c5039e206279010483ad04bfb5b6c619 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/Structures/StructuresCalculationServiceBaseTest.cs (.../StructuresCalculationServiceBaseTest.cs) (revision fd8f3552c5039e206279010483ad04bfb5b6c619) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/Structures/StructuresCalculationServiceBaseTest.cs (.../StructuresCalculationServiceBaseTest.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -809,7 +809,8 @@ protected override ExceedanceProbabilityCalculationInput CreateInput(TestStructuresInput structureInput, GeneralTestInput generalInput, - string hydraulicBoundaryDatabaseFilePath) + string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor) { return new TestExceedanceProbabilityCalculationInput(structureInput.HydraulicBoundaryLocation.Id); } Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationServiceTest.cs =================================================================== diff -u -rfd8f3552c5039e206279010483ad04bfb5b6c619 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationServiceTest.cs (.../WaveHeightCalculationServiceTest.cs) (revision fd8f3552c5039e206279010483ad04bfb5b6c619) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationServiceTest.cs (.../WaveHeightCalculationServiceTest.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -206,6 +206,50 @@ [Test] [TestCase(true)] [TestCase(false)] + public void Calculate_ValidDesignWaterLevelCalculationWithPreprocessorDirectory_StartsCalculationWithRightParametersAndLogs(bool usePreprocessor) + { + // Setup + string preprocessorDirectory = usePreprocessor + ? validPreprocessorDirectory + : string.Empty; + + var calculator = new TestWaveHeightCalculator + { + IllustrationPointsResult = new TestGeneralResult(), + Converged = true + }; + + var mockRepository = new MockRepository(); + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath, preprocessorDirectory)).Return(calculator); + + var calculation = mockRepository.Stub(); + calculation.Stub(c => c.Name).Return("punt_flw_ 1"); + calculation.Expect(c => c.Id).Return(100); + calculation.Expect(c => c.CalculateIllustrationPoints).Return(false); + + var calculationMessageProvider = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + new WaveHeightCalculationService().Calculate(calculation, + validFilePath, + preprocessorDirectory, + 1.0 / 30, + calculationMessageProvider); + + // Assert + Assert.AreEqual(usePreprocessor, calculator.ReceivedInputs.Single().PreprocessorSetting.RunPreprocessor); + Assert.IsFalse(calculator.IsCanceled); + } + mockRepository.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] public void Calculate_ValidWaveHeightCalculationAndDoesNotConverge_SetsOutputAndLogs(bool calculateIllustrationPoints) { // Setup Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/test-data/hrd.config.sqlite =================================================================== diff -u -ra91af2b4cf186d4c53e839f6ce44b2ffc2895831 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 Binary files differ Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Service/DuneErosionBoundaryCalculationService.cs =================================================================== diff -u -r0ce0e78f755c50e78451bab5a01d91c98d464caa -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Service/DuneErosionBoundaryCalculationService.cs (.../DuneErosionBoundaryCalculationService.cs) (revision 0ce0e78f755c50e78451bab5a01d91c98d464caa) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Service/DuneErosionBoundaryCalculationService.cs (.../DuneErosionBoundaryCalculationService.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -142,7 +142,8 @@ { DunesBoundaryConditionsCalculationInput calculationInput = CreateInput(duneLocation, norm, - hydraulicBoundaryDatabaseFilePath); + hydraulicBoundaryDatabaseFilePath, + !string.IsNullOrEmpty(preprocessorDirectory)); calculator.Calculate(calculationInput); if (string.IsNullOrEmpty(calculator.LastErrorFileContent)) @@ -236,6 +237,7 @@ /// The norm of the failure mechanism to use. /// The file path to the hydraulic /// boundary database. + /// Indicator whether to use the preprocessor in the calculation. /// A with all needed /// input data. /// Thrown when the @@ -250,10 +252,11 @@ /// private static DunesBoundaryConditionsCalculationInput CreateInput(DuneLocation duneLocation, double norm, - string hydraulicBoundaryDatabaseFilePath) + string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor) { var dunesBoundaryConditionsCalculationInput = new DunesBoundaryConditionsCalculationInput(1, duneLocation.Id, norm); - HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(dunesBoundaryConditionsCalculationInput, hydraulicBoundaryDatabaseFilePath); + HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(dunesBoundaryConditionsCalculationInput, hydraulicBoundaryDatabaseFilePath, usePreprocessor); return dunesBoundaryConditionsCalculationInput; } } Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Service.Test/DuneErosionBoundaryCalculationServiceTest.cs =================================================================== diff -u -rfd8f3552c5039e206279010483ad04bfb5b6c619 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Service.Test/DuneErosionBoundaryCalculationServiceTest.cs (.../DuneErosionBoundaryCalculationServiceTest.cs) (revision fd8f3552c5039e206279010483ad04bfb5b6c619) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Service.Test/DuneErosionBoundaryCalculationServiceTest.cs (.../DuneErosionBoundaryCalculationServiceTest.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -146,14 +146,20 @@ } [Test] - public void Calculate_ValidData_CalculationStartedWithRightParameters() + [TestCase(true)] + [TestCase(false)] + public void Calculate_ValidData_CalculationStartedWithRightParameters(bool usePreprocessor) { // Setup + string preprocessorDirectory = usePreprocessor + ? validPreprocessorDirectory + : string.Empty; + var calculator = new TestDunesBoundaryConditionsCalculator(); var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock(); - calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(testDataPath, validPreprocessorDirectory)) + calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(testDataPath, preprocessorDirectory)) .Return(calculator); mockRepository.ReplayAll(); @@ -179,11 +185,13 @@ duneLocation, mechanismSpecificNorm, validFilePath, - validPreprocessorDirectory); + preprocessorDirectory); // Assert DunesBoundaryConditionsCalculationInput expectedInput = CreateInput(duneLocation, mechanismSpecificNorm); - AssertInput(expectedInput, calculator.ReceivedInputs.Single()); + DunesBoundaryConditionsCalculationInput actualInput = calculator.ReceivedInputs.Single(); + AssertInput(expectedInput, actualInput); + Assert.AreEqual(usePreprocessor, actualInput.PreprocessorSetting.RunPreprocessor); Assert.IsFalse(calculator.IsCanceled); } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs =================================================================== diff -u -rd604f4a885198a27cb0546d2e77318c1dc6ab3a1 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs (.../GrassCoverErosionInwardsCalculationService.cs) (revision d604f4a885198a27cb0546d2e77318c1dc6ab3a1) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs (.../GrassCoverErosionInwardsCalculationService.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -160,9 +160,12 @@ throw new ArgumentNullException(nameof(generalInput)); } + string effectivePreprocessorDirectory = assessmentSection.HydraulicBoundaryDatabase.EffectivePreprocessorDirectory(); + bool usePreprocessor = !string.IsNullOrEmpty(effectivePreprocessorDirectory); + int numberOfCalculators = CreateCalculators(calculation, Path.GetDirectoryName(hydraulicBoundaryDatabaseFilePath), - assessmentSection.HydraulicBoundaryDatabase.EffectivePreprocessorDirectory()); + effectivePreprocessorDirectory); CalculationServiceHelper.LogCalculationBegin(); @@ -171,6 +174,7 @@ OvertoppingOutput overtoppingOutput = CalculateOvertopping(calculation, generalInput, hydraulicBoundaryDatabaseFilePath, + usePreprocessor, assessmentSection.FailureMechanismContribution.Norm, failureMechanismContribution, numberOfCalculators); @@ -185,6 +189,7 @@ generalInput, failureMechanismContribution, hydraulicBoundaryDatabaseFilePath, + usePreprocessor, numberOfCalculators); if (canceled) { @@ -196,6 +201,7 @@ generalInput, failureMechanismContribution, hydraulicBoundaryDatabaseFilePath, + usePreprocessor, numberOfCalculators); if (canceled) @@ -245,6 +251,7 @@ /// The calculation containing the input for the overtopping calculation. /// The general grass cover erosion inwards calculation input parameters. /// The path which points to the hydraulic boundary database file. + /// Indicator whether to use the preprocessor in the calculation. /// The norm which has been defined on the assessment section. /// The amount of contribution for this failure mechanism in the assessment section /// The total number of calculations to perform. @@ -253,6 +260,7 @@ private OvertoppingOutput CalculateOvertopping(GrassCoverErosionInwardsCalculation calculation, GeneralGrassCoverErosionInwardsInput generalInput, string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor, double norm, double failureMechanismContribution, int numberOfCalculators) @@ -261,7 +269,10 @@ Resources.GrassCoverErosionInwardsCalculationService_Overtopping), 1, numberOfCalculators); - OvertoppingCalculationInput overtoppingCalculationInput = CreateOvertoppingInput(calculation, generalInput, hydraulicBoundaryDatabaseFilePath); + OvertoppingCalculationInput overtoppingCalculationInput = CreateOvertoppingInput(calculation, + generalInput, + hydraulicBoundaryDatabaseFilePath, + usePreprocessor); PerformCalculation(() => overtoppingCalculator.Calculate(overtoppingCalculationInput), () => overtoppingCalculator.LastErrorFileContent, @@ -300,6 +311,7 @@ GeneralGrassCoverErosionInwardsInput generalInput, double failureMechanismContribution, string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor, int numberOfCalculators) { if (dikeHeightCalculator == null) @@ -320,7 +332,8 @@ DikeHeightCalculationInput dikeHeightCalculationInput = CreateDikeHeightInput(calculation, norm, generalInput, - hydraulicBoundaryDatabaseFilePath); + hydraulicBoundaryDatabaseFilePath, + usePreprocessor); var dikeHeightCalculated = true; @@ -355,6 +368,7 @@ GeneralGrassCoverErosionInwardsInput generalInput, double failureMechanismContribution, string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor, int numberOfCalculators) { if (overtoppingRateCalculator == null) @@ -375,7 +389,8 @@ OvertoppingRateCalculationInput overtoppingRateCalculationInput = CreateOvertoppingRateInput(calculation, norm, generalInput, - hydraulicBoundaryDatabaseFilePath); + hydraulicBoundaryDatabaseFilePath, + usePreprocessor); var overtoppingRateCalculated = true; @@ -482,6 +497,7 @@ /// The calculation containing the input for the overtopping calculation. /// The general grass cover erosion inwards calculation input parameters. /// The path which points to the hydraulic boundary database file. + /// Indicator whether to use the preprocessor in the calculation. /// A new instance. /// Thrown when the /// contains invalid characters. @@ -495,7 +511,8 @@ /// private static OvertoppingCalculationInput CreateOvertoppingInput(GrassCoverErosionInwardsCalculation calculation, GeneralGrassCoverErosionInwardsInput generalInput, - string hydraulicBoundaryDatabaseFilePath) + string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor) { var overtoppingCalculationInput = new OvertoppingCalculationInput(calculation.InputParameters.HydraulicBoundaryLocation.Id, calculation.InputParameters.Orientation, @@ -524,7 +541,7 @@ generalInput.FshallowModelFactor.LowerBoundary, generalInput.FshallowModelFactor.UpperBoundary); - HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(overtoppingCalculationInput, hydraulicBoundaryDatabaseFilePath); + HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(overtoppingCalculationInput, hydraulicBoundaryDatabaseFilePath, usePreprocessor); return overtoppingCalculationInput; } @@ -536,6 +553,7 @@ /// The norm to use in the calculation. /// The general grass cover erosion inwards calculation input parameters. /// The path which points to the hydraulic boundary database file. + /// Indicator whether to use the preprocessor in the calculation. /// A new instance. /// Thrown when the /// contains invalid characters. @@ -550,7 +568,8 @@ private static DikeHeightCalculationInput CreateDikeHeightInput(GrassCoverErosionInwardsCalculation calculation, double norm, GeneralGrassCoverErosionInwardsInput generalInput, - string hydraulicBoundaryDatabaseFilePath) + string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor) { var dikeHeightCalculationInput = new DikeHeightCalculationInput(calculation.InputParameters.HydraulicBoundaryLocation.Id, norm, @@ -579,7 +598,7 @@ generalInput.FshallowModelFactor.LowerBoundary, generalInput.FshallowModelFactor.UpperBoundary); - HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(dikeHeightCalculationInput, hydraulicBoundaryDatabaseFilePath); + HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(dikeHeightCalculationInput, hydraulicBoundaryDatabaseFilePath, usePreprocessor); return dikeHeightCalculationInput; } @@ -591,6 +610,7 @@ /// The norm to use in the calculation. /// The general grass cover erosion inwards calculation input parameters. /// The path which points to the hydraulic boundary database file. + /// Indicator whether to use the preprocessor in the calculation. /// A new instance. /// Thrown when the /// contains invalid characters. @@ -605,7 +625,8 @@ private static OvertoppingRateCalculationInput CreateOvertoppingRateInput(GrassCoverErosionInwardsCalculation calculation, double norm, GeneralGrassCoverErosionInwardsInput generalInput, - string hydraulicBoundaryDatabaseFilePath) + string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor) { var overtoppingRateCalculationInput = new OvertoppingRateCalculationInput(calculation.InputParameters.HydraulicBoundaryLocation.Id, norm, @@ -633,7 +654,7 @@ generalInput.FshallowModelFactor.LowerBoundary, generalInput.FshallowModelFactor.UpperBoundary); - HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(overtoppingRateCalculationInput, hydraulicBoundaryDatabaseFilePath); + HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(overtoppingRateCalculationInput, hydraulicBoundaryDatabaseFilePath, usePreprocessor); return overtoppingRateCalculationInput; } Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/GrassCoverErosionInwardsCalculationServiceTest.cs =================================================================== diff -u -rfd8f3552c5039e206279010483ad04bfb5b6c619 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/GrassCoverErosionInwardsCalculationServiceTest.cs (.../GrassCoverErosionInwardsCalculationServiceTest.cs) (revision fd8f3552c5039e206279010483ad04bfb5b6c619) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/GrassCoverErosionInwardsCalculationServiceTest.cs (.../GrassCoverErosionInwardsCalculationServiceTest.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -2746,6 +2746,9 @@ } // Assert + Assert.IsTrue(overtoppingCalculator.ReceivedInputs.Single().PreprocessorSetting.RunPreprocessor); + Assert.IsTrue(dikeHeightCalculator.ReceivedInputs.Single().PreprocessorSetting.RunPreprocessor); + Assert.IsTrue(overtoppingRateCalculator.ReceivedInputs.Single().PreprocessorSetting.RunPreprocessor); mockRepository.VerifyAll(); } @@ -2800,6 +2803,9 @@ } // Assert + Assert.IsFalse(overtoppingCalculator.ReceivedInputs.Single().PreprocessorSetting.RunPreprocessor); + Assert.IsFalse(dikeHeightCalculator.ReceivedInputs.Single().PreprocessorSetting.RunPreprocessor); + Assert.IsFalse(overtoppingRateCalculator.ReceivedInputs.Single().PreprocessorSetting.RunPreprocessor); mockRepository.VerifyAll(); } Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs =================================================================== diff -u -r19f983eab8eac43d27e39f6eb9de019bad677652 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs (.../HeightStructuresCalculationService.cs) (revision 19f983eab8eac43d27e39f6eb9de019bad677652) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs (.../HeightStructuresCalculationService.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -41,7 +41,8 @@ protected override StructuresOvertoppingCalculationInput CreateInput(HeightStructuresInput structureInput, GeneralHeightStructuresInput generalInput, - string hydraulicBoundaryDatabaseFilePath) + string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor) { var structuresOvertoppingCalculationInput = new StructuresOvertoppingCalculationInput( structureInput.HydraulicBoundaryLocation.Id, @@ -64,7 +65,7 @@ structureInput.DeviationWaveDirection, structureInput.StormDuration.Mean, structureInput.StormDuration.CoefficientOfVariation); - HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(structuresOvertoppingCalculationInput, hydraulicBoundaryDatabaseFilePath); + HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(structuresOvertoppingCalculationInput, hydraulicBoundaryDatabaseFilePath, usePreprocessor); return structuresOvertoppingCalculationInput; } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Service.Test/HeightStructuresCalculationServiceTest.cs =================================================================== diff -u -rd0532a4358c7ad50722fd19082677e43fcb018d8 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Service.Test/HeightStructuresCalculationServiceTest.cs (.../HeightStructuresCalculationServiceTest.cs) (revision d0532a4358c7ad50722fd19082677e43fcb018d8) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Service.Test/HeightStructuresCalculationServiceTest.cs (.../HeightStructuresCalculationServiceTest.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -572,6 +572,56 @@ } [Test] + [Combinatorial] + public void Calculate_PreprocessorDirectorySet_InputPropertiesCorrectlySentToCalculator([Values(true, false)] bool usePreprocessor) + { + // Setup + string preprocessorDirectory = usePreprocessor + ? validPreprocessorDirectory + : string.Empty; + + var failureMechanism = new HeightStructuresFailureMechanism(); + + var mockRepository = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, + mockRepository); + var calculator = new TestStructuresCalculator(); + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateStructuresCalculator(testDataPath, preprocessorDirectory)) + .Return(calculator); + mockRepository.ReplayAll(); + + var calculation = new TestHeightStructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001) + } + }; + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + new HeightStructuresCalculationService().Calculate(calculation, + failureMechanism.GeneralInput, + failureMechanism.GeneralInput.N, + assessmentSection.FailureMechanismContribution.Norm, + failureMechanism.Contribution, + validFilePath, + preprocessorDirectory); + + // Assert + StructuresOvertoppingCalculationInput[] calculationInputs = calculator.ReceivedInputs.ToArray(); + Assert.AreEqual(1, calculationInputs.Length); + + StructuresOvertoppingCalculationInput actualInput = calculationInputs[0]; + Assert.AreEqual(usePreprocessor, actualInput.PreprocessorSetting.RunPreprocessor); + Assert.IsFalse(calculator.IsCanceled); + } + mockRepository.VerifyAll(); + } + + [Test] public void Calculate_CalculationFailedWithExceptionAndLastErrorPresent_LogErrorAndThrowException() { // Setup Index: Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/test-data/HydraRingCalculation/HRD dutch coast south.config.sqlite =================================================================== diff -u -r16f6bd5805e77d549cded91fc48fff35ffbdec00 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 Binary files differ Index: Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/test-data/HydraRingCalculation/HRD ijsselmeer.config.sqlite =================================================================== diff -u -r16f6bd5805e77d549cded91fc48fff35ffbdec00 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 Binary files differ Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Service/WaveConditionsCalculationServiceBase.cs =================================================================== diff -u -rd604f4a885198a27cb0546d2e77318c1dc6ab3a1 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Service/WaveConditionsCalculationServiceBase.cs (.../WaveConditionsCalculationServiceBase.cs) (revision d604f4a885198a27cb0546d2e77318c1dc6ab3a1) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Service/WaveConditionsCalculationServiceBase.cs (.../WaveConditionsCalculationServiceBase.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -269,7 +269,8 @@ { string hlcdDirectory = Path.GetDirectoryName(hydraulicBoundaryDatabaseFilePath); calculator = HydraRingCalculatorFactory.Instance.CreateWaveConditionsCosineCalculator(hlcdDirectory, preprocessorDirectory); - WaveConditionsCosineCalculationInput calculationInput = CreateInput(waterLevel, a, b, c, norm, input, hydraulicBoundaryDatabaseFilePath); + WaveConditionsCosineCalculationInput calculationInput = CreateInput(waterLevel, a, b, c, norm, input, hydraulicBoundaryDatabaseFilePath, + !string.IsNullOrEmpty(preprocessorDirectory)); WaveConditionsOutput output; var exceptionThrown = false; @@ -343,6 +344,7 @@ /// The norm to use as the target. /// The input that is different per calculation. /// The path to the hydraulic boundary database file. + /// Indicator whether to use the preprocessor in the calculation. /// A . /// Thrown when the /// contains invalid characters. @@ -360,7 +362,8 @@ RoundedDouble c, double norm, WaveConditionsInput input, - string hydraulicBoundaryDatabaseFilePath) + string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor) { var waveConditionsCosineCalculationInput = new WaveConditionsCosineCalculationInput( 1, @@ -374,7 +377,7 @@ b, c); - HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(waveConditionsCosineCalculationInput, hydraulicBoundaryDatabaseFilePath); + HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(waveConditionsCosineCalculationInput, hydraulicBoundaryDatabaseFilePath, usePreprocessor); return waveConditionsCosineCalculationInput; } Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Service.Test/WaveConditionsCalculationServiceBaseTest.cs =================================================================== diff -u -r284d0bb44bac303edcecfb8f70b44c4d58696e16 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Service.Test/WaveConditionsCalculationServiceBaseTest.cs (.../WaveConditionsCalculationServiceBaseTest.cs) (revision 284d0bb44bac303edcecfb8f70b44c4d58696e16) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Service.Test/WaveConditionsCalculationServiceBaseTest.cs (.../WaveConditionsCalculationServiceBaseTest.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -495,6 +495,58 @@ } [Test] + [TestCase(true)] + [TestCase(false)] + public void Calculate_PreprocessorDirectorySet_StartsCalculationWithRightParameters(bool usePreprocessor) + { + // Setup + string preprocessorDirectory = usePreprocessor + ? validPreprocessorDirectory + : string.Empty; + + var waterLevel = (RoundedDouble) 4.20; + var a = (RoundedDouble) 1.0; + var b = (RoundedDouble) 0.8; + var c = (RoundedDouble) 0.4; + const double norm = 0.2; + var input = new WaveConditionsInput + { + HydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(waterLevel), + ForeshoreProfile = new TestForeshoreProfile(true), + UpperBoundaryRevetment = (RoundedDouble) 4, + LowerBoundaryRevetment = (RoundedDouble) 3, + StepSize = WaveConditionsInputStepSize.Two, + Orientation = (RoundedDouble) 0 + }; + + string hcldFilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite"); + + var calculator = new TestWaveConditionsCosineCalculator(); + int nrOfCalculators = input.WaterLevels.Count(); + + var mockRepository = new MockRepository(); + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(testDataPath, preprocessorDirectory)) + .Return(calculator) + .Repeat + .Times(nrOfCalculators); + mockRepository.ReplayAll(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + new WaveConditionsCalculationService().PublicCalculate(a, b, c, norm, input, hcldFilePath, preprocessorDirectory); + + // Assert + for (var i = 0; i < nrOfCalculators; i++) + { + Assert.AreEqual(usePreprocessor, calculator.ReceivedInputs[i].PreprocessorSetting.RunPreprocessor); + } + } + mockRepository.VerifyAll(); + } + + [Test] [TestCaseSource(typeof(HydraRingCalculatorTestCaseProvider), nameof(HydraRingCalculatorTestCaseProvider.GetCalculatorFailingConditionsWithReportDetails), new object[] { nameof(Calculate_ThreeCalculationsFail_ThrowsHydraRingCalculationExceptionAndLogError) Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/StabilityPointStructuresCalculationService.cs =================================================================== diff -u -r19f983eab8eac43d27e39f6eb9de019bad677652 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/StabilityPointStructuresCalculationService.cs (.../StabilityPointStructuresCalculationService.cs) (revision 19f983eab8eac43d27e39f6eb9de019bad677652) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/StabilityPointStructuresCalculationService.cs (.../StabilityPointStructuresCalculationService.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -44,7 +44,8 @@ protected override StructuresStabilityPointCalculationInput CreateInput(StabilityPointStructuresInput structureInput, GeneralStabilityPointStructuresInput generalInput, - string hydraulicBoundaryDatabaseFilePath) + string hydraulicBoundaryDatabaseFilePath, + bool usePreprocessor) { StructuresStabilityPointCalculationInput input; switch (structureInput.InflowModelType) @@ -93,7 +94,7 @@ typeof(StabilityPointStructureInflowModelType)); } - HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(input, hydraulicBoundaryDatabaseFilePath); + HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(input, hydraulicBoundaryDatabaseFilePath, usePreprocessor); return input; } Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Service.Test/StabilityPointStructuresCalculationServiceTest.cs =================================================================== diff -u -rd0532a4358c7ad50722fd19082677e43fcb018d8 -r1a13918c62e84efa50c1f121e59d81fccb7ff625 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Service.Test/StabilityPointStructuresCalculationServiceTest.cs (.../StabilityPointStructuresCalculationServiceTest.cs) (revision d0532a4358c7ad50722fd19082677e43fcb018d8) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Service.Test/StabilityPointStructuresCalculationServiceTest.cs (.../StabilityPointStructuresCalculationServiceTest.cs) (revision 1a13918c62e84efa50c1f121e59d81fccb7ff625) @@ -1106,6 +1106,56 @@ [Test] [Combinatorial] + public void Calculate_PreprocessorDirectorySet_InputPropertiesCorrectlySentToCalculator([Values(true, false)] bool usePreprocessor) + { + // Setup + string preprocessorDirectory = usePreprocessor + ? validPreprocessorDirectory + : string.Empty; + + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + var mockRepository = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, + mockRepository); + var calculator = new TestStructuresCalculator(); + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateStructuresCalculator(testDataPath, preprocessorDirectory)) + .Return(calculator); + mockRepository.ReplayAll(); + + var calculation = new TestStabilityPointStructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001) + } + }; + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + new StabilityPointStructuresCalculationService().Calculate(calculation, + failureMechanism.GeneralInput, + failureMechanism.GeneralInput.N, + assessmentSection.FailureMechanismContribution.Norm, + failureMechanism.Contribution, + validFilePath, + preprocessorDirectory); + + // Assert + StructuresStabilityPointCalculationInput[] calculationInputs = calculator.ReceivedInputs.ToArray(); + Assert.AreEqual(1, calculationInputs.Length); + + StructuresStabilityPointCalculationInput actualInput = calculationInputs[0]; + Assert.AreEqual(usePreprocessor, actualInput.PreprocessorSetting.RunPreprocessor); + Assert.IsFalse(calculator.IsCanceled); + } + mockRepository.VerifyAll(); + } + + [Test] + [Combinatorial] public void Calculate_ValidCalculation_LogStartAndEndAndReturnOutput( [Values(StabilityPointStructureInflowModelType.FloodedCulvert, StabilityPointStructureInflowModelType.LowSill)] StabilityPointStructureInflowModelType inflowModelType, [Values(LoadSchematizationType.Quadratic, LoadSchematizationType.Linear)] LoadSchematizationType loadSchematizationType,