Index: Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationActivity.cs =================================================================== diff -u -rca294adc98299b17393265233305360300e8b0ef -rb3e587584ceb7389563f3fd460e96f1b3e10506e --- Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationActivity.cs (.../DesignWaterLevelCalculationActivity.cs) (revision ca294adc98299b17393265233305360300e8b0ef) +++ Ringtoets/Common/src/Ringtoets.Common.Service/DesignWaterLevelCalculationActivity.cs (.../DesignWaterLevelCalculationActivity.cs) (revision b3e587584ceb7389563f3fd460e96f1b3e10506e) @@ -55,12 +55,13 @@ string categoryBoundaryName) : base(hydraulicBoundaryLocationCalculation) { + messageProvider = new DesignWaterLevelCalculationMessageProvider(categoryBoundaryName); + this.hydraulicBoundaryLocationCalculation = hydraulicBoundaryLocationCalculation; this.hydraulicBoundaryDatabaseFilePath = hydraulicBoundaryDatabaseFilePath; this.preprocessorDirectory = preprocessorDirectory; this.norm = norm; - messageProvider = new DesignWaterLevelCalculationMessageProvider(categoryBoundaryName); calculationService = new DesignWaterLevelCalculationService(); Description = messageProvider.GetActivityDescription(hydraulicBoundaryLocationCalculation.HydraulicBoundaryLocation.Name); Index: Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationActivity.cs =================================================================== diff -u -rca294adc98299b17393265233305360300e8b0ef -rb3e587584ceb7389563f3fd460e96f1b3e10506e --- Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationActivity.cs (.../WaveHeightCalculationActivity.cs) (revision ca294adc98299b17393265233305360300e8b0ef) +++ Ringtoets/Common/src/Ringtoets.Common.Service/WaveHeightCalculationActivity.cs (.../WaveHeightCalculationActivity.cs) (revision b3e587584ceb7389563f3fd460e96f1b3e10506e) @@ -55,12 +55,13 @@ string categoryBoundaryName) : base(hydraulicBoundaryLocationCalculation) { + messageProvider = new WaveHeightCalculationMessageProvider(categoryBoundaryName); + this.hydraulicBoundaryLocationCalculation = hydraulicBoundaryLocationCalculation; this.hydraulicBoundaryDatabaseFilePath = hydraulicBoundaryDatabaseFilePath; this.preprocessorDirectory = preprocessorDirectory; this.norm = norm; - messageProvider = new WaveHeightCalculationMessageProvider(categoryBoundaryName); calculationService = new WaveHeightCalculationService(); Description = messageProvider.GetActivityDescription(hydraulicBoundaryLocationCalculation.HydraulicBoundaryLocation.Name); Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/GuiServices/HydraulicBoundaryLocationCalculationGuiServiceTest.cs =================================================================== diff -u -r363300c699ad66d46344a53e0c2041c9dab281e0 -rb3e587584ceb7389563f3fd460e96f1b3e10506e --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/GuiServices/HydraulicBoundaryLocationCalculationGuiServiceTest.cs (.../HydraulicBoundaryLocationCalculationGuiServiceTest.cs) (revision 363300c699ad66d46344a53e0c2041c9dab281e0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/GuiServices/HydraulicBoundaryLocationCalculationGuiServiceTest.cs (.../HydraulicBoundaryLocationCalculationGuiServiceTest.cs) (revision b3e587584ceb7389563f3fd460e96f1b3e10506e) @@ -42,7 +42,6 @@ { 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 validPreprocessorDirectory = TestHelper.GetScratchPadPath(); [Test] public void Constructor_MainWindowNull_ThrowsArgumentNullException() Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/HydraulicBoundaryLocationCalculationActivityFactoryTest.cs =================================================================== diff -u -r3f8d1494a5efb5f3f05a2c106d618a0d424d6535 -rb3e587584ceb7389563f3fd460e96f1b3e10506e --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/HydraulicBoundaryLocationCalculationActivityFactoryTest.cs (.../HydraulicBoundaryLocationCalculationActivityFactoryTest.cs) (revision 3f8d1494a5efb5f3f05a2c106d618a0d424d6535) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/HydraulicBoundaryLocationCalculationActivityFactoryTest.cs (.../HydraulicBoundaryLocationCalculationActivityFactoryTest.cs) (revision b3e587584ceb7389563f3fd460e96f1b3e10506e) @@ -87,63 +87,36 @@ public void CreateWaveHeightCalculationActivities_WithValidDataAndUsePreprocessorStates_ReturnsExpectedActivity(bool usePreprocessor) { // Setup - const string locationName = "locationName"; const string categoryBoundaryName = "A"; const double norm = 1.0 / 30; - var calculator = new TestWaveHeightCalculator - { - Converged = true - }; - var mocks = new MockRepository(); IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mocks); - - var calculatorFactory = mocks.StrictMock(); - calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath, usePreprocessor ? validPreprocessorDirectory : "")).Return(calculator); - mocks.ReplayAll(); ConfigureAssessmentSection(assessmentSection, usePreprocessor); - var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(locationName); + var hydraulicBoundaryLocation1 = new TestHydraulicBoundaryLocation("locationName1"); + var hydraulicBoundaryLocation2 = new TestHydraulicBoundaryLocation("locationName2"); // Call IEnumerable activities = HydraulicBoundaryLocationCalculationActivityFactory.CreateWaveHeightCalculationActivities( assessmentSection, new[] { - new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation) + new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation1), + new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation2) }, norm, categoryBoundaryName); // Assert - CalculatableActivity activity = activities.Single(); - Assert.IsInstanceOf(activity); + Assert.AreEqual(2, activities.Count()); + CollectionAssert.AllItemsAreInstancesOfType(activities, typeof(WaveHeightCalculationActivity)); - using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) - { - Action call = () => activity.Run(); + AssertWaveHeightCalculationActivity(activities.First(), hydraulicBoundaryLocation1, categoryBoundaryName, norm, usePreprocessor); + AssertWaveHeightCalculationActivity(activities.ElementAt(1), hydraulicBoundaryLocation2, categoryBoundaryName, norm, usePreprocessor); - TestHelper.AssertLogMessages(call, m => - { - string[] messages = m.ToArray(); - Assert.AreEqual(6, messages.Length); - Assert.AreEqual($"Golfhoogte berekenen voor locatie 'locationName' (Categorie {categoryBoundaryName}) is gestart.", messages[0]); - CalculationServiceTestHelper.AssertValidationStartMessage(messages[1]); - CalculationServiceTestHelper.AssertValidationEndMessage(messages[2]); - CalculationServiceTestHelper.AssertCalculationStartMessage(messages[3]); - StringAssert.StartsWith("Golfhoogte berekening is uitgevoerd op de tijdelijke locatie", messages[4]); - CalculationServiceTestHelper.AssertCalculationEndMessage(messages[5]); - }); - WaveHeightCalculationInput waveHeightCalculationInput = calculator.ReceivedInputs.Single(); - - Assert.AreEqual(hydraulicBoundaryLocation.Id, waveHeightCalculationInput.HydraulicBoundaryLocationId); - Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(norm), waveHeightCalculationInput.Beta); - } - - Assert.AreEqual(ActivityState.Executed, activity.State); mocks.VerifyAll(); } @@ -189,59 +162,113 @@ public void CreateDesignWaterLevelCalculationActivities_WithValidDataAndUsePreprocessorStates_ReturnsExpectedActivity(bool usePreprocessor) { // Setup - const string locationName = "locationName"; const string categoryBoundaryName = "A"; const double norm = 1.0 / 30; - var calculator = new TestDesignWaterLevelCalculator - { - Converged = true - }; - var mocks = new MockRepository(); IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mocks); - - var calculatorFactory = mocks.StrictMock(); - calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath, usePreprocessor ? validPreprocessorDirectory : "")).Return(calculator); mocks.ReplayAll(); ConfigureAssessmentSection(assessmentSection, usePreprocessor); - var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(locationName); + var hydraulicBoundaryLocation1 = new TestHydraulicBoundaryLocation("locationName1"); + var hydraulicBoundaryLocation2 = new TestHydraulicBoundaryLocation("locationName2"); // Call IEnumerable activities = HydraulicBoundaryLocationCalculationActivityFactory.CreateDesignWaterLevelCalculationActivities( assessmentSection, new[] { - new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation) + new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation1), + new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation2) }, norm, categoryBoundaryName); // Assert - CalculatableActivity activity = activities.Single(); - Assert.IsInstanceOf(activity); + Assert.AreEqual(2, activities.Count()); + CollectionAssert.AllItemsAreInstancesOfType(activities, typeof(DesignWaterLevelCalculationActivity)); + AssertDesignWaterLevelCalculationActivity(activities.First(), hydraulicBoundaryLocation1, categoryBoundaryName, norm, usePreprocessor); + AssertDesignWaterLevelCalculationActivity(activities.ElementAt(1), hydraulicBoundaryLocation2, categoryBoundaryName, norm, usePreprocessor); + + mocks.VerifyAll(); + } + + private void AssertWaveHeightCalculationActivity(Activity activity, + HydraulicBoundaryLocation hydraulicBoundaryLocation, + string categoryBoundaryName, + double norm, + bool usePreprocessor) + { + var mocks = new MockRepository(); + var calculator = new TestWaveHeightCalculator + { + Converged = true + }; + var calculatorFactory = mocks.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath, usePreprocessor ? validPreprocessorDirectory : "")).Return(calculator); + mocks.ReplayAll(); + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { - Action call = () => activity.Run(); + Action call = activity.Run; TestHelper.AssertLogMessages(call, m => { string[] messages = m.ToArray(); Assert.AreEqual(6, messages.Length); - Assert.AreEqual($"Waterstand berekenen voor locatie 'locationName' (Categorie {categoryBoundaryName}) is gestart.", messages[0]); + Assert.AreEqual($"Golfhoogte berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie {categoryBoundaryName}) is gestart.", messages[0]); CalculationServiceTestHelper.AssertValidationStartMessage(messages[1]); CalculationServiceTestHelper.AssertValidationEndMessage(messages[2]); CalculationServiceTestHelper.AssertCalculationStartMessage(messages[3]); + StringAssert.StartsWith("Golfhoogte berekening is uitgevoerd op de tijdelijke locatie", messages[4]); + CalculationServiceTestHelper.AssertCalculationEndMessage(messages[5]); + }); + WaveHeightCalculationInput waveHeightCalculationInput = calculator.ReceivedInputs.Single(); + + Assert.AreEqual(hydraulicBoundaryLocation.Id, waveHeightCalculationInput.HydraulicBoundaryLocationId); + Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(norm), waveHeightCalculationInput.Beta); + } + + Assert.AreEqual(ActivityState.Executed, activity.State); + mocks.VerifyAll(); + } + + private void AssertDesignWaterLevelCalculationActivity(Activity activity, + HydraulicBoundaryLocation hydraulicBoundaryLocation, + string categoryBoundaryName, + double norm, + bool usePreprocessor) + { + var mocks = new MockRepository(); + var calculator = new TestDesignWaterLevelCalculator + { + Converged = true + }; + var calculatorFactory = mocks.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath, usePreprocessor ? validPreprocessorDirectory : "")).Return(calculator); + mocks.ReplayAll(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + Action call = activity.Run; + + TestHelper.AssertLogMessages(call, m => + { + string[] messages = m.ToArray(); + Assert.AreEqual(6, messages.Length); + Assert.AreEqual($"Waterstand berekenen voor locatie '{hydraulicBoundaryLocation.Name}' (Categorie {categoryBoundaryName}) is gestart.", messages[0]); + CalculationServiceTestHelper.AssertValidationStartMessage(messages[1]); + CalculationServiceTestHelper.AssertValidationEndMessage(messages[2]); + CalculationServiceTestHelper.AssertCalculationStartMessage(messages[3]); StringAssert.StartsWith("Waterstand berekening is uitgevoerd op de tijdelijke locatie", messages[4]); CalculationServiceTestHelper.AssertCalculationEndMessage(messages[5]); }); - AssessmentLevelCalculationInput assessmentLevelCalculationInput = calculator.ReceivedInputs.Single(); + AssessmentLevelCalculationInput waveHeightCalculationInput = calculator.ReceivedInputs.Single(); - Assert.AreEqual(hydraulicBoundaryLocation.Id, assessmentLevelCalculationInput.HydraulicBoundaryLocationId); - Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(norm), assessmentLevelCalculationInput.Beta); + Assert.AreEqual(hydraulicBoundaryLocation.Id, waveHeightCalculationInput.HydraulicBoundaryLocationId); + Assert.AreEqual(StatisticsConverter.ProbabilityToReliability(norm), waveHeightCalculationInput.Beta); } Assert.AreEqual(ActivityState.Executed, activity.State); Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r2dadb16fa39d6a4ac94305346c70aee7927e8673 -rb3e587584ceb7389563f3fd460e96f1b3e10506e --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 2dadb16fa39d6a4ac94305346c70aee7927e8673) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision b3e587584ceb7389563f3fd460e96f1b3e10506e) @@ -1944,11 +1944,6 @@ RingtoetsCommonFormsResources.CalculateAllIcon, (sender, args) => { - if (hydraulicBoundaryLocationCalculationGuiService == null) - { - return; - } - ActivityProgressDialogRunner.Run( Gui.MainWindow, AssessmentSectionHydraulicBoundaryLocationCalculationActivityFactory.CreateHydraulicBoundaryLocationCalculationActivities(nodeData.AssessmentSection)); @@ -2109,11 +2104,6 @@ RingtoetsCommonFormsResources.CalculateAllIcon, (sender, args) => { - if (hydraulicBoundaryLocationCalculationGuiService == null) - { - return; - } - ActivityProgressDialogRunner.Run( Gui.MainWindow, AssessmentSectionHydraulicBoundaryLocationCalculationActivityFactory.CreateDesignWaterLevelCalculationActivities(assessmentSection)); @@ -2139,11 +2129,6 @@ RingtoetsCommonFormsResources.CalculateAllIcon, (sender, args) => { - if (hydraulicBoundaryLocationCalculationGuiService == null) - { - return; - } - ActivityProgressDialogRunner.Run( Gui.MainWindow, AssessmentSectionHydraulicBoundaryLocationCalculationActivityFactory.CreateWaveHeightCalculationActivities(assessmentSection)); Index: Ringtoets/Integration/src/Ringtoets.Integration.Service/AssessmentSectionHydraulicBoundaryLocationCalculationActivityFactory.cs =================================================================== diff -u -r249a26006e363c5bb4cf26d2f033ee87c30e4bf4 -rb3e587584ceb7389563f3fd460e96f1b3e10506e --- Ringtoets/Integration/src/Ringtoets.Integration.Service/AssessmentSectionHydraulicBoundaryLocationCalculationActivityFactory.cs (.../AssessmentSectionHydraulicBoundaryLocationCalculationActivityFactory.cs) (revision 249a26006e363c5bb4cf26d2f033ee87c30e4bf4) +++ Ringtoets/Integration/src/Ringtoets.Integration.Service/AssessmentSectionHydraulicBoundaryLocationCalculationActivityFactory.cs (.../AssessmentSectionHydraulicBoundaryLocationCalculationActivityFactory.cs) (revision b3e587584ceb7389563f3fd460e96f1b3e10506e) @@ -97,7 +97,7 @@ } /// - /// Creates a collection of for wave height calculations + /// Creates a collection of for design water level calculations /// based on the given . /// /// The assessment section to create the activities for. Index: Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/AssessmentSectionHydraulicBoundaryLocationCalculationActivityFactoryTest.cs =================================================================== diff -u -r249a26006e363c5bb4cf26d2f033ee87c30e4bf4 -rb3e587584ceb7389563f3fd460e96f1b3e10506e --- Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/AssessmentSectionHydraulicBoundaryLocationCalculationActivityFactoryTest.cs (.../AssessmentSectionHydraulicBoundaryLocationCalculationActivityFactoryTest.cs) (revision 249a26006e363c5bb4cf26d2f033ee87c30e4bf4) +++ Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/AssessmentSectionHydraulicBoundaryLocationCalculationActivityFactoryTest.cs (.../AssessmentSectionHydraulicBoundaryLocationCalculationActivityFactoryTest.cs) (revision b3e587584ceb7389563f3fd460e96f1b3e10506e) @@ -41,6 +41,8 @@ public class AssessmentSectionHydraulicBoundaryLocationCalculationActivityFactoryTest { private static readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); + private static readonly string validFilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite"); + private static readonly string validPreprocessorDirectory = TestHelper.GetScratchPadPath(); [Test] public void CreateHydraulicBoundaryLocationCalculationActivities_AssessmentSectionNull_ThrowsArgumentNullException() @@ -57,13 +59,7 @@ public void CreateHydraulicBoundaryLocationCalculationActivities_WithValidData_ExpectedInputSetToActivities() { // Setup - var assessmentSection = new AssessmentSectionStub - { - HydraulicBoundaryDatabase = - { - FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") - } - }; + AssessmentSectionStub assessmentSection = CreateAssessmentSectionStub(); var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("locationName 1"); assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] @@ -82,7 +78,7 @@ double factorizedSignalingNorm = signalingNorm / 30; double lowerLimitNorm = assessmentSection.FailureMechanismContribution.LowerLimitNorm; double factorizedLowerLimitNorm = lowerLimitNorm * 30; - + AssertDesignWaterLevelCalculationActivity(activities.First(), hydraulicBoundaryLocation, factorizedSignalingNorm); @@ -97,17 +93,17 @@ factorizedLowerLimitNorm); AssertWaveHeightCalculationActivity(activities.ElementAt(4), - hydraulicBoundaryLocation, - factorizedSignalingNorm); + hydraulicBoundaryLocation, + factorizedSignalingNorm); AssertWaveHeightCalculationActivity(activities.ElementAt(5), - hydraulicBoundaryLocation, - signalingNorm); + hydraulicBoundaryLocation, + signalingNorm); AssertWaveHeightCalculationActivity(activities.ElementAt(6), - hydraulicBoundaryLocation, - lowerLimitNorm); + hydraulicBoundaryLocation, + lowerLimitNorm); AssertWaveHeightCalculationActivity(activities.ElementAt(7), - hydraulicBoundaryLocation, - factorizedLowerLimitNorm); + hydraulicBoundaryLocation, + factorizedLowerLimitNorm); } [Test] @@ -125,13 +121,7 @@ public void CreateDesignWaterLevelCalculationActivities_WithValidData_ExpectedInputSetToActivities() { // Setup - var assessmentSection = new AssessmentSectionStub - { - HydraulicBoundaryDatabase = - { - FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") - } - }; + AssessmentSectionStub assessmentSection = CreateAssessmentSectionStub(); var hydraulicBoundaryLocation1 = new TestHydraulicBoundaryLocation("locationName 1"); var hydraulicBoundaryLocation2 = new TestHydraulicBoundaryLocation("locationName 2"); @@ -196,13 +186,7 @@ public void CreateWaveHeightCalculationActivities_WithValidData_ExpectedInputSetToActivities() { // Setup - var assessmentSection = new AssessmentSectionStub - { - HydraulicBoundaryDatabase = - { - FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") - } - }; + AssessmentSectionStub assessmentSection = CreateAssessmentSectionStub(); var hydraulicBoundaryLocation1 = new TestHydraulicBoundaryLocation("locationName 1"); var hydraulicBoundaryLocation2 = new TestHydraulicBoundaryLocation("locationName 2"); @@ -252,14 +236,29 @@ factorizedLowerLimitNorm); } + private static AssessmentSectionStub CreateAssessmentSectionStub() + { + var assessmentSection = new AssessmentSectionStub + { + HydraulicBoundaryDatabase = + { + FilePath = validFilePath, + CanUsePreprocessor = true, + PreprocessorDirectory = validPreprocessorDirectory, + UsePreprocessor = true + } + }; + return assessmentSection; + } + private static void AssertDesignWaterLevelCalculationActivity(Activity activity, HydraulicBoundaryLocation hydraulicBoundaryLocation, double norm) { var mocks = new MockRepository(); var designWaterLevelCalculator = new TestDesignWaterLevelCalculator(); var calculatorFactory = mocks.Stub(); - calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath, string.Empty)).Return(designWaterLevelCalculator); + calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(testDataPath, validPreprocessorDirectory)).Return(designWaterLevelCalculator); mocks.ReplayAll(); using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) @@ -281,7 +280,7 @@ var mocks = new MockRepository(); var waveHeightCalculator = new TestWaveHeightCalculator(); var calculatorFactory = mocks.Stub(); - calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath, string.Empty)).Return(waveHeightCalculator); + calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(testDataPath, validPreprocessorDirectory)).Return(waveHeightCalculator); mocks.ReplayAll(); using (new HydraRingCalculatorFactoryConfig(calculatorFactory))