Index: Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs =================================================================== diff -u -r1119ad16afc56bb523cac630e15fb98b1fcf8d25 -rc09b65e09c7af06495433e73530b900c46414392 --- Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 1119ad16afc56bb523cac630e15fb98b1fcf8d25) +++ Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision c09b65e09c7af06495433e73530b900c46414392) @@ -152,6 +152,15 @@ } /// + /// Looks up a localized string similar to De waarde moet tussen 0 en 1 zijn.. + /// + public static string PipingProbabilityAssessmentInput_A_Value_must_be_between_zero_and_one { + get { + return ResourceManager.GetString("PipingProbabilityAssessmentInput_A_Value_must_be_between_zero_and_one", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Vector moet 2 dimensies hebben, maar heeft er {0}.. /// public static string Point2D_AddVector_Vector_must_be_2D_but_has_Dimensionality_0_ { Index: Core/Common/src/Core.Common.Base/Properties/Resources.resx =================================================================== diff -u -r1119ad16afc56bb523cac630e15fb98b1fcf8d25 -rc09b65e09c7af06495433e73530b900c46414392 --- Core/Common/src/Core.Common.Base/Properties/Resources.resx (.../Resources.resx) (revision 1119ad16afc56bb523cac630e15fb98b1fcf8d25) +++ Core/Common/src/Core.Common.Base/Properties/Resources.resx (.../Resources.resx) (revision c09b65e09c7af06495433e73530b900c46414392) @@ -174,4 +174,7 @@ De tekst mag niet leeg zijn. + + De waarde moet tussen 0 en 1 zijn. + \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingProbabilityAssessmentInput.cs =================================================================== diff -u -rfcc734ebbc1e5c6c02ae2dae2a184fdcb9aa4d1b -rc09b65e09c7af06495433e73530b900c46414392 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingProbabilityAssessmentInput.cs (.../PipingProbabilityAssessmentInput.cs) (revision fcc734ebbc1e5c6c02ae2dae2a184fdcb9aa4d1b) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingProbabilityAssessmentInput.cs (.../PipingProbabilityAssessmentInput.cs) (revision c09b65e09c7af06495433e73530b900c46414392) @@ -19,28 +19,48 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Core.Common.Base.Properties; + namespace Ringtoets.Piping.Data { /// /// This class holds parameters which influence the probability estimate for a piping assessment. /// public class PipingProbabilityAssessmentInput { + private double a; + /// /// Creates a new instance of . /// public PipingProbabilityAssessmentInput() { - A = 1.0; - B = 350.0; + A = 0.4; + B = 300.0; SectionLength = double.NaN; } /// /// Gets 'a' parameter used to factor in the 'length effect' when determining the /// maximum tolerated probability of failure. /// - public double A { get; private set; } + public double A + { + get + { + return a; + } + set + { + if (!(value >= 0) || !(value <= 1)) + { + throw new ArgumentException(Resources.PipingProbabilityAssessmentInput_A_Value_must_be_between_zero_and_one); + } + + a = value; + } + } /// /// Gets 'b' parameter used to factor in the 'length effect' when determining the Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingFailureMechanismContextProperties.cs =================================================================== diff -u -rde8e5c0dd97c9e53a07e905a0f59617e570b2259 -rc09b65e09c7af06495433e73530b900c46414392 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingFailureMechanismContextProperties.cs (.../PipingFailureMechanismContextProperties.cs) (revision de8e5c0dd97c9e53a07e905a0f59617e570b2259) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingFailureMechanismContextProperties.cs (.../PipingFailureMechanismContextProperties.cs) (revision c09b65e09c7af06495433e73530b900c46414392) @@ -200,6 +200,11 @@ { return data.WrappedData.PipingProbabilityAssessmentInput.A; } + set + { + data.WrappedData.PipingProbabilityAssessmentInput.A = value; + data.WrappedData.NotifyObservers(); + } } [PropertyOrder(52)] Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingProbabilityAssessmentInputTest.cs =================================================================== diff -u -rfcc734ebbc1e5c6c02ae2dae2a184fdcb9aa4d1b -rc09b65e09c7af06495433e73530b900c46414392 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingProbabilityAssessmentInputTest.cs (.../PipingProbabilityAssessmentInputTest.cs) (revision fcc734ebbc1e5c6c02ae2dae2a184fdcb9aa4d1b) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingProbabilityAssessmentInputTest.cs (.../PipingProbabilityAssessmentInputTest.cs) (revision c09b65e09c7af06495433e73530b900c46414392) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using NUnit.Framework; namespace Ringtoets.Piping.Data.Test @@ -33,10 +34,46 @@ var pipingProbabilityAssessmentInput = new PipingProbabilityAssessmentInput(); // Assert - Assert.AreEqual(1.0, pipingProbabilityAssessmentInput.A); - Assert.AreEqual(350.0, pipingProbabilityAssessmentInput.B); + Assert.AreEqual(0.4, pipingProbabilityAssessmentInput.A); + Assert.AreEqual(300, pipingProbabilityAssessmentInput.B); Assert.IsNaN(pipingProbabilityAssessmentInput.SectionLength); } + + [Test] + [TestCase(-1)] + [TestCase(-0.1)] + [TestCase(1.1)] + [TestCase(8)] + public void A_InvalidValue_ThrowsArgumentException(double value) + { + // Setup + var pipingProbabilityAssessmentInput = new PipingProbabilityAssessmentInput(); + + // Call + TestDelegate call = () => pipingProbabilityAssessmentInput.A = value; + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("De waarde moet tussen 0 en 1 zijn.", exception.Message); + } + + [Test] + [TestCase(0)] + [TestCase(0.1)] + [TestCase(1)] + [TestCase(0.0000001)] + [TestCase(0.9999999)] + public void A_ValidValue_SetsValue(double value) + { + // Setup + var pipingProbabilityAssessmentInput = new PipingProbabilityAssessmentInput(); + + // Call + pipingProbabilityAssessmentInput.A = value; + + // Assert + Assert.AreEqual(value, pipingProbabilityAssessmentInput.A); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingFailureMechanismContextPropertiesTest.cs =================================================================== diff -u -rde8e5c0dd97c9e53a07e905a0f59617e570b2259 -rc09b65e09c7af06495433e73530b900c46414392 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingFailureMechanismContextPropertiesTest.cs (.../PipingFailureMechanismContextPropertiesTest.cs) (revision de8e5c0dd97c9e53a07e905a0f59617e570b2259) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingFailureMechanismContextPropertiesTest.cs (.../PipingFailureMechanismContextPropertiesTest.cs) (revision c09b65e09c7af06495433e73530b900c46414392) @@ -1,4 +1,6 @@ -using Core.Common.Gui.PropertyBag; +using System; +using Core.Common.Base; +using Core.Common.Gui.PropertyBag; using NUnit.Framework; using Rhino.Mocks; @@ -15,8 +17,6 @@ [Test] public void Constructor_ExpectedValues() { - // Setup - // Call var properties = new PipingFailureMechanismContextProperties(); @@ -55,5 +55,63 @@ Assert.AreEqual(failureMechanism.PipingProbabilityAssessmentInput.A, properties.A); Assert.AreEqual(failureMechanism.PipingProbabilityAssessmentInput.B, properties.B); } + + [Test] + [TestCase(-1)] + [TestCase(-0.1)] + [TestCase(1.1)] + [TestCase(8)] + public void A_SetInvalidValue_ThrowsArgumentException(double value) + { + // Setup + var mocks = new MockRepository(); + var observerMock = mocks.StrictMock(); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + var properties = new PipingFailureMechanismContextProperties + { + Data = new PipingFailureMechanismContext(failureMechanism, new MockRepository().StrictMock()) + }; + + // Call + TestDelegate call = () => properties.A = value; + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("De waarde moet tussen 0 en 1 zijn.", exception.Message); + Assert.AreEqual(failureMechanism.PipingProbabilityAssessmentInput.A, properties.A); + mocks.VerifyAll(); + } + + [Test] + [TestCase(0)] + [TestCase(0.1)] + [TestCase(1)] + [TestCase(0.0000001)] + [TestCase(0.9999999)] + public void A_SetValidValue_SetsValueAndUpdatesObservers(double value) + { + // Setup + var mocks = new MockRepository(); + var observerMock = mocks.StrictMock(); + observerMock.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + var properties = new PipingFailureMechanismContextProperties + { + Data = new PipingFailureMechanismContext(failureMechanism, new MockRepository().StrictMock()) + }; + + failureMechanism.Attach(observerMock); + + // Call + properties.A = value; + + // Assert + Assert.AreEqual(value, failureMechanism.PipingProbabilityAssessmentInput.A); + mocks.VerifyAll(); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingSemiProbabilisticCalculationServiceTest.cs =================================================================== diff -u -rcde435e88e283129f4d572fa0b9537a59baf72c2 -rc09b65e09c7af06495433e73530b900c46414392 --- Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingSemiProbabilisticCalculationServiceTest.cs (.../PipingSemiProbabilisticCalculationServiceTest.cs) (revision cde435e88e283129f4d572fa0b9537a59baf72c2) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingSemiProbabilisticCalculationServiceTest.cs (.../PipingSemiProbabilisticCalculationServiceTest.cs) (revision c09b65e09c7af06495433e73530b900c46414392) @@ -114,9 +114,9 @@ } [Test] - [TestCase(30000, 6000, 24, 4.916313847)] - [TestCase(20000, 6000, 12, 4.972362935)] - [TestCase(20000, 8000, 24, 4.890463519)] + [TestCase(30000, 6000, 24, 4.777)] + [TestCase(20000, 6000, 12, 4.835)] + [TestCase(20000, 8000, 24, 4.748)] public void RequiredReliability_DifferentInputs_ReturnsExpectedValue(int norm, double assessmentSectionLength, double contribution, double expectedResult) { // Setup @@ -146,7 +146,7 @@ double fosUplift = 1.2; double fosHeave = 0.6; double fosSellmeijer = 0.9; - double expectedResult = 0.881; + double expectedResult = 0.907; var calculatorResult = new PipingOutput(double.NaN, fosUplift, double.NaN, fosHeave, double.NaN, fosSellmeijer); var pipingProbabilityAssessmentInput = new PipingProbabilityAssessmentInput @@ -210,7 +210,7 @@ // Assert RoundedDouble result = pipingCalculation.SemiProbabilisticOutput.PipingFactorOfSafety; - Assert.AreEqual(0.881, result, result.GetAccuracy()); + Assert.AreEqual(0.907, result, result.GetAccuracy()); } [Test]