Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismResultView.cs =================================================================== diff -u -r4c1753252a3984c26f8d68d0a648f8206aa31536 -r3a1246401dbe3ee905bc595a9e23e184fe8f4767 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismResultView.cs (.../StabilityPointStructuresFailureMechanismResultView.cs) (revision 4c1753252a3984c26f8d68d0a648f8206aa31536) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismResultView.cs (.../StabilityPointStructuresFailureMechanismResultView.cs) (revision 3a1246401dbe3ee905bc595a9e23e184fe8f4767) @@ -125,7 +125,7 @@ nameof(StabilityPointStructuresFailureMechanismSectionResultRow.DetailedAssessmentProbability), RingtoetsCommonFormsResources.FailureMechanismResultView_DetailedAssessmentResult_DisplayName); DataGridViewControl.AddTextBoxColumn( - nameof(StabilityPointStructuresFailureMechanismSectionResultRow.AssessmentLayerThree), + nameof(StabilityPointStructuresFailureMechanismSectionResultRow.TailorMadeAssessmentProbability), RingtoetsCommonFormsResources.FailureMechanismResultView_TailorMadeAssessmentResult_DisplayName); } } Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismSectionResultRow.cs =================================================================== diff -u -r833e75c2d3d73d3b7c63ab12d44edaa3cbb09bf1 -r3a1246401dbe3ee905bc595a9e23e184fe8f4767 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismSectionResultRow.cs (.../StabilityPointStructuresFailureMechanismSectionResultRow.cs) (revision 833e75c2d3d73d3b7c63ab12d44edaa3cbb09bf1) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismSectionResultRow.cs (.../StabilityPointStructuresFailureMechanismSectionResultRow.cs) (revision 3a1246401dbe3ee905bc595a9e23e184fe8f4767) @@ -100,7 +100,7 @@ /// Thrown when /// is outside of the valid ranges. [TypeConverter(typeof(NoProbabilityValueDoubleConverter))] - public double AssessmentLayerThree + public double TailorMadeAssessmentProbability { get { @@ -109,6 +109,7 @@ set { SectionResult.TailorMadeAssessmentProbability = value; + SectionResult.NotifyObservers(); } } Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismSectionResultRowTest.cs =================================================================== diff -u -r833e75c2d3d73d3b7c63ab12d44edaa3cbb09bf1 -r3a1246401dbe3ee905bc595a9e23e184fe8f4767 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismSectionResultRowTest.cs (.../StabilityPointStructuresFailureMechanismSectionResultRowTest.cs) (revision 833e75c2d3d73d3b7c63ab12d44edaa3cbb09bf1) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismSectionResultRowTest.cs (.../StabilityPointStructuresFailureMechanismSectionResultRowTest.cs) (revision 3a1246401dbe3ee905bc595a9e23e184fe8f4767) @@ -60,12 +60,12 @@ Assert.IsInstanceOf>(row); Assert.AreEqual(result.SimpleAssessmentResult, row.SimpleAssessmentResult); Assert.AreEqual(result.GetDetailedAssessmentProbability(failureMechanism, assessmentSection), row.DetailedAssessmentProbability); - Assert.AreEqual(row.AssessmentLayerThree, result.TailorMadeAssessmentProbability); + Assert.AreEqual(row.TailorMadeAssessmentProbability, result.TailorMadeAssessmentProbability); TestHelper.AssertTypeConverter( nameof(StabilityPointStructuresFailureMechanismSectionResultRow.DetailedAssessmentProbability)); TestHelper.AssertTypeConverter( - nameof(StabilityPointStructuresFailureMechanismSectionResultRow.AssessmentLayerThree)); + nameof(StabilityPointStructuresFailureMechanismSectionResultRow.TailorMadeAssessmentProbability)); mocks.VerifyAll(); } @@ -279,26 +279,64 @@ } [Test] - public void AssessmentLayerThree_ValueSet_ReturnExpectedValue() + [TestCase(0)] + [TestCase(1)] + [TestCase(0.5)] + [TestCase(1e-6)] + [TestCase(double.NaN)] + public void TailorMadeAssessmentProbability_ValidValue_NotifyObserversAndPropertyChanged(double value) { // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); + FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var result = new StabilityPointStructuresFailureMechanismSectionResult(section); + result.Attach(observer); + + var row = new StabilityPointStructuresFailureMechanismSectionResultRow( + result, new StabilityPointStructuresFailureMechanism(), assessmentSection); + + // Call + row.TailorMadeAssessmentProbability = value; + + // Assert + Assert.AreEqual(value, row.TailorMadeAssessmentProbability); + mocks.VerifyAll(); + } + + [Test] + [SetCulture("nl-NL")] + [TestCase(-20)] + [TestCase(-1e-6)] + [TestCase(1 + 1e-6)] + [TestCase(12)] + public void TailorMadeAssessmentProbability_InvalidValue_ThrowsArgumentOutOfRangeException(double value) + { + // Setup var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var random = new Random(21); - double assessmentLayerThree = random.NextDouble(); + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); - var sectionResult = new StabilityPointStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); - var row = new StabilityPointStructuresFailureMechanismSectionResultRow(sectionResult, failureMechanism, assessmentSection); + FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var result = new StabilityPointStructuresFailureMechanismSectionResult(section); + var row = new StabilityPointStructuresFailureMechanismSectionResultRow( + result, new StabilityPointStructuresFailureMechanism(), assessmentSection); + // Call - row.AssessmentLayerThree = assessmentLayerThree; + TestDelegate test = () => row.TailorMadeAssessmentProbability = value; // Assert - Assert.AreEqual(assessmentLayerThree, sectionResult.TailorMadeAssessmentProbability); + const string expectedMessage = "De waarde voor de faalkans moet in het bereik [0,0, 1,0] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); mocks.VerifyAll(); } }