Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Data/HydraulicBoundaryLocation.cs =================================================================== diff -u -r57634f535a347ce49c2491f114d7238d5387c7a8 -r883060cccacd8501ff89325a242fc352c54e8a53 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Data/HydraulicBoundaryLocation.cs (.../HydraulicBoundaryLocation.cs) (revision 57634f535a347ce49c2491f114d7238d5387c7a8) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Data/HydraulicBoundaryLocation.cs (.../HydraulicBoundaryLocation.cs) (revision 883060cccacd8501ff89325a242fc352c54e8a53) @@ -48,7 +48,7 @@ Id = id; Name = name; Location = new Point2D(coordinateX, coordinateY); - DesignWaterLevel = Double.NaN; + DesignWaterLevel = double.NaN; } /// Index: Ringtoets/Integration/src/Ringtoets.Integration.Service/DesignWaterLevelCalculationActivity.cs =================================================================== diff -u -r6ccc539ce58e63f0e0fbff0da189c87b65146129 -r883060cccacd8501ff89325a242fc352c54e8a53 --- Ringtoets/Integration/src/Ringtoets.Integration.Service/DesignWaterLevelCalculationActivity.cs (.../DesignWaterLevelCalculationActivity.cs) (revision 6ccc539ce58e63f0e0fbff0da189c87b65146129) +++ Ringtoets/Integration/src/Ringtoets.Integration.Service/DesignWaterLevelCalculationActivity.cs (.../DesignWaterLevelCalculationActivity.cs) (revision 883060cccacd8501ff89325a242fc352c54e8a53) @@ -57,17 +57,23 @@ protected override void OnRun() { - PerformRun(() => DesignWaterLevelCalculationService.Validate(assessmentSection.HydraulicBoundaryDatabase, hydraulicBoundaryLocation), - () => hydraulicBoundaryLocation.DesignWaterLevel = double.NaN, - () => DesignWaterLevelCalculationService.Calculate(assessmentSection, - assessmentSection.HydraulicBoundaryDatabase, - hydraulicBoundaryLocation, - assessmentSection.Name)); // TODO: Provide name of reference line instead + if (double.IsNaN(hydraulicBoundaryLocation.DesignWaterLevel)) + { + PerformRun(() => DesignWaterLevelCalculationService.Validate(assessmentSection.HydraulicBoundaryDatabase, hydraulicBoundaryLocation), + () => hydraulicBoundaryLocation.DesignWaterLevel = double.NaN, + () => DesignWaterLevelCalculationService.Calculate(assessmentSection, + assessmentSection.HydraulicBoundaryDatabase, + hydraulicBoundaryLocation, + assessmentSection.Name)); // TODO: Provide name of reference line instead + } } protected override void OnFinish() { - PerformFinish(() => hydraulicBoundaryLocation.DesignWaterLevel = Output.Result, hydraulicBoundaryLocation); + if (double.IsNaN(hydraulicBoundaryLocation.DesignWaterLevel)) + { + PerformFinish(() => hydraulicBoundaryLocation.DesignWaterLevel = Output.Result, hydraulicBoundaryLocation); + } } } } Index: Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/DesignWaterLevelCalculationActivityTest.cs =================================================================== diff -u -r0f7eb2998561112d0013b667ee39c2316341d2fe -r883060cccacd8501ff89325a242fc352c54e8a53 --- Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/DesignWaterLevelCalculationActivityTest.cs (.../DesignWaterLevelCalculationActivityTest.cs) (revision 0f7eb2998561112d0013b667ee39c2316341d2fe) +++ Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/DesignWaterLevelCalculationActivityTest.cs (.../DesignWaterLevelCalculationActivityTest.cs) (revision 883060cccacd8501ff89325a242fc352c54e8a53) @@ -149,6 +149,32 @@ } [Test] + public void Run_CalculationAlreadyRan_ValidationAndCalculationNotPerformed() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + ImportHydraulicBoundaryDatabase(assessmentSection); + + var designWaterLevel = 3.0; + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 1, 1) + { + DesignWaterLevel = designWaterLevel + }; + + var activity = new DesignWaterLevelCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + + // Call + Action call = () => activity.Run(); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(0, msgs.Length); + }); + } + + [Test] public void Finish_ValidCalculationAndRun_SetsDesignWaterLevelAndNotifyObservers() { // Setup @@ -201,6 +227,30 @@ mocks.VerifyAll(); } + [Test] + public void Finish_CalculationAlreadyRan_FinishNotPerformed() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + ImportHydraulicBoundaryDatabase(assessmentSection); + + var designWaterLevel = 3.0; + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test", 1, 1) + { + DesignWaterLevel = designWaterLevel + }; + + var activity = new DesignWaterLevelCalculationActivity(assessmentSection, hydraulicBoundaryLocation); + + activity.Run(); + + // Call + activity.Finish(); + + // Assert + Assert.AreEqual(designWaterLevel, hydraulicBoundaryLocation.DesignWaterLevel); + } + private void ImportHydraulicBoundaryDatabase(AssessmentSection assessmentSection) { string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite");