Index: Core/Common/src/Core.Common.Base/Helpers/DoubleParsingHelper.cs =================================================================== diff -u -ra3e4620f5e663d447936fbc69068b02168764733 -r0d1c09fdde06cbe26edb81dd50fa6f3338eb7c78 --- Core/Common/src/Core.Common.Base/Helpers/DoubleParsingHelper.cs (.../DoubleParsingHelper.cs) (revision a3e4620f5e663d447936fbc69068b02168764733) +++ Core/Common/src/Core.Common.Base/Helpers/DoubleParsingHelper.cs (.../DoubleParsingHelper.cs) (revision 0d1c09fdde06cbe26edb81dd50fa6f3338eb7c78) @@ -48,16 +48,16 @@ { if (string.IsNullOrWhiteSpace(value)) { - throw new DoubleParsingException(Resources.RoundedDoubleConverter_ConvertFrom_String_cannot_be_empty, + throw new DoubleParsingException(Resources.DoubleParsingHelper_Parse_String_cannot_be_empty, exception); } - throw new DoubleParsingException(Resources.RoundedDoubleConverter_ConvertFrom_String_must_represent_number, + throw new DoubleParsingException(Resources.DoubleParsingHelper_Parse_String_must_represent_number, exception); } catch (OverflowException exception) { - throw new DoubleParsingException(Resources.RoundedDoubleConverter_ConvertFrom_String_too_small_or_too_big_to_represent_as_double, + throw new DoubleParsingException(Resources.DoubleParsingHelper_Parse_String_too_small_or_too_big_to_represent_as_double, exception); } } Index: Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs =================================================================== diff -u -rb72c292b735fce941efee4945314cd04b0560445 -r0d1c09fdde06cbe26edb81dd50fa6f3338eb7c78 --- Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision b72c292b735fce941efee4945314cd04b0560445) +++ Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 0d1c09fdde06cbe26edb81dd50fa6f3338eb7c78) @@ -146,6 +146,33 @@ } /// + /// Looks up a localized string similar to De tekst mag niet leeg zijn.. + /// + public static string DoubleParsingHelper_Parse_String_cannot_be_empty { + get { + return ResourceManager.GetString("DoubleParsingHelper_Parse_String_cannot_be_empty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to De tekst moet een getal zijn.. + /// + public static string DoubleParsingHelper_Parse_String_must_represent_number { + get { + return ResourceManager.GetString("DoubleParsingHelper_Parse_String_must_represent_number", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to De tekst is een getal dat te groot of te klein is om gerepresenteerd te worden.. + /// + public static string DoubleParsingHelper_Parse_String_too_small_or_too_big_to_represent_as_double { + get { + return ResourceManager.GetString("DoubleParsingHelper_Parse_String_too_small_or_too_big_to_represent_as_double", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Fout. /// public static string Error { @@ -265,34 +292,6 @@ } /// - /// Looks up a localized string similar to De tekst mag niet leeg zijn.. - /// - public static string RoundedDoubleConverter_ConvertFrom_String_cannot_be_empty { - get { - return ResourceManager.GetString("RoundedDoubleConverter_ConvertFrom_String_cannot_be_empty", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to De tekst moet een getal zijn.. - /// - public static string RoundedDoubleConverter_ConvertFrom_String_must_represent_number { - get { - return ResourceManager.GetString("RoundedDoubleConverter_ConvertFrom_String_must_represent_number", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to De tekst is een getal dat te groot of te klein is om gerepresenteerd te worden.. - /// - public static string RoundedDoubleConverter_ConvertFrom_String_too_small_or_too_big_to_represent_as_double { - get { - return ResourceManager.GetString("RoundedDoubleConverter_ConvertFrom_String_too_small_or_too_big_to_represent_as_do" + - "uble", resourceCulture); - } - } - - /// /// Looks up a localized string similar to Voor het maken van een segment zijn twee punten nodig.. /// public static string Segment2D_Constructor_Segment_must_be_created_with_two_points { Index: Core/Common/src/Core.Common.Base/Properties/Resources.resx =================================================================== diff -u -r4a91111c1fda2c629fef0f552a2b33d9dbb5df92 -r0d1c09fdde06cbe26edb81dd50fa6f3338eb7c78 --- Core/Common/src/Core.Common.Base/Properties/Resources.resx (.../Resources.resx) (revision 4a91111c1fda2c629fef0f552a2b33d9dbb5df92) +++ Core/Common/src/Core.Common.Base/Properties/Resources.resx (.../Resources.resx) (revision 0d1c09fdde06cbe26edb81dd50fa6f3338eb7c78) @@ -159,16 +159,16 @@ -Oneindig - + De tekst moet een getal zijn. - + De tekst is een getal dat te groot of te klein is om gerepresenteerd te worden. Vector moet 2 dimensies hebben, maar heeft er {0}. - + De tekst mag niet leeg zijn. Index: Core/Common/src/Core.Common.Base/TypeConverters/RoundedDoubleConverter.cs =================================================================== diff -u -rb72c292b735fce941efee4945314cd04b0560445 -r0d1c09fdde06cbe26edb81dd50fa6f3338eb7c78 --- Core/Common/src/Core.Common.Base/TypeConverters/RoundedDoubleConverter.cs (.../RoundedDoubleConverter.cs) (revision b72c292b735fce941efee4945314cd04b0560445) +++ Core/Common/src/Core.Common.Base/TypeConverters/RoundedDoubleConverter.cs (.../RoundedDoubleConverter.cs) (revision 0d1c09fdde06cbe26edb81dd50fa6f3338eb7c78) @@ -56,16 +56,16 @@ { if (string.IsNullOrWhiteSpace(text)) { - throw new NotSupportedException(Resources.RoundedDoubleConverter_ConvertFrom_String_cannot_be_empty, + throw new NotSupportedException(Resources.DoubleParsingHelper_Parse_String_cannot_be_empty, exception); } - throw new NotSupportedException(Resources.RoundedDoubleConverter_ConvertFrom_String_must_represent_number, + throw new NotSupportedException(Resources.DoubleParsingHelper_Parse_String_must_represent_number, exception); } catch (OverflowException exception) { - throw new NotSupportedException(Resources.RoundedDoubleConverter_ConvertFrom_String_too_small_or_too_big_to_represent_as_double, + throw new NotSupportedException(Resources.DoubleParsingHelper_Parse_String_too_small_or_too_big_to_represent_as_double, exception); } } Index: Core/Common/test/Core.Common.Base.Test/Helpers/DoubleParsingHelperTest.cs =================================================================== diff -u -ra3e4620f5e663d447936fbc69068b02168764733 -r0d1c09fdde06cbe26edb81dd50fa6f3338eb7c78 --- Core/Common/test/Core.Common.Base.Test/Helpers/DoubleParsingHelperTest.cs (.../DoubleParsingHelperTest.cs) (revision a3e4620f5e663d447936fbc69068b02168764733) +++ Core/Common/test/Core.Common.Base.Test/Helpers/DoubleParsingHelperTest.cs (.../DoubleParsingHelperTest.cs) (revision 0d1c09fdde06cbe26edb81dd50fa6f3338eb7c78) @@ -31,21 +31,8 @@ public class DoubleParsingHelperTest { [Test] - [TestCase("")] - [TestCase(" ")] - [TestCase(" ")] - [TestCase(null)] - public void Parse_NullOrEmptyString_ReturnsExpectedOutput(string value) - { - // Call - double parsedValue = DoubleParsingHelper.Parse(value); - - // Assert - Assert.IsNaN(parsedValue); - } - - [Test] [SetCulture("nl-NL")] + [TestCase(null, 0)] [TestCase("13.137,371446", 13137.371446)] [TestCase("13,3701231", 13.3701231)] [TestCase("1,000000001", 1.000000001)] @@ -66,7 +53,8 @@ } [Test] - [SetCulture("en-US")] + [SetCulture("en-US")] + [TestCase(null, 0)] [TestCase("13,137.371446", 13137.371446)] [TestCase("13.3701231", 13.3701231)] [TestCase("1.000000001", 1.000000001)] @@ -87,8 +75,23 @@ } [Test] - public void Parse_ValueDoesNotRepresentRoundedDouble_ThrowsProbabilityParsingException() + [TestCase("")] + [TestCase(" ")] + [TestCase(" ")] + public void Parse_WhitespacesOrEmptyString_ThrowsDoubleParsingException(string value) { + // Call + void Call() => DoubleParsingHelper.Parse(value); + + // Assert + var exception = Assert.Throws(Call); + Assert.IsInstanceOf(exception.InnerException); + Assert.AreEqual("De tekst mag niet leeg zijn.", exception.Message); + } + + [Test] + public void Parse_ValueDoesNotRepresentRoundedDouble_ThrowsDoubleParsingException() + { // Setup const string invalidValue = "I'm not a number!"; @@ -98,22 +101,24 @@ // Assert var exception = Assert.Throws(Call); Assert.IsInstanceOf(exception.InnerException); - Assert.AreEqual("De waarde kon niet geïnterpreteerd worden als een kommagetal.", exception.Message); + Assert.AreEqual("De tekst moet een getal zijn.", exception.Message); } [Test] - public void Parse_ValueTooLargeToStoreInDouble_ThrowsProbabilityParsingException() + [TestCase("1")] + [TestCase("-1")] + public void Parse_ValueTooLargeToStoreInDouble_ThrowsDoubleParsingException(string prefix) { // Setup - string invalidValue = "1" + double.MaxValue.ToString(CultureInfo.CurrentCulture); + string invalidValue = prefix + double.MaxValue.ToString(CultureInfo.CurrentCulture); // Call void Call() => DoubleParsingHelper.Parse(invalidValue); // Assert var exception = Assert.Throws(Call); Assert.IsInstanceOf(exception.InnerException); - Assert.AreEqual("De waarde is te groot of te klein.", exception.Message); + Assert.AreEqual("De tekst is een getal dat te groot of te klein is om gerepresenteerd te worden.", exception.Message); } } } \ No newline at end of file