Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresFailureMechanismSectionResult.cs
===================================================================
diff -u -r673e35de0df920529e5dda63ea8b4dfb08ed65a8 -rd9c981f7b4c64d16e55fca0cb51eb9f4c9aec28f
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresFailureMechanismSectionResult.cs (.../HeightStructuresFailureMechanismSectionResult.cs) (revision 673e35de0df920529e5dda63ea8b4dfb08ed65a8)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresFailureMechanismSectionResult.cs (.../HeightStructuresFailureMechanismSectionResult.cs) (revision d9c981f7b4c64d16e55fca0cb51eb9f4c9aec28f)
@@ -30,17 +30,12 @@
///
public class HeightStructuresFailureMechanismSectionResult : FailureMechanismSectionResult
{
- private readonly double assessmentLayerTwoA;
-
///
/// Creates a new instance of .
///
/// The to get the result from.
/// Thrown when is null.
- public HeightStructuresFailureMechanismSectionResult(FailureMechanismSection section) : base(section)
- {
- assessmentLayerTwoA = double.NaN;
- }
+ public HeightStructuresFailureMechanismSectionResult(FailureMechanismSection section) : base(section) {}
///
/// Gets the value of assessment layer two a.
@@ -49,7 +44,11 @@
{
get
{
- return assessmentLayerTwoA;
+ if (Calculation == null || !Calculation.HasOutput)
+ {
+ return double.NaN;
+ }
+ return Calculation.Output.Probability;
}
}
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresFailureMechanismSectionResultTest.cs
===================================================================
diff -u -r73597729ce18d3ee00d8036bca8341e9c12f2953 -rd9c981f7b4c64d16e55fca0cb51eb9f4c9aec28f
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresFailureMechanismSectionResultTest.cs (.../HeightStructuresFailureMechanismSectionResultTest.cs) (revision 73597729ce18d3ee00d8036bca8341e9c12f2953)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresFailureMechanismSectionResultTest.cs (.../HeightStructuresFailureMechanismSectionResultTest.cs) (revision d9c981f7b4c64d16e55fca0cb51eb9f4c9aec28f)
@@ -22,6 +22,7 @@
using Core.Common.Base.Geometry;
using NUnit.Framework;
using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.Probability;
namespace Ringtoets.HeightStructures.Data.Test
{
@@ -46,5 +47,91 @@
Assert.IsNaN(sectionResult.AssessmentLayerTwoA);
Assert.IsNull(sectionResult.Calculation);
}
+
+ [Test]
+ public void Calculation_SetNewValue_GetNewlySetValue()
+ {
+ // Setup
+ FailureMechanismSection section = CreateSection();
+
+ var result = new HeightStructuresFailureMechanismSectionResult(section);
+
+ var calculation = new HeightStructuresCalculation();
+
+ // Call
+ result.Calculation = calculation;
+
+ // Assert
+ Assert.AreSame(calculation, result.Calculation);
+ }
+
+ [Test]
+ public void AssessmentLayerTwoA_CalculationNull_ReturnNaN()
+ {
+ // Setup
+ FailureMechanismSection section = CreateSection();
+
+ var result = new HeightStructuresFailureMechanismSectionResult(section)
+ {
+ Calculation = null
+ };
+
+ // Call
+ double twoAValue = result.AssessmentLayerTwoA;
+
+ // Assert
+ Assert.IsNaN(twoAValue);
+ }
+
+ [Test]
+ public void AssessmentLayerTwoA_FailedCalculation_ReturnNaN()
+ {
+ // Setup
+ FailureMechanismSection section = CreateSection();
+
+ var result = new HeightStructuresFailureMechanismSectionResult(section)
+ {
+ Calculation = new HeightStructuresCalculation
+ {
+ Output = new ProbabilityAssessmentOutput(1.0, 1.0, double.NaN, 1.0, 1.0)
+ }
+ };
+
+ // Call
+ double twoAValue = result.AssessmentLayerTwoA;
+
+ // Assert
+ Assert.IsNaN(twoAValue);
+ }
+
+ [Test]
+ public void AssessmentLayerTwoA_SuccessfulCalculation_ReturnProbability()
+ {
+ // Setup
+ FailureMechanismSection section = CreateSection();
+
+ double probability = 0.65;
+ var result = new HeightStructuresFailureMechanismSectionResult(section)
+ {
+ Calculation = new HeightStructuresCalculation
+ {
+ Output = new ProbabilityAssessmentOutput(1.0, 1.0, probability, 1.0, 1.0)
+ }
+ };
+
+ // Call
+ double twoAValue = result.AssessmentLayerTwoA;
+
+ // Assert
+ Assert.AreEqual(probability, twoAValue);
+ }
+
+ private static FailureMechanismSection CreateSection()
+ {
+ return new FailureMechanismSection("Section", new[]
+ {
+ new Point2D(0, 0)
+ });
+ }
}
}
\ No newline at end of file