Index: Riskeer/Common/src/Riskeer.Common.Data/FailurePath/FailurePathAssemblyResult.cs =================================================================== diff -u -rf5bd7e0b6014f6f2026ea36d4ee53183cbb8a6a4 -rf021c1bffb41b07a8f60f9d96dcf2a08f9fc03cf --- Riskeer/Common/src/Riskeer.Common.Data/FailurePath/FailurePathAssemblyResult.cs (.../FailurePathAssemblyResult.cs) (revision f5bd7e0b6014f6f2026ea36d4ee53183cbb8a6a4) +++ Riskeer/Common/src/Riskeer.Common.Data/FailurePath/FailurePathAssemblyResult.cs (.../FailurePathAssemblyResult.cs) (revision f021c1bffb41b07a8f60f9d96dcf2a08f9fc03cf) @@ -19,13 +19,18 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using Riskeer.Common.Data.Probability; +using RiskeerCommonDataResources = Riskeer.Common.Data.Properties.Resources; + namespace Riskeer.Common.Data.FailurePath { /// /// Class containing the assembly result of an entire failure path. /// public class FailurePathAssemblyResult { + private double manualFailurePathAssemblyProbability; + /// /// Creates a new instance of /// @@ -43,6 +48,16 @@ /// /// Gets or sets the probability of a failure path assembly. /// - public double ManualFailurePathAssemblyProbability { get; set; } + public double ManualFailurePathAssemblyProbability + { + get => manualFailurePathAssemblyProbability; + set + { + ProbabilityHelper.ValidateProbability(value, null, + RiskeerCommonDataResources.ArbitraryProbabilityFailureMechanismSectionResult_AssessmentProbability_Value_needs_to_be_in_Range_0_, + true); + manualFailurePathAssemblyProbability = value; + } + } } } \ No newline at end of file Index: Riskeer/Common/test/Riskeer.Common.Data.Test/FailurePath/FailurePathAssemblyResultTest.cs =================================================================== diff -u -rf5bd7e0b6014f6f2026ea36d4ee53183cbb8a6a4 -rf021c1bffb41b07a8f60f9d96dcf2a08f9fc03cf --- Riskeer/Common/test/Riskeer.Common.Data.Test/FailurePath/FailurePathAssemblyResultTest.cs (.../FailurePathAssemblyResultTest.cs) (revision f5bd7e0b6014f6f2026ea36d4ee53183cbb8a6a4) +++ Riskeer/Common/test/Riskeer.Common.Data.Test/FailurePath/FailurePathAssemblyResultTest.cs (.../FailurePathAssemblyResultTest.cs) (revision f021c1bffb41b07a8f60f9d96dcf2a08f9fc03cf) @@ -19,6 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Core.Common.TestUtil; using NUnit.Framework; using Riskeer.Common.Data.FailurePath; @@ -37,5 +39,43 @@ Assert.AreEqual(FailurePathAssemblyProbabilityResultType.Automatic, result.ProbabilityResultType); Assert.IsNaN(result.ManualFailurePathAssemblyProbability); } + + [Test] + [SetCulture("nl-NL")] + [TestCase(-20)] + [TestCase(-1e-6)] + [TestCase(1 + 1e-6)] + [TestCase(12)] + public void ManualInitialFailureMechanismResultProfileProbability_InvalidValue_ThrowsArgumentOutOfRangeException(double newValue) + { + // Setup + var result = new FailurePathAssemblyResult(); + + // Call + void Call() => result.ManualFailurePathAssemblyProbability = newValue; + + // Assert + const string message = "De waarde voor de faalkans moet in het bereik [0,0, 1,0] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, message); + } + + [Test] + [TestCase(0)] + [TestCase(1e-6)] + [TestCase(0.5)] + [TestCase(1 - 1e-6)] + [TestCase(1)] + [TestCase(double.NaN)] + public void ManualInitialFailureMechanismResultProfileProbability_ValidValue_NewValueSet(double newValue) + { + // Setup + var result = new FailurePathAssemblyResult(); + + // Call + result.ManualFailurePathAssemblyProbability = newValue; + + // Assert + Assert.AreEqual(newValue, result.ManualFailurePathAssemblyProbability); + } } } \ No newline at end of file