Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismSectionResultRow.cs =================================================================== diff -u -r65f8729394c33c64e1df467388d39e40f2d7e8ff -r9056f2d94b44d294f525e1b574a1bae59cb623f1 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismSectionResultRow.cs (.../ClosingStructuresFailureMechanismSectionResultRow.cs) (revision 65f8729394c33c64e1df467388d39e40f2d7e8ff) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismSectionResultRow.cs (.../ClosingStructuresFailureMechanismSectionResultRow.cs) (revision 9056f2d94b44d294f525e1b574a1bae59cb623f1) @@ -181,6 +181,41 @@ } /// + /// Gets or sets the indicator whether the combined assembly probability + /// should be overwritten by . + /// + public bool UseManualAssemblyProbability + { + get + { + return SectionResult.UseManualAssemblyProbability; + } + set + { + SectionResult.UseManualAssemblyProbability = value; + UpdateInternalData(); + } + } + + /// + /// Gets or sets the manually entered assembly probability. + /// + /// Thrown when is + /// not in the range [0,1]. + public double ManualAssemblyProbability + { + get + { + return SectionResult.ManualAssemblyProbability; + } + set + { + SectionResult.ManualAssemblyProbability = value; + UpdateInternalData(); + } + } + + /// /// Gets the of the wrapped /// . /// Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismSectionResultRowTest.cs =================================================================== diff -u -r65f8729394c33c64e1df467388d39e40f2d7e8ff -r9056f2d94b44d294f525e1b574a1bae59cb623f1 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismSectionResultRowTest.cs (.../ClosingStructuresFailureMechanismSectionResultRowTest.cs) (revision 65f8729394c33c64e1df467388d39e40f2d7e8ff) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismSectionResultRowTest.cs (.../ClosingStructuresFailureMechanismSectionResultRowTest.cs) (revision 9056f2d94b44d294f525e1b574a1bae59cb623f1) @@ -155,6 +155,106 @@ } [Test] + public void UseManualAssemblyProbability_SetNewValue_NotifyObserversAndPropertyChanged() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var result = new ClosingStructuresFailureMechanismSectionResult(section); + result.Attach(observer); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var row = new ClosingStructuresFailureMechanismSectionResultRow( + result, new ClosingStructuresFailureMechanism(), assessmentSection); + bool originalValue = result.UseManualAssemblyProbability; + bool newValue = !originalValue; + + // Call + row.UseManualAssemblyProbability = newValue; + + // Assert + Assert.AreEqual(newValue, result.UseManualAssemblyProbability); + mocks.VerifyAll(); + } + } + + [Test] + [TestCase(0)] + [TestCase(1)] + [TestCase(0.5)] + [TestCase(1e-6)] + [TestCase(double.NaN)] + public void ManualAssemblyProbability_ValidValue_NotifyObserversAndPropertyChanged(double value) + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var result = new ClosingStructuresFailureMechanismSectionResult(section); + result.Attach(observer); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var row = new ClosingStructuresFailureMechanismSectionResultRow( + result, new ClosingStructuresFailureMechanism(), assessmentSection); + + // Call + row.ManualAssemblyProbability = value; + + // Assert + Assert.AreEqual(value, row.ManualAssemblyProbability); + mocks.VerifyAll(); + } + } + + [Test] + [SetCulture("nl-NL")] + [TestCase(-20)] + [TestCase(-1e-6)] + [TestCase(1 + 1e-6)] + [TestCase(12)] + public void ManualAssemblyProbability_InvalidValue_ThrowsArgumentOutOfRangeException(double value) + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var result = new ClosingStructuresFailureMechanismSectionResult(section); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var row = new ClosingStructuresFailureMechanismSectionResultRow( + result, new ClosingStructuresFailureMechanism(), assessmentSection); + + // Call + TestDelegate test = () => row.ManualAssemblyProbability = value; + + // Assert + const string expectedMessage = "De waarde voor de faalkans moet in het bereik [0,0, 1,0] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + mocks.VerifyAll(); + } + } + + [Test] public void SimpleAssessmentResult_AlwaysOnChange_NotifyObserversOfResultAndResultPropertyChanged() { // Setup