Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismSectionResultRowTest.cs =================================================================== diff -u -rfe1332c1e9b14365a62f6ce03c9494393223179e -racb9db836c6b6cdd639842b4cb559cec5141ba8a --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismSectionResultRowTest.cs (.../ClosingStructuresFailureMechanismSectionResultRowTest.cs) (revision fe1332c1e9b14365a62f6ce03c9494393223179e) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismSectionResultRowTest.cs (.../ClosingStructuresFailureMechanismSectionResultRowTest.cs) (revision acb9db836c6b6cdd639842b4cb559cec5141ba8a) @@ -24,7 +24,10 @@ using NUnit.Framework; using Ringtoets.ClosingStructures.Data; using Ringtoets.ClosingStructures.Forms.Views; +using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Probability; +using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Forms.TypeConverters; using Ringtoets.Common.Forms.Views; using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; @@ -52,6 +55,116 @@ r => r.AssessmentLayerTwoA)); } + [Test] + public void AssessmentLayerTwoA_NoCalculationSet_ReturnNaN() + { + // Setup + FailureMechanismSection section = CreateSection(); + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(section); + + // Precondition + Assert.IsNull(sectionResult.Calculation); + + var resultRow = new ClosingStructuresFailureMechanismSectionResultRow(sectionResult); + + // Call + double assessmentLayerTwoA = resultRow.AssessmentLayerTwoA; + + // Assert + Assert.IsNaN(assessmentLayerTwoA); + } + + [Test] + [TestCase(CalculationScenarioStatus.Failed)] + [TestCase(CalculationScenarioStatus.NotCalculated)] + public void AssessmentLayerTwoA_CalculationNotDone_ReturnNaN(CalculationScenarioStatus status) + { + // Setup + var calculation = new StructuresCalculation(); + if (status == CalculationScenarioStatus.Failed) + { + calculation.Output = new ProbabilityAssessmentOutput(0.9, 1.0, double.NaN, 1.0, 1.0); + } + + FailureMechanismSection section = CreateSection(); + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(section) + { + Calculation = calculation + }; + + var resultRow = new ClosingStructuresFailureMechanismSectionResultRow(sectionResult); + + // Call + double assessmentLayerTwoA = resultRow.AssessmentLayerTwoA; + + // Assert + Assert.IsNaN(assessmentLayerTwoA); + } + + [Test] + public void AssessmentLayerTwoA_CalculationSuccessful_ReturnAssessmentLayerTwoA() + { + // Setup + var calculation = new StructuresCalculation + { + Output = new ProbabilityAssessmentOutput(0.9, 1.0, 0.95, 1.0, 1.0) + }; + + FailureMechanismSection section = CreateSection(); + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(section) + { + Calculation = calculation + }; + + var resultRow = new ClosingStructuresFailureMechanismSectionResultRow(sectionResult); + + // Call + double assessmentLayerTwoA = resultRow.AssessmentLayerTwoA; + + // Assert + Assert.AreEqual(calculation.Output.Probability, assessmentLayerTwoA); + } + + [Test] + public void GetSectionResultCalculation_NoCalculationSetOnSectionResult_ReturnNull() + { + // Setup + FailureMechanismSection section = CreateSection(); + var result = new ClosingStructuresFailureMechanismSectionResult(section); + + // Precondition + Assert.IsNull(result.Calculation); + + var row = new ClosingStructuresFailureMechanismSectionResultRow(result); + + // Call + StructuresCalculation calculation = row.GetSectionResultCalculation(); + + // Assert + Assert.IsNull(calculation); + } + + [Test] + public void GetSectionResultCalculation_WithCalculationSetOnSectionResult_ReturnCalculation() + { + // Setup + var expectedCalculation = new StructuresCalculation(); + + FailureMechanismSection section = CreateSection(); + var result = new ClosingStructuresFailureMechanismSectionResult(section) + { + Calculation = expectedCalculation + }; + + var row = new ClosingStructuresFailureMechanismSectionResultRow(result); + + // Call + StructuresCalculation calculation = row.GetSectionResultCalculation(); + + // Assert + Assert.AreSame(expectedCalculation, calculation); + } + private static FailureMechanismSection CreateSection() { return new FailureMechanismSection("name", new[]