Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Helpers/ProbabilityFormattingHelperTest.cs =================================================================== diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -r9ec7530d68e3e12f58d5d9498be3e4879a0cbc15 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Helpers/ProbabilityFormattingHelperTest.cs (.../ProbabilityFormattingHelperTest.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Helpers/ProbabilityFormattingHelperTest.cs (.../ProbabilityFormattingHelperTest.cs) (revision 9ec7530d68e3e12f58d5d9498be3e4879a0cbc15) @@ -19,6 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using System.Globalization; using NUnit.Framework; using Ringtoets.Common.Forms.Helpers; @@ -77,5 +79,48 @@ // Assert Assert.AreEqual(expectedText, text); } + + [Test] + [SetCulture("nl-NL")] + [TestCase("1/10", 0.1)] + [TestCase("1/2,5", 0.4)] + [TestCase("0,5", 0.5)] + [TestCase("1", 1.0)] + [TestCase("1e-2", 0.01)] + public void Parse_WithValidInput_ReturnsCorrectProbability(string input, double expectedProbability) + { + // Call + double probability = ProbabilityFormattingHelper.Parse(input); + + // Assert + Assert.AreEqual(expectedProbability, probability); + } + + [Test] + [TestCase("not a double")] + [TestCase("")] + [TestCase("1/aaa")] + [TestCase("1/")] + [TestCase(".")] + public void Parse_WithInvalidInput_ThrowsFormatException(string input) + { + // Call + TestDelegate call = () => ProbabilityFormattingHelper.Parse(input); + + // Assert + Assert.Throws(call); + } + + [Test] + [TestCase(double.MinValue)] + [TestCase(double.MaxValue)] + public void Parse_WithOutOfRangeInput_ThrowsOverflowException(double input) + { + // Call + TestDelegate call = () => ProbabilityFormattingHelper.Parse(input.ToString(CultureInfo.CurrentCulture) + "1"); + + // Assert + Assert.Throws(call); + } } } \ No newline at end of file