Index: Ringtoets/Common/test/Ringtoets.Common.Util.Test/FailureMechanismNormHelperTest.cs =================================================================== diff -u -r4b64623cd95f3917397dbb4add6c34da61c25cf4 -r18fa622cceab5b9575dbf4b6bffd0825100d7416 --- Ringtoets/Common/test/Ringtoets.Common.Util.Test/FailureMechanismNormHelperTest.cs (.../FailureMechanismNormHelperTest.cs) (revision 4b64623cd95f3917397dbb4add6c34da61c25cf4) +++ Ringtoets/Common/test/Ringtoets.Common.Util.Test/FailureMechanismNormHelperTest.cs (.../FailureMechanismNormHelperTest.cs) (revision 18fa622cceab5b9575dbf4b6bffd0825100d7416) @@ -57,10 +57,8 @@ var random = new Random(21); const int invalidValue = 9999; - var assessmentSection = new AssessmentSectionStub(); - // Call - TestDelegate test = () => FailureMechanismNormHelper.GetNorm(assessmentSection, + TestDelegate test = () => FailureMechanismNormHelper.GetNorm(new AssessmentSectionStub(), (FailureMechanismCategoryType) invalidValue, random.NextDouble(), random.NextDouble()); @@ -72,6 +70,48 @@ } [Test] + [TestCase(-0.1)] + [TestCase(100.1)] + [TestCase(double.NaN)] + public void GetNorm_ContributionOutOfRange_ThrowsArgumentOutOfRangeException(double contribution) + { + // Setup + var random = new Random(21); + + // Call + TestDelegate call = () => FailureMechanismNormHelper.GetNorm(new AssessmentSectionStub(), + random.NextEnumValue(), + contribution, + random.NextDouble(1, 20)); + + // Assert + const string message = "The value for 'failureMechanismContribution' must be in the range of [0.0, 100.0]."; + string paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, message).ParamName; + Assert.AreEqual("failureMechanismContribution", paramName); + } + + [Test] + [TestCase(0.99)] + [TestCase(-1)] + [TestCase(double.NaN)] + public void GetNorm_NOutOfRange_ThrowsArgumentOutOfRangeException(double n) + { + // Setup + var random = new Random(21); + + // Call + TestDelegate call = () => FailureMechanismNormHelper.GetNorm(new AssessmentSectionStub(), + random.NextEnumValue(), + random.NextDouble(1, 100), + n); + + // Assert + const string message = "The value for 'n' must be larger than 1.0."; + string paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, message).ParamName; + Assert.AreEqual("n", paramName); + } + + [Test] [TestCaseSource(nameof(GetNormConfigurationPerFailureMechanismCategoryType))] public void GetNorm_AssessmentSectionWithNormConfiguration_ReturnsCorrespondingNorm( double contribution, @@ -146,7 +186,7 @@ ).SetName("FactorizedLowerLimitNorm"); } - private static double GetMechanismSpecificNorm(double failureMechanismContribution, + private static double GetMechanismSpecificNorm(double failureMechanismContribution, double n, double norm) {