Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Util/GrassCoverErosionInwardsIllustrationPointsHelper.cs
===================================================================
diff -u -rbb831b80442c0389546ce12572e24c795e0f6df6 -rb72098cbe278bd5b985a370cff6491c5c353fc7e
--- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Util/GrassCoverErosionInwardsIllustrationPointsHelper.cs (.../GrassCoverErosionInwardsIllustrationPointsHelper.cs) (revision bb831b80442c0389546ce12572e24c795e0f6df6)
+++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Util/GrassCoverErosionInwardsIllustrationPointsHelper.cs (.../GrassCoverErosionInwardsIllustrationPointsHelper.cs) (revision b72098cbe278bd5b985a370cff6491c5c353fc7e)
@@ -65,21 +65,68 @@
return calculations.Any(HasIllustrationPoints);
}
- private static bool HasIllustrationPoints(GrassCoverErosionInwardsOutput output)
+ ///
+ /// Determines whether a
+ /// has overtopping illustration point results.
+ ///
+ /// The output to check.
+ /// true when has overtopping illustration point results,
+ /// false otherwise.
+ /// Thrown when
+ /// is null.
+ public static bool HasOverToppingIllustrationPoints(GrassCoverErosionInwardsOutput output)
{
- return output.OvertoppingOutput.HasGeneralResult
- || HasDikeHeightOutputWithIllustrationPoints(output)
- || HasOverToppingRateOutputWithIllustrationPoints(output);
+ if (output == null)
+ {
+ throw new ArgumentNullException(nameof(output));
+ }
+
+ return output.OvertoppingOutput.HasGeneralResult;
}
- private static bool HasOverToppingRateOutputWithIllustrationPoints(GrassCoverErosionInwardsOutput output)
+ ///
+ /// Determines whether a
+ /// has overtopping dike height with illustration point results.
+ ///
+ /// The output to check.
+ /// true when has dike height output with illustration point results,
+ /// false otherwise.
+ /// Thrown when
+ /// is null.
+ public static bool HasDikeHeightOutputWithIllustrationPoints(GrassCoverErosionInwardsOutput output)
{
+ if (output == null)
+ {
+ throw new ArgumentNullException(nameof(output));
+ }
+
+ return output.DikeHeightOutput != null && output.DikeHeightOutput.HasGeneralResult;
+ }
+
+ ///
+ /// Determines whether a
+ /// has overtopping rate output with illustration point results.
+ ///
+ /// The output to check.
+ /// true when has overtopping rate output with illustration point results,
+ /// false otherwise.
+ /// Thrown when
+ /// is null.
+ public static bool HasOverToppingRateOutputWithIllustrationPoints(GrassCoverErosionInwardsOutput output)
+ {
+ if (output == null)
+ {
+ throw new ArgumentNullException(nameof(output));
+ }
+
return output.OvertoppingRateOutput != null && output.OvertoppingRateOutput.HasGeneralResult;
}
- private static bool HasDikeHeightOutputWithIllustrationPoints(GrassCoverErosionInwardsOutput output)
+ private static bool HasIllustrationPoints(GrassCoverErosionInwardsOutput output)
{
- return output.DikeHeightOutput != null && output.DikeHeightOutput.HasGeneralResult;
+ return HasOverToppingIllustrationPoints(output)
+ || HasDikeHeightOutputWithIllustrationPoints(output)
+ || HasOverToppingRateOutputWithIllustrationPoints(output);
}
}
}
\ No newline at end of file
Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Util.Test/GrassCoverErosionInwardsIllustrationPointsHelperTest.cs
===================================================================
diff -u -r910cba21727c0cdc02a1310341784a227db32f53 -rb72098cbe278bd5b985a370cff6491c5c353fc7e
--- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Util.Test/GrassCoverErosionInwardsIllustrationPointsHelperTest.cs (.../GrassCoverErosionInwardsIllustrationPointsHelperTest.cs) (revision 910cba21727c0cdc02a1310341784a227db32f53)
+++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Util.Test/GrassCoverErosionInwardsIllustrationPointsHelperTest.cs (.../GrassCoverErosionInwardsIllustrationPointsHelperTest.cs) (revision b72098cbe278bd5b985a370cff6491c5c353fc7e)
@@ -80,6 +80,120 @@
Assert.AreEqual(expectedHasIllustrationPoints, hasIllustrationPoints);
}
+ [Test]
+ public void HasOverToppingIllustrationPoints_OutputNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => GrassCoverErosionInwardsIllustrationPointsHelper.HasOverToppingIllustrationPoints(null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("output", exception.ParamName);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void HasOverToppingIllustrationPoints_WithOrWithoutIllustrationPoints_ReturnsExpectedResult(bool expectedHasIllustrationPoints)
+ {
+ // Setup
+ var output = new TestGrassCoverErosionInwardsOutput(
+ expectedHasIllustrationPoints
+ ? new TestGeneralResultFaultTreeIllustrationPoint()
+ : null);
+
+ // Call
+ bool hasIllustrationPoints = GrassCoverErosionInwardsIllustrationPointsHelper.HasOverToppingIllustrationPoints(output);
+
+ // Assert
+ Assert.AreEqual(expectedHasIllustrationPoints, hasIllustrationPoints);
+ }
+
+ [Test]
+ public void HasDikeHeightOutputWithIllustrationPoints_OutputNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => GrassCoverErosionInwardsIllustrationPointsHelper.HasDikeHeightOutputWithIllustrationPoints(null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("output", exception.ParamName);
+ }
+
+ [Test]
+ public void HasDikeHeightOutputWithIllustrationPoints_DikeHeightOutputNull_ReturnsFalse()
+ {
+ // Setup
+ var output = new GrassCoverErosionInwardsOutput(new TestOvertoppingOutput(0.1), null,
+ new TestOvertoppingRateOutput(0.2));
+ // Call
+ bool hasIllustrationPoints = GrassCoverErosionInwardsIllustrationPointsHelper.HasDikeHeightOutputWithIllustrationPoints(output);
+
+ // Assert
+ Assert.IsFalse(hasIllustrationPoints);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void HasDikeHeightOutputWithIllustrationPoints_WithOrWithoutIllustrationPoints_ReturnsExpectedResult(bool expectedHasIllustrationPoints)
+ {
+ // Setup
+ var output = new TestGrassCoverErosionInwardsOutput(
+ expectedHasIllustrationPoints
+ ? new TestGeneralResultFaultTreeIllustrationPoint()
+ : null);
+
+ // Call
+ bool hasIllustrationPoints = GrassCoverErosionInwardsIllustrationPointsHelper.HasDikeHeightOutputWithIllustrationPoints(output);
+
+ // Assert
+ Assert.AreEqual(expectedHasIllustrationPoints, hasIllustrationPoints);
+ }
+
+ [Test]
+ public void HasOverToppingRateOutputWithIllustrationPoints_OutputNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => GrassCoverErosionInwardsIllustrationPointsHelper.HasOverToppingRateOutputWithIllustrationPoints(null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("output", exception.ParamName);
+ }
+
+ [Test]
+ public void HasOverToppingRateOutputWithIllustrationPoints_OvertoppingRateOutputNull_ReturnsFalse()
+ {
+ // Setup
+ var output = new GrassCoverErosionInwardsOutput(
+ new TestOvertoppingOutput(0.1), new TestDikeHeightOutput(0.2), null);
+
+ // Call
+ bool hasIllustrationPoints = GrassCoverErosionInwardsIllustrationPointsHelper.HasOverToppingRateOutputWithIllustrationPoints(output);
+
+ // Assert
+ Assert.IsFalse(hasIllustrationPoints);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void HasOverToppingRateOutputWithIllustrationPoints_WithOrWithoutIllustrationPoints_ReturnsExpectedResult(bool expectedHasIllustrationPoints)
+ {
+ // Setup
+ var output = new TestGrassCoverErosionInwardsOutput(
+ expectedHasIllustrationPoints
+ ? new TestGeneralResultFaultTreeIllustrationPoint()
+ : null);
+
+ // Call
+ bool hasIllustrationPoints = GrassCoverErosionInwardsIllustrationPointsHelper.HasOverToppingRateOutputWithIllustrationPoints(output);
+
+ // Assert
+ Assert.AreEqual(expectedHasIllustrationPoints, hasIllustrationPoints);
+ }
+
private static IEnumerable GetCalculationCollectionConfigurations()
{
foreach (TestCaseData configuration in GetCalculationConfigurations())