Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInput.cs =================================================================== diff -u -r619e1c9f14861454e4cbe0109445de3bce0d7a75 -rb0d5ec501a22b7a3e201595217991655901b103b --- Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInput.cs (.../WaveConditionsInput.cs) (revision 619e1c9f14861454e4cbe0109445de3bce0d7a75) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInput.cs (.../WaveConditionsInput.cs) (revision b0d5ec501a22b7a3e201595217991655901b103b) @@ -44,6 +44,9 @@ private RoundedDouble upperWaterLevel; private RoundedDouble stepSize; + private RoundedDouble upperBoundary; + private RoundedDouble lowerBoundary; + /// /// Creates a new instance of . /// @@ -55,6 +58,9 @@ upperWaterLevel = new RoundedDouble(2); stepSize = new RoundedDouble(1); + upperBoundary = new RoundedDouble(2); + lowerBoundary = new RoundedDouble(2); + designWaterLevelSubstraction = new RoundedDouble(2, 0.01); UpdateDikeProfileParameters(); @@ -132,6 +138,7 @@ set { upperRevetmentLevel = value.ToPrecision(upperRevetmentLevel.NumberOfDecimalPlaces); + DetermineBoundaries(); } } @@ -147,6 +154,7 @@ set { lowerRevetmentLevel = value.ToPrecision(lowerRevetmentLevel.NumberOfDecimalPlaces); + DetermineBoundaries(); } } @@ -162,6 +170,7 @@ set { lowerWaterLevel = value.ToPrecision(lowerWaterLevel.NumberOfDecimalPlaces); + DetermineBoundaries(); } } @@ -192,9 +201,40 @@ private set { upperWaterLevel = value.ToPrecision(upperWaterLevel.NumberOfDecimalPlaces); + DetermineBoundaries(); } } + /// + /// Gets the upper boundary of the waterlevels that should be calculated.. + /// + public RoundedDouble UpperBoundary + { + get + { + return upperBoundary; + } + private set + { + upperBoundary = value.ToPrecision(upperBoundary.NumberOfDecimalPlaces); + } + } + + /// + /// Gets the lower boundary of the waterlevels that should be calculated.. + /// + public RoundedDouble LowerBoundary + { + get + { + return lowerBoundary; + } + private set + { + lowerBoundary = value.ToPrecision(lowerBoundary.NumberOfDecimalPlaces); + } + } + private void UpdateUpperWaterLevel() { if (hydraulicBoundaryLocation != null && !double.IsNaN(hydraulicBoundaryLocation.DesignWaterLevel)) @@ -207,6 +247,12 @@ } } + private void DetermineBoundaries() + { + UpperBoundary = UpperWaterLevel < UpperRevetmentLevel ? UpperWaterLevel : UpperRevetmentLevel; + LowerBoundary = LowerWaterLevel > LowerRevetmentLevel ? LowerWaterLevel : LowerRevetmentLevel; + } + private void UpdateDikeProfileParameters() { if (dikeProfile == null) Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs =================================================================== diff -u -r619e1c9f14861454e4cbe0109445de3bce0d7a75 -rb0d5ec501a22b7a3e201595217991655901b103b --- Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs (.../WaveConditionsInputTest.cs) (revision 619e1c9f14861454e4cbe0109445de3bce0d7a75) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs (.../WaveConditionsInputTest.cs) (revision b0d5ec501a22b7a3e201595217991655901b103b) @@ -55,6 +55,8 @@ Assert.AreEqual(new RoundedDouble(2), input.LowerWaterLevel); Assert.AreEqual(new RoundedDouble(2), input.UpperWaterLevel); Assert.AreEqual(new RoundedDouble(1), input.StepSize); + Assert.AreEqual(new RoundedDouble(2), input.LowerBoundary); + Assert.AreEqual(new RoundedDouble(2), input.UpperBoundary); } [Test] @@ -229,20 +231,34 @@ } [Test] - public void HydraulicBoundaryLocation_SetNewValue_UpperWaterLevelUpdated() + [TestCase(true, 6.34, 8.19, 8.18, 6.34)] + [TestCase(true, 8.63, 6.77, 6.76, 6.76)] + [TestCase(false, double.NaN, 7.32, 7.31, 0)] + public void HydraulicBoundaryLocation_SetNewValue_UpperWaterLevelUpdatedAndBoundariesSyncedAccordingly(bool upperRevetmentLevelSet, + double upperRevetmentLevel, + double designWaterLevel, + double expectedUpperWaterLevel, + double expectedUpperBoundary) { // Setup var input = new WaveConditionsInput(); + + if (upperRevetmentLevelSet) + { + input.UpperRevetmentLevel = (RoundedDouble) upperRevetmentLevel; + } + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) { - DesignWaterLevel = new RoundedDouble(2, 6.34) + DesignWaterLevel = (RoundedDouble) designWaterLevel }; // Call input.HydraulicBoundaryLocation = hydraulicBoundaryLocation; // Assert - Assert.AreEqual(6.33, input.UpperWaterLevel, input.UpperWaterLevel.GetAccuracy()); + Assert.AreEqual(expectedUpperWaterLevel, input.UpperWaterLevel, input.UpperWaterLevel.GetAccuracy()); + Assert.AreEqual(expectedUpperBoundary, input.UpperBoundary, input.UpperBoundary.GetAccuracy()); } [Test] @@ -303,5 +319,80 @@ // Assert Assert.AreEqual(new RoundedDouble(2), input.UpperWaterLevel); } + + [Test] + [TestCase(true, 7.65, 5.39, 5.39)] + [TestCase(true, 7.65, 8.34, 7.64)] + [TestCase(false, double.NaN, 5.39, 0)] + public void UpperRevetmentLevel_SetNewValue_BoundariesSyncedAccordingly(bool hydraulicBoundaryLocationSet, + double designWaterLevel, + double upperRevetmentLevel, + double expectedUpperBoundary) + { + // Setup + var input = new WaveConditionsInput(); + + if (hydraulicBoundaryLocationSet) + { + input.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) + { + DesignWaterLevel = (RoundedDouble) designWaterLevel + }; + } + + // Call + input.UpperRevetmentLevel = (RoundedDouble) upperRevetmentLevel; + + // Assert + Assert.AreEqual(expectedUpperBoundary, input.UpperBoundary, input.UpperBoundary.GetAccuracy()); + } + + [Test] + [TestCase(true, -2.31, -1.53, -1.53)] + [TestCase(true, -1.56, -3.29, -1.56)] + [TestCase(false, double.NaN, -1.29, 0)] + public void LowerRevetmentLevel_SetNewValue_BoundariesSyncedAccordingly(bool lowerWaterLevelSet, + double lowerWaterLevel, + double lowerRevetmentLevel, + double expectedLowerBoundary) + { + // Setup + var input = new WaveConditionsInput(); + + if (lowerWaterLevelSet) + { + input.LowerWaterLevel = (RoundedDouble) lowerWaterLevel; + } + + // Call + input.LowerRevetmentLevel = (RoundedDouble) lowerRevetmentLevel; + + // Assert + Assert.AreEqual(expectedLowerBoundary, input.LowerBoundary, input.LowerBoundary.GetAccuracy()); + } + + [Test] + [TestCase(true, -2.31, -1.53, -1.53)] + [TestCase(true, -1.56, -3.29, -1.56)] + [TestCase(false, double.NaN, -1.29, 0)] + public void LowerWaterLevel_SetNewValue_BoundariesSyncedAccordingly(bool lowerRevetmentLevelSet, + double lowerRevetmentLevel, + double lowerWaterLevel, + double expectedLowerBoundary) + { + // Setup + var input = new WaveConditionsInput(); + + if (lowerRevetmentLevelSet) + { + input.LowerRevetmentLevel = (RoundedDouble) lowerRevetmentLevel; + } + + // Call + input.LowerWaterLevel = (RoundedDouble) lowerWaterLevel; + + // Assert + Assert.AreEqual(expectedLowerBoundary, input.LowerBoundary, input.LowerBoundary.GetAccuracy()); + } } } \ No newline at end of file