Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensions.cs =================================================================== diff -u -r3fad85f24665fdcfe75cba4e2f9ab30c2ca6a4b6 -rfe1332c1e9b14365a62f6ce03c9494393223179e --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensions.cs (.../ClosingStructuresSectionResultEntityReadExtensions.cs) (revision 3fad85f24665fdcfe75cba4e2f9ab30c2ca6a4b6) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensions.cs (.../ClosingStructuresSectionResultEntityReadExtensions.cs) (revision fe1332c1e9b14365a62f6ce03c9494393223179e) @@ -48,7 +48,6 @@ } sectionResult.AssessmentLayerOne = Convert.ToBoolean(entity.LayerOne); - sectionResult.AssessmentLayerTwoA = (RoundedDouble) entity.LayerTwoA.ToNullAsNaN(); sectionResult.AssessmentLayerThree = (RoundedDouble) entity.LayerThree.ToNullAsNaN(); } } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u -r3fad85f24665fdcfe75cba4e2f9ab30c2ca6a4b6 -rfe1332c1e9b14365a62f6ce03c9494393223179e --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs (.../ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs) (revision 3fad85f24665fdcfe75cba4e2f9ab30c2ca6a4b6) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs (.../ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs) (revision fe1332c1e9b14365a62f6ce03c9494393223179e) @@ -48,14 +48,12 @@ [Test] public void Create_WithDifferentResults_ReturnsEntityWithExpectedResults( [Values(true, false)] bool assessmentLayerOneResult, - [Values(0.2, 0.523)] double assessmentLayerTwoAResult, [Values(3.2, 4.5)] double assessmentLayerThreeResult) { // Setup var sectionResult = new ClosingStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()) { AssessmentLayerOne = assessmentLayerOneResult, - AssessmentLayerTwoA = (RoundedDouble) assessmentLayerTwoAResult, AssessmentLayerThree = (RoundedDouble) assessmentLayerThreeResult }; @@ -64,27 +62,10 @@ // Assert Assert.AreEqual(Convert.ToByte(assessmentLayerOneResult), result.LayerOne); - Assert.AreEqual(assessmentLayerTwoAResult, result.LayerTwoA); Assert.AreEqual(assessmentLayerThreeResult, result.LayerThree); } [Test] - public void Create_WithNaNLevel2aResult_ReturnsEntityWithExpectedResults() - { - // Setup - var sectionResult = new ClosingStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - AssessmentLayerTwoA = (RoundedDouble) double.NaN - }; - - // Call - var result = sectionResult.Create(new PersistenceRegistry()); - - // Assert - Assert.IsNull(result.LayerTwoA); - } - - [Test] public void Create_WithNaNLevel3Result_ReturnsEntityWithExpectedResults() { // Setup Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u -r3fad85f24665fdcfe75cba4e2f9ab30c2ca6a4b6 -rfe1332c1e9b14365a62f6ce03c9494393223179e --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensionsTest.cs (.../ClosingStructuresSectionResultEntityReadExtensionsTest.cs) (revision 3fad85f24665fdcfe75cba4e2f9ab30c2ca6a4b6) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensionsTest.cs (.../ClosingStructuresSectionResultEntityReadExtensionsTest.cs) (revision fe1332c1e9b14365a62f6ce03c9494393223179e) @@ -55,15 +55,13 @@ // Setup var random = new Random(21); double layerThree = random.NextDouble(); - double layerTwoA = random.NextDouble(); var collector = new ReadConversionCollector(); var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); var entity = new ClosingStructuresSectionResultEntity { LayerThree = layerThree, - LayerTwoA = layerTwoA, LayerOne = Convert.ToByte(layerOne), FailureMechanismSectionEntity = failureMechanismSectionEntity }; @@ -75,7 +73,6 @@ // Assert Assert.IsNotNull(sectionResult); Assert.AreEqual(layerOne, sectionResult.AssessmentLayerOne); - Assert.AreEqual(layerTwoA, sectionResult.AssessmentLayerTwoA, 1e-6); Assert.AreEqual(layerThree, sectionResult.AssessmentLayerThree, 1e-6); } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs =================================================================== diff -u -r531a5378e2e0c670c8e4bc361765d5d63f429a62 -rfe1332c1e9b14365a62f6ce03c9494393223179e --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs (.../RingtoetsProjectTestHelper.cs) (revision 531a5378e2e0c670c8e4bc361765d5d63f429a62) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs (.../RingtoetsProjectTestHelper.cs) (revision fe1332c1e9b14365a62f6ce03c9494393223179e) @@ -193,7 +193,6 @@ foreach (var sectionResult in sectionResults) { sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); - sectionResult.AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(); sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); } } Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresFailureMechanismSectionResult.cs =================================================================== diff -u -r73597729ce18d3ee00d8036bca8341e9c12f2953 -rfe1332c1e9b14365a62f6ce03c9494393223179e --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresFailureMechanismSectionResult.cs (.../ClosingStructuresFailureMechanismSectionResult.cs) (revision 73597729ce18d3ee00d8036bca8341e9c12f2953) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresFailureMechanismSectionResult.cs (.../ClosingStructuresFailureMechanismSectionResult.cs) (revision fe1332c1e9b14365a62f6ce03c9494393223179e) @@ -21,7 +21,6 @@ using System; using Ringtoets.Common.Data.FailureMechanism; -using Ringtoets.Common.Data.Properties; namespace Ringtoets.ClosingStructures.Data { @@ -31,39 +30,29 @@ /// public class ClosingStructuresFailureMechanismSectionResult : FailureMechanismSectionResult { - private double assessmentLayerTwoA; - /// /// Creates a new instance of . /// /// The for which the /// will hold the result. /// Thrown when is null. - public ClosingStructuresFailureMechanismSectionResult(FailureMechanismSection section) : base(section) - { - AssessmentLayerTwoA = double.NaN; - } + public ClosingStructuresFailureMechanismSectionResult(FailureMechanismSection section) : base(section) {} /// - /// Gets or sets the value for the detailed assessment of safety per failure mechanism section as a probability. + /// Gets the value for the detailed assessment of safety per failure mechanism section as a probability. /// - /// Thrown when is not in range [0,1]. public double AssessmentLayerTwoA { get { - return assessmentLayerTwoA; - } - set - { - if (!double.IsNaN(value) && (value < 0 || value > 1)) + if (Calculation == null || !Calculation.HasOutput) { - throw new ArgumentException(Resources.ArbitraryProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1); + return double.NaN; } - assessmentLayerTwoA = value; + return Calculation.Output.Probability; } } - + /// /// Gets or sets the , which is chosen /// to be representative for the whole section. Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismSectionResultRow.cs =================================================================== diff -u -r673e35de0df920529e5dda63ea8b4dfb08ed65a8 -rfe1332c1e9b14365a62f6ce03c9494393223179e --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismSectionResultRow.cs (.../ClosingStructuresFailureMechanismSectionResultRow.cs) (revision 673e35de0df920529e5dda63ea8b4dfb08ed65a8) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismSectionResultRow.cs (.../ClosingStructuresFailureMechanismSectionResultRow.cs) (revision fe1332c1e9b14365a62f6ce03c9494393223179e) @@ -43,19 +43,13 @@ /// /// Gets the assessment layer two a of the . /// - /// Thrown when is - /// not in the range [0,1]. [TypeConverter(typeof(FailureMechanismSectionResultNoProbabilityValueDoubleConverter))] public double AssessmentLayerTwoA { get { return SectionResult.AssessmentLayerTwoA; } - set - { - SectionResult.AssessmentLayerTwoA = value; - } } } } \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresFailureMechanismSectionResultTest.cs =================================================================== diff -u -r73597729ce18d3ee00d8036bca8341e9c12f2953 -rfe1332c1e9b14365a62f6ce03c9494393223179e --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresFailureMechanismSectionResultTest.cs (.../ClosingStructuresFailureMechanismSectionResultTest.cs) (revision 73597729ce18d3ee00d8036bca8341e9c12f2953) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresFailureMechanismSectionResultTest.cs (.../ClosingStructuresFailureMechanismSectionResultTest.cs) (revision fe1332c1e9b14365a62f6ce03c9494393223179e) @@ -19,11 +19,10 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using Core.Common.Base.Geometry; using NUnit.Framework; using Ringtoets.Common.Data.FailureMechanism; -using Ringtoets.Common.Data.Properties; +using Ringtoets.Common.Data.Probability; namespace Ringtoets.ClosingStructures.Data.Test { @@ -47,45 +46,83 @@ } [Test] - [TestCase(-20)] - [TestCase(-1e-6)] - [TestCase(1 + 1e-6)] - [TestCase(12)] - public void AssessmentLayerTwoA_ForInvalidValues_ThrowsException(double newValue) + public void Calculation_SetNewValue_GetNewlySetValue() { // Setup FailureMechanismSection section = CreateSection(); + var result = new ClosingStructuresFailureMechanismSectionResult(section); + var calculation = new ClosingStructuresCalculation(); + // Call - TestDelegate test = () => result.AssessmentLayerTwoA = newValue; + result.Calculation = calculation; // Assert - var message = Assert.Throws(test).Message; - Assert.AreEqual( - Resources.ArbitraryProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1, - message); + Assert.AreSame(calculation, result.Calculation); } [Test] - [TestCase(0)] - [TestCase(1e-6)] - [TestCase(0.5)] - [TestCase(1 - 1e-6)] - [TestCase(1)] - public void AssessmentLayerTwoA_ForValidValues_NewValueSet(double newValue) + public void AssessmentLayerTwoA_CalculationNull_ReturnNaN() { // Setup FailureMechanismSection section = CreateSection(); - var result = new ClosingStructuresFailureMechanismSectionResult(section); + var result = new ClosingStructuresFailureMechanismSectionResult(section) + { + Calculation = null + }; + // Call - result.AssessmentLayerTwoA = newValue; + double twoAValue = result.AssessmentLayerTwoA; // Assert - Assert.AreEqual(newValue, result.AssessmentLayerTwoA); + Assert.IsNaN(twoAValue); } + [Test] + public void AssessmentLayerTwoA_FailedCalculation_ReturnNaN() + { + // Setup + FailureMechanismSection section = CreateSection(); + + var result = new ClosingStructuresFailureMechanismSectionResult(section) + { + Calculation = new ClosingStructuresCalculation + { + 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 ClosingStructuresFailureMechanismSectionResult(section) + { + Calculation = new ClosingStructuresCalculation + { + 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[] Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismResultViewTest.cs =================================================================== diff -u -r5b1276bcb70296a150fd4a26fbf8867e6f8aa0f2 -rfe1332c1e9b14365a62f6ce03c9494393223179e --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismResultViewTest.cs (.../ClosingStructuresFailureMechanismResultViewTest.cs) (revision 5b1276bcb70296a150fd4a26fbf8867e6f8aa0f2) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismResultViewTest.cs (.../ClosingStructuresFailureMechanismResultViewTest.cs) (revision fe1332c1e9b14365a62f6ce03c9494393223179e) @@ -93,13 +93,11 @@ var result1 = new ClosingStructuresFailureMechanismSectionResult(section1) { AssessmentLayerOne = true, - AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), AssessmentLayerThree = (RoundedDouble) random.NextDouble() }; var result2 = new ClosingStructuresFailureMechanismSectionResult(section2) { AssessmentLayerOne = false, - AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), AssessmentLayerThree = (RoundedDouble) random.NextDouble() }; @@ -125,9 +123,8 @@ Assert.AreEqual(4, cells.Count); Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue); Assert.AreEqual(result1.AssessmentLayerOne, cells[assessmentLayerOneIndex].Value); - var expectedAssessmentLayer2AString1 = ProbabilityFormattingHelper.Format(result1.AssessmentLayerTwoA); - Assert.AreEqual(expectedAssessmentLayer2AString1, cells[assessmentLayerTwoAIndex].FormattedValue); + Assert.AreEqual("-", cells[assessmentLayerTwoAIndex].FormattedValue); Assert.AreEqual(result1.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); @@ -137,11 +134,10 @@ Assert.AreEqual(4, cells.Count); Assert.AreEqual("Section 2", cells[nameColumnIndex].FormattedValue); Assert.AreEqual(result2.AssessmentLayerOne, cells[assessmentLayerOneIndex].Value); - var expectedAssessmentLayer2AString2 = ProbabilityFormattingHelper.Format(result2.AssessmentLayerTwoA); - Assert.AreEqual(expectedAssessmentLayer2AString2, cells[assessmentLayerTwoAIndex].FormattedValue); + Assert.AreEqual("-", cells[assessmentLayerTwoAIndex].FormattedValue); Assert.AreEqual(result2.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); - AssertCellIsEnabled(cells[assessmentLayerTwoAIndex]); + AssertCellIsEnabled(cells[assessmentLayerTwoAIndex], true); AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); } } @@ -158,7 +154,6 @@ var result = new ClosingStructuresFailureMechanismSectionResult(section) { AssessmentLayerOne = false, - AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), AssessmentLayerThree = (RoundedDouble) random.NextDouble() }; using (var form = new Form()) @@ -231,9 +226,9 @@ Assert.AreEqual(Color.FromKnownColor(KnownColor.DarkGray), dataGridViewCell.Style.BackColor); } - private static void AssertCellIsEnabled(DataGridViewCell dataGridViewCell) + private static void AssertCellIsEnabled(DataGridViewCell dataGridViewCell, bool readOnly = false) { - Assert.AreEqual(false, dataGridViewCell.ReadOnly); + Assert.AreEqual(readOnly, dataGridViewCell.ReadOnly); Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), dataGridViewCell.Style.ForeColor); Assert.AreEqual(Color.FromKnownColor(KnownColor.White), dataGridViewCell.Style.BackColor); } Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismSectionResultRowTest.cs =================================================================== diff -u -r673e35de0df920529e5dda63ea8b4dfb08ed65a8 -rfe1332c1e9b14365a62f6ce03c9494393223179e --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismSectionResultRowTest.cs (.../ClosingStructuresFailureMechanismSectionResultRowTest.cs) (revision 673e35de0df920529e5dda63ea8b4dfb08ed65a8) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismSectionResultRowTest.cs (.../ClosingStructuresFailureMechanismSectionResultRowTest.cs) (revision fe1332c1e9b14365a62f6ce03c9494393223179e) @@ -19,7 +19,6 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using Core.Common.Base.Geometry; using Core.Common.Utils.Reflection; using NUnit.Framework; @@ -53,47 +52,6 @@ r => r.AssessmentLayerTwoA)); } - [Test] - [TestCase(0)] - [TestCase(1)] - [TestCase(0.5)] - [TestCase(1e-6)] - public void AssessmentLayerTwoA_ForValidValues_ResultPropertyChanged(double value) - { - // Setup - FailureMechanismSection section = CreateSection(); - var result = new ClosingStructuresFailureMechanismSectionResult(section); - var row = new ClosingStructuresFailureMechanismSectionResultRow(result); - - // Call - row.AssessmentLayerTwoA = value; - - // Assert - Assert.AreEqual(value, row.AssessmentLayerTwoA); - } - - [Test] - [TestCase(-20)] - [TestCase(-1e-6)] - [TestCase(1 + 1e-6)] - [TestCase(12)] - public void AssessmentLayerTwoA_ForInvalidValues_ThrowsArgumentException(double value) - { - // Setup - FailureMechanismSection section = CreateSection(); - var result = new ClosingStructuresFailureMechanismSectionResult(section); - var row = new ClosingStructuresFailureMechanismSectionResultRow(result); - - // Call - TestDelegate test = () => row.AssessmentLayerTwoA = value; - - // Assert - var message = Assert.Throws(test).Message; - Assert.AreEqual( - RingtoetsCommonDataResources.ArbitraryProbabilityFailureMechanismSectionResult_AssessmentLayerTwoA_Value_needs_to_be_between_0_and_1, - message); - } - private static FailureMechanismSection CreateSection() { return new FailureMechanismSection("name", new[]