Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/RingtoetsCommonDataCalculationServiceTest.cs =================================================================== diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -rd56bec747401ad6676fac64af5eef6d5fd89c47c --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/RingtoetsCommonDataCalculationServiceTest.cs (.../RingtoetsCommonDataCalculationServiceTest.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/RingtoetsCommonDataCalculationServiceTest.cs (.../RingtoetsCommonDataCalculationServiceTest.cs) (revision d56bec747401ad6676fac64af5eef6d5fd89c47c) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Core.Common.Utils; using NUnit.Framework; using Ringtoets.Common.Data.Hydraulics; @@ -56,5 +57,58 @@ // Assert Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, calculationConverged); } + + [Test] + public void ProfileSpecificRequiredProbability_WithValidParameters_ReturnSpecificProbability() + { + // Setup + const double norm = 1.0/200; + const double contribution = 10; + const int n = 2; + + // Call + double probability = RingtoetsCommonDataCalculationService.ProfileSpecificRequiredProbability(norm, contribution, n); + + // Assert + Assert.AreEqual(0.00025, probability); + } + + [Test] + public void ProfileSpecificRequiredProbability_WithZeroContribution_ThrowsArgumentException() + { + // Setup + const double norm = 1.0/200; + const double contribution = 0; + const int n = 2; + + // Call + TestDelegate action = () => RingtoetsCommonDataCalculationService.ProfileSpecificRequiredProbability(norm, contribution, n); + + // Assert + ArgumentOutOfRangeException exception = Assert.Throws(action); + Assert.AreEqual(contribution, exception.ActualValue); + Assert.AreEqual("failureMechanismContribution", exception.ParamName); + StringAssert.StartsWith("De bijdrage van dit toetsspoor is nul. Daardoor is de doorsnede-eis onbepaald en kunnen de berekeningen niet worden uitgevoerd." + + Environment.NewLine, exception.Message); + } + + [Test] + public void ProfileSpecificRequiredProbability_WithZeroN_ThrowsArgumentException() + { + // Setup + const double norm = 1.0/200; + const double contribution = 10; + const int n = 0; + + // Call + TestDelegate action = () => RingtoetsCommonDataCalculationService.ProfileSpecificRequiredProbability(norm, contribution, n); + + // Assert + ArgumentOutOfRangeException exception = Assert.Throws(action); + Assert.AreEqual(n, exception.ActualValue); + Assert.AreEqual("n", exception.ParamName); + StringAssert.StartsWith("De N-waarde van dit toetsspoor is nul. Daardoor is de doorsnede-eis onbepaald en kunnen de berekeningen niet worden uitgevoerd." + + Environment.NewLine, exception.Message); + } } } \ No newline at end of file