Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInput.cs =================================================================== diff -u -rde24943cc5de951dd42ba93671c9816046ae7607 -r68004dbc5a33be0b6343844bb6706ab2931cbe5c --- Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInput.cs (.../WaveConditionsInput.cs) (revision de24943cc5de951dd42ba93671c9816046ae7607) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInput.cs (.../WaveConditionsInput.cs) (revision 68004dbc5a33be0b6343844bb6706ab2931cbe5c) @@ -154,6 +154,7 @@ /// Gets or sets the lower boundary of the revetment. /// /// Thrown when value is larger than or equal to . + /// When the value is smaller than -50, it will be set to -50. public RoundedDouble LowerBoundaryRevetment { get @@ -164,6 +165,8 @@ { var newLowerBoundaryRevetment = value.ToPrecision(lowerBoundaryRevetment.NumberOfDecimalPlaces); + newLowerBoundaryRevetment = ValidateLowerBoundaryInRange(newLowerBoundaryRevetment); + ValidateRevetmentBoundaries(newLowerBoundaryRevetment, UpperBoundaryRevetment); lowerBoundaryRevetment = newLowerBoundaryRevetment; @@ -174,6 +177,7 @@ /// Gets or sets the upper boundary of the revetment. /// /// Thrown when value is smaller than or equal to . + /// When the value is larger than 1000, it will be set to 1000. public RoundedDouble UpperBoundaryRevetment { get @@ -184,6 +188,8 @@ { var newUpperBoundaryRevetment = value.ToPrecision(upperBoundaryRevetment.NumberOfDecimalPlaces); + newUpperBoundaryRevetment = ValidateUpperBoundaryInRange(newUpperBoundaryRevetment); + ValidateRevetmentBoundaries(LowerBoundaryRevetment, newUpperBoundaryRevetment); upperBoundaryRevetment = newUpperBoundaryRevetment; @@ -200,8 +206,11 @@ /// /// Thrown when value is larger than or equal to . /// - /// Setting this property is optional when it comes to determining ; if the value - /// equals , only will be taken into account. + /// + /// Setting this property is optional when it comes to determining ; if the value + /// equals , only will be taken into account. + /// When the value is smaller than -50, it will be set to -50. + /// /// public RoundedDouble LowerBoundaryWaterLevels { @@ -213,6 +222,8 @@ { var newLowerBoundaryWaterLevels = value.ToPrecision(lowerBoundaryWaterLevels.NumberOfDecimalPlaces); + newLowerBoundaryWaterLevels = ValidateLowerBoundaryInRange(newLowerBoundaryWaterLevels); + ValidateWaterLevelBoundaries(newLowerBoundaryWaterLevels, UpperBoundaryWaterLevels); lowerBoundaryWaterLevels = newLowerBoundaryWaterLevels; @@ -224,9 +235,12 @@ /// /// Thrown when value is smaller than or equal to . /// - /// Setting this property is optional when it comes to determining ; if the value + /// + /// Setting this property is optional when it comes to determining ; if the value /// equals , only and - /// will be taken into account. + /// will be taken into account. + /// When the value is larger than 1000, it will be set to 1000. + /// /// public RoundedDouble UpperBoundaryWaterLevels { @@ -238,6 +252,8 @@ { var newUpperBoundaryWaterLevels = value.ToPrecision(upperBoundaryWaterLevels.NumberOfDecimalPlaces); + newUpperBoundaryWaterLevels = ValidateUpperBoundaryInRange(newUpperBoundaryWaterLevels); + ValidateWaterLevelBoundaries(LowerBoundaryWaterLevels, newUpperBoundaryWaterLevels); upperBoundaryWaterLevels = newUpperBoundaryWaterLevels; @@ -255,6 +271,24 @@ } } + private static RoundedDouble ValidateUpperBoundaryInRange(RoundedDouble boundary) + { + if (boundary > 1000) + { + boundary = new RoundedDouble(boundary.NumberOfDecimalPlaces, 1000); + } + return boundary; + } + + private static RoundedDouble ValidateLowerBoundaryInRange(RoundedDouble boundary) + { + if (boundary < -50) + { + boundary = new RoundedDouble(boundary.NumberOfDecimalPlaces, -50); + } + return boundary; + } + private static void ValidateRevetmentBoundaries(RoundedDouble lowerBoundary, RoundedDouble upperBoundary) { ValidateBoundaries(lowerBoundary, upperBoundary, Resources.WaveConditionsInput_ValidateRevetmentBoundaries_Upper_boundary_revetment_must_be_above_lower_boundary_revetment); Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs =================================================================== diff -u -rde24943cc5de951dd42ba93671c9816046ae7607 -r68004dbc5a33be0b6343844bb6706ab2931cbe5c --- Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs (.../WaveConditionsInputTest.cs) (revision de24943cc5de951dd42ba93671c9816046ae7607) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs (.../WaveConditionsInputTest.cs) (revision 68004dbc5a33be0b6343844bb6706ab2931cbe5c) @@ -395,6 +395,21 @@ } [Test] + [TestCase(-50.005)] + [TestCase(-100)] + public void LowerBoundaryRevetment_BoundarySmallerThanValid_SetValueToValidBoundary(double newValue) + { + // Setup + var input = new WaveConditionsInput(); + + // Call + input.LowerBoundaryRevetment = (RoundedDouble) newValue; + + // Assert + Assert.AreEqual(-50, input.LowerBoundaryRevetment, input.LowerBoundaryRevetment.GetAccuracy()); + } + + [Test] public void UpperBoundaryRevetment_SetNewValue_ValueIsRounded() { // Setup @@ -452,6 +467,21 @@ } [Test] + [TestCase(1000.005)] + [TestCase(1030)] + public void UpperBoundaryRevetment_BoundaryLargerThanValid_SetValueToValidBoundary(double newValue) + { + // Setup + var input = new WaveConditionsInput(); + + // Call + input.UpperBoundaryRevetment = (RoundedDouble)newValue; + + // Assert + Assert.AreEqual(1000, input.UpperBoundaryRevetment, input.UpperBoundaryRevetment.GetAccuracy()); + } + + [Test] public void LowerBoundaryWaterLevels_SetNewValue_ValueIsRounded() { // Setup @@ -509,6 +539,21 @@ } [Test] + [TestCase(-50.005)] + [TestCase(-100)] + public void LowerBoundaryWaterLevels_BoundarySmallerThanValid_SetValueToValidBoundary(double newValue) + { + // Setup + var input = new WaveConditionsInput(); + + // Call + input.LowerBoundaryWaterLevels = (RoundedDouble)newValue; + + // Assert + Assert.AreEqual(-50, input.LowerBoundaryWaterLevels, input.LowerBoundaryWaterLevels.GetAccuracy()); + } + + [Test] public void UpperBoundaryWaterLevels_SetNewValue_ValueIsRounded() { // Setup @@ -566,6 +611,21 @@ } [Test] + [TestCase(1000.005)] + [TestCase(1030)] + public void UpperBoundaryWaterLevels_BoundaryLargerThanValid_SetValueToValidBoundary(double newValue) + { + // Setup + var input = new WaveConditionsInput(); + + // Call + input.UpperBoundaryWaterLevels = (RoundedDouble)newValue; + + // Assert + Assert.AreEqual(1000, input.UpperBoundaryWaterLevels, input.UpperBoundaryWaterLevels.GetAccuracy()); + } + + [Test] [TestCase(double.NaN, 10.0, 12.0)] [TestCase(1.0, double.NaN, 12.0)] [TestCase(1.0, 10.0, double.NaN)]