Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingFailureMechanismSectionResultTest.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingFailureMechanismSectionResultTest.cs (.../PipingFailureMechanismSectionResultTest.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingFailureMechanismSectionResultTest.cs (.../PipingFailureMechanismSectionResultTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -19,9 +19,13 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Core.Common.Base.Data; using Core.Common.Base.Geometry; +using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; namespace Ringtoets.Piping.Data.Test { @@ -32,18 +36,61 @@ public void Constructor_WithParameters_ExpectedValues() { // Setup - var section = new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - }); + FailureMechanismSection section = CreateSection(); // Call var sectionResult = new PipingFailureMechanismSectionResult(section); // Assert Assert.IsInstanceOf(sectionResult); Assert.AreSame(section, sectionResult.Section); + Assert.IsNaN(sectionResult.AssessmentLayerThree); Assert.IsNaN(sectionResult.GetAssessmentLayerTwoA(new PipingCalculationScenario[0])); } + + [Test] + [TestCase(double.NegativeInfinity)] + [TestCase(double.PositiveInfinity)] + [TestCase(1.1)] + [TestCase(-0.1)] + public void AssessmentLayerThree_SetInvalidValue_ThrowsArgumentOutOfRangeException(double invalidValue) + { + // Setup + var sectionResult = new PipingFailureMechanismSectionResult(CreateSection()); + + // Call + TestDelegate call = () => sectionResult.AssessmentLayerThree = (RoundedDouble) invalidValue; + + // Assert + const string expectedMessage = "Kans moet in het bereik [0.0, 1.0] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, + expectedMessage); + } + + [Test] + [TestCase(double.NaN)] + [TestCase(0)] + [TestCase(1)] + [TestCase(0.5)] + public void AssessmentLayerThree_SetValidValue_SetsValue(double validValue) + { + // Setup + var sectionResult = new PipingFailureMechanismSectionResult(CreateSection()); + + // Call + TestDelegate call = () => sectionResult.AssessmentLayerThree = (RoundedDouble) validValue; + + // Assert + Assert.DoesNotThrow(call); + Assert.AreEqual(validValue, sectionResult.AssessmentLayerThree, sectionResult.AssessmentLayerThree.GetAccuracy()); + } + + private static FailureMechanismSection CreateSection() + { + return new FailureMechanismSection("test", new[] + { + new Point2D(0, 0) + }); + } } } \ No newline at end of file