Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresInput.cs
===================================================================
diff -u -rc3294111adba59fbf4a19757d1b945ec7045a19f -r547267b70fbf09e80c59b252b4660300cc370c74
--- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresInput.cs (.../ClosingStructuresInput.cs) (revision c3294111adba59fbf4a19757d1b945ec7045a19f)
+++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresInput.cs (.../ClosingStructuresInput.cs) (revision 547267b70fbf09e80c59b252b4660300cc370c74)
@@ -159,33 +159,62 @@
#region Deterministic inputs
+ #region Structure Normal orientation
+
///
- /// Gets or sets the storm duration for an open structure.
+ /// Gets or sets the orientation of the normal of the structure.
///
- public RoundedDouble FactorStormDurationOpenStructure
+ ///
+ /// - When the value is smaller than 0, it will be set to 0.
+ /// - When the value is larger than 360, it will be set to 360.
+ ///
+ public RoundedDouble StructureNormalOrientation
{
get
{
- return factorStormDurationOpenStructure;
+ return structureNormalOrientation;
}
set
{
- factorStormDurationOpenStructure = value.ToPrecision(factorStormDurationOpenStructure.NumberOfDecimalPlaces);
+
+ RoundedDouble newOrientationValue = value.ToPrecision(structureNormalOrientation.NumberOfDecimalPlaces);
+ newOrientationValue = ValidateStructureNormalOrientationInRange(newOrientationValue);
+
+ structureNormalOrientation = newOrientationValue;
}
}
+ private RoundedDouble ValidateStructureNormalOrientationInRange(RoundedDouble newOrientationValue)
+ {
+ const double upperBoundaryRange = 360;
+ const double lowerBoundaryRange = 0.0;
+
+ if (newOrientationValue > upperBoundaryRange)
+ {
+ newOrientationValue = new RoundedDouble(2, upperBoundaryRange);
+ }
+ else if (newOrientationValue < lowerBoundaryRange)
+ {
+ newOrientationValue = new RoundedDouble(2, lowerBoundaryRange);
+ }
+
+ return newOrientationValue;
+ }
+
+ #endregion
+
///
- /// Gets or sets the orientation of the normal of the structure.
+ /// Gets or sets the storm duration for an open structure.
///
- public RoundedDouble StructureNormalOrientation
+ public RoundedDouble FactorStormDurationOpenStructure
{
get
{
- return structureNormalOrientation;
+ return factorStormDurationOpenStructure;
}
set
{
- structureNormalOrientation = value.ToPrecision(structureNormalOrientation.NumberOfDecimalPlaces);
+ factorStormDurationOpenStructure = value.ToPrecision(factorStormDurationOpenStructure.NumberOfDecimalPlaces);
}
}
Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs
===================================================================
diff -u -rc3294111adba59fbf4a19757d1b945ec7045a19f -r547267b70fbf09e80c59b252b4660300cc370c74
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs (.../ClosingStructuresInputTest.cs) (revision c3294111adba59fbf4a19757d1b945ec7045a19f)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs (.../ClosingStructuresInputTest.cs) (revision 547267b70fbf09e80c59b252b4660300cc370c74)
@@ -50,6 +50,9 @@
Assert.IsNull(input.HydraulicBoundaryLocation);
Assert.IsNull(input.ClosingStructure);
+ AssertEqualValues(0, input.StructureNormalOrientation);
+ Assert.AreEqual(2, input.StructureNormalOrientation.NumberOfDecimalPlaces);
+
Assert.IsNull(input.ForeshoreProfile);
Assert.IsFalse(input.UseBreakWater);
Assert.AreEqual(BreakWaterType.Dam, input.BreakWater.Type);
@@ -69,7 +72,7 @@
AssertEqualValues(0.05, input.FlowWidthAtBottomProtection.StandardDeviation);
AssertEqualValues(7.5, input.StormDuration.Mean);
AssertEqualValues(0.25, input.StormDuration.GetVariationCoefficient());
- Assert.AreEqual(1, input.ProbabilityOpenStructureBeforeFlooding);
+ Assert.AreEqual(1.0, input.ProbabilityOpenStructureBeforeFlooding);
}
[Test]
@@ -204,23 +207,42 @@
}
[Test]
- public void Properties_StructureNormalOrientation_ExpectedValues()
+ [TestCase(360.004)]
+ [TestCase(300)]
+ [TestCase(0)]
+ [TestCase(-0.004)]
+ public void Properties_StructureNormalOrientationValidValues_NewValueSet(double orientation)
{
// Setup
var input = new ClosingStructuresInput();
- var random = new Random(22);
- var orientation = new RoundedDouble(5, random.NextDouble());
-
// Call
- input.StructureNormalOrientation = orientation;
+ input.StructureNormalOrientation = (RoundedDouble) orientation;
// Assert
Assert.AreEqual(2, input.StructureNormalOrientation.NumberOfDecimalPlaces);
AssertEqualValues(orientation, input.StructureNormalOrientation);
}
[Test]
+ [TestCase(400, 360)]
+ [TestCase(360.05, 360)]
+ [TestCase(-0.005, 0)]
+ [TestCase(-23, 0)]
+ public void Properties_StructureNormalOrientationInValidValues_ValueRoundedToValidValue(double invalidValue, double validValue)
+ {
+ // Setup
+ var input = new ClosingStructuresInput();
+
+ // Call
+ input.StructureNormalOrientation = (RoundedDouble) invalidValue;
+
+ // Assert
+ Assert.AreEqual(2, input.StructureNormalOrientation.NumberOfDecimalPlaces);
+ AssertEqualValues(validValue, input.StructureNormalOrientation);
+ }
+
+ [Test]
public void Properties_ModelFactorSuperCriticalFlow_ExpectedValues()
{
// Setup
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresInput.cs
===================================================================
diff -u -ra8ffe20fbe684f5020f5158354b33fad488baac9 -r547267b70fbf09e80c59b252b4660300cc370c74
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresInput.cs (.../HeightStructuresInput.cs) (revision a8ffe20fbe684f5020f5158354b33fad488baac9)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresInput.cs (.../HeightStructuresInput.cs) (revision 547267b70fbf09e80c59b252b4660300cc370c74)
@@ -185,6 +185,10 @@
///
/// Gets or sets the orientation of the normal of the structure.
///
+ ///
+ /// - When the value is smaller than 0, it will be set to 0.
+ /// - When the value is larger than 360, it will be set to 360.
+ ///
public RoundedDouble OrientationOfTheNormalOfTheStructure
{
get
@@ -193,10 +197,30 @@
}
set
{
- orientationOfTheNormalOfTheStructure = value.ToPrecision(orientationOfTheNormalOfTheStructure.NumberOfDecimalPlaces);
+ RoundedDouble newOrientationValue = value.ToPrecision(orientationOfTheNormalOfTheStructure.NumberOfDecimalPlaces);
+ newOrientationValue = ValidateStructureNormalOrientationInRange(newOrientationValue);
+
+ orientationOfTheNormalOfTheStructure = newOrientationValue;
}
}
+ private RoundedDouble ValidateStructureNormalOrientationInRange(RoundedDouble newOrientationValue)
+ {
+ const double upperBoundaryRange = 360;
+ const double lowerBoundaryRange = 0.0;
+
+ if (newOrientationValue > upperBoundaryRange)
+ {
+ newOrientationValue = new RoundedDouble(2, upperBoundaryRange);
+ }
+ else if (newOrientationValue < lowerBoundaryRange)
+ {
+ newOrientationValue = new RoundedDouble(2, lowerBoundaryRange);
+ }
+
+ return newOrientationValue;
+ }
+
///
/// Gets or sets the allowable increase of level for the storage.
///
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresInputTest.cs
===================================================================
diff -u -ra8ffe20fbe684f5020f5158354b33fad488baac9 -r547267b70fbf09e80c59b252b4660300cc370c74
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresInputTest.cs (.../HeightStructuresInputTest.cs) (revision a8ffe20fbe684f5020f5158354b33fad488baac9)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresInputTest.cs (.../HeightStructuresInputTest.cs) (revision 547267b70fbf09e80c59b252b4660300cc370c74)
@@ -45,6 +45,9 @@
Assert.IsInstanceOf(input);
Assert.IsNull(input.HydraulicBoundaryLocation);
+ AssertAreEqual(0, input.OrientationOfTheNormalOfTheStructure);
+ Assert.AreEqual(2, input.OrientationOfTheNormalOfTheStructure.NumberOfDecimalPlaces);
+
AssertAreEqual(0.05, input.LevelOfCrestOfStructure.StandardDeviation);
AssertAreEqual(1.1, input.ModelFactorOvertoppingSuperCriticalFlow.Mean);
AssertAreEqual(0.03, input.ModelFactorOvertoppingSuperCriticalFlow.StandardDeviation);
@@ -153,19 +156,39 @@
}
[Test]
- public void Properties_OrientationOfTheNormalOfTheStructure_ExpectedValues()
+ [TestCase(360.004)]
+ [TestCase(300)]
+ [TestCase(0)]
+ [TestCase(-0.004)]
+ public void Properties_StructureNormalOrientationValidValues_NewValueSet(double orientation)
{
// Setup
var input = new HeightStructuresInput();
- var random = new Random(22);
- RoundedDouble orientationOfTheNormalOfTheStructure = new RoundedDouble(5, random.NextDouble());
+ // Call
+ input.OrientationOfTheNormalOfTheStructure = (RoundedDouble)orientation;
+ // Assert
+ Assert.AreEqual(2, input.OrientationOfTheNormalOfTheStructure.NumberOfDecimalPlaces);
+ AssertAreEqual(orientation, input.OrientationOfTheNormalOfTheStructure);
+ }
+
+ [Test]
+ [TestCase(400, 360)]
+ [TestCase(360.05, 360)]
+ [TestCase(-0.005, 0)]
+ [TestCase(-23, 0)]
+ public void Properties_StructureNormalOrientationInValidValues_ValueRoundedToValidValue(double invalidValue, double validValue)
+ {
+ // Setup
+ var input = new HeightStructuresInput();
+
// Call
- input.OrientationOfTheNormalOfTheStructure = orientationOfTheNormalOfTheStructure;
+ input.OrientationOfTheNormalOfTheStructure = (RoundedDouble)invalidValue;
// Assert
- AssertAreEqual(orientationOfTheNormalOfTheStructure, input.OrientationOfTheNormalOfTheStructure);
+ Assert.AreEqual(2, input.OrientationOfTheNormalOfTheStructure.NumberOfDecimalPlaces);
+ AssertAreEqual(validValue, input.OrientationOfTheNormalOfTheStructure);
}
[Test]