Index: Core/Common/src/Core.Common.Base/TypeConverters/RoundedDoubleConverter.cs =================================================================== diff -u -r0d1c09fdde06cbe26edb81dd50fa6f3338eb7c78 -recaaea7d66c0456feb5cb2d075e40785be1459e1 --- Core/Common/src/Core.Common.Base/TypeConverters/RoundedDoubleConverter.cs (.../RoundedDoubleConverter.cs) (revision 0d1c09fdde06cbe26edb81dd50fa6f3338eb7c78) +++ Core/Common/src/Core.Common.Base/TypeConverters/RoundedDoubleConverter.cs (.../RoundedDoubleConverter.cs) (revision ecaaea7d66c0456feb5cb2d075e40785be1459e1) @@ -23,7 +23,8 @@ using System.ComponentModel; using System.Globalization; using Core.Common.Base.Data; -using Core.Common.Base.Properties; +using Core.Common.Base.Exceptions; +using Core.Common.Base.Helpers; namespace Core.Common.Base.TypeConverters { @@ -50,24 +51,12 @@ { try { - return (RoundedDouble) Convert.ToDouble(text, CultureInfo.CurrentCulture); + return (RoundedDouble) DoubleParsingHelper.Parse(text); } - catch (FormatException exception) + catch (DoubleParsingException exception) { - if (string.IsNullOrWhiteSpace(text)) - { - throw new NotSupportedException(Resources.DoubleParsingHelper_Parse_String_cannot_be_empty, - exception); - } - - throw new NotSupportedException(Resources.DoubleParsingHelper_Parse_String_must_represent_number, - exception); + throw new NotSupportedException(exception.Message); } - catch (OverflowException exception) - { - throw new NotSupportedException(Resources.DoubleParsingHelper_Parse_String_too_small_or_too_big_to_represent_as_double, - exception); - } } return base.ConvertFrom(context, culture, value); Index: Core/Common/test/Core.Common.Base.Test/TypeConverters/RoundedDoubleConverterTest.cs =================================================================== diff -u -r6a87577fa7123c62be24c8f7a192a496fe41f8fb -recaaea7d66c0456feb5cb2d075e40785be1459e1 --- Core/Common/test/Core.Common.Base.Test/TypeConverters/RoundedDoubleConverterTest.cs (.../RoundedDoubleConverterTest.cs) (revision 6a87577fa7123c62be24c8f7a192a496fe41f8fb) +++ Core/Common/test/Core.Common.Base.Test/TypeConverters/RoundedDoubleConverterTest.cs (.../RoundedDoubleConverterTest.cs) (revision ecaaea7d66c0456feb5cb2d075e40785be1459e1) @@ -99,10 +99,10 @@ var converter = new RoundedDoubleConverter(); // Call - TestDelegate call = () => converter.ConvertFrom(context, CultureInfo.CurrentCulture, text); + void Call() => converter.ConvertFrom(context, CultureInfo.CurrentCulture, text); // Assert - string message = Assert.Throws(call).Message; + string message = Assert.Throws(Call).Message; Assert.AreEqual("De tekst moet een getal zijn.", message); mocks.VerifyAll(); } @@ -120,10 +120,10 @@ var converter = new RoundedDoubleConverter(); // Call - TestDelegate call = () => converter.ConvertFrom(context, CultureInfo.CurrentCulture, text); + void Call() => converter.ConvertFrom(context, CultureInfo.CurrentCulture, text); // Assert - string message = Assert.Throws(call).Message; + string message = Assert.Throws(Call).Message; Assert.AreEqual("De tekst mag niet leeg zijn.", message); mocks.ReplayAll(); } @@ -141,10 +141,10 @@ var converter = new RoundedDoubleConverter(); // Call - TestDelegate call = () => converter.ConvertFrom(context, CultureInfo.CurrentCulture, text); + void Call() => converter.ConvertFrom(context, CultureInfo.CurrentCulture, text); // Assert - string message = Assert.Throws(call).Message; + string message = Assert.Throws(Call).Message; Assert.AreEqual("De tekst is een getal dat te groot of te klein is om gerepresenteerd te worden.", message); mocks.VerifyAll(); } Index: Riskeer/Common/test/Riskeer.Common.Forms.Test/TypeConverters/NoProbabilityValueDoubleConverterTest.cs =================================================================== diff -u -r6e3bc0437167a40cf4a79f0f04e31dc61ef4407f -recaaea7d66c0456feb5cb2d075e40785be1459e1 --- Riskeer/Common/test/Riskeer.Common.Forms.Test/TypeConverters/NoProbabilityValueDoubleConverterTest.cs (.../NoProbabilityValueDoubleConverterTest.cs) (revision 6e3bc0437167a40cf4a79f0f04e31dc61ef4407f) +++ Riskeer/Common/test/Riskeer.Common.Forms.Test/TypeConverters/NoProbabilityValueDoubleConverterTest.cs (.../NoProbabilityValueDoubleConverterTest.cs) (revision ecaaea7d66c0456feb5cb2d075e40785be1459e1) @@ -75,10 +75,10 @@ var converter = new NoProbabilityValueDoubleConverter(); // Call - TestDelegate call = () => converter.ConvertFrom(new object()); + void Call() => converter.ConvertFrom(new object()); // Assert - Assert.Throws(call); + Assert.Throws(Call); } [Test] @@ -194,10 +194,10 @@ var converter = new NoProbabilityValueDoubleConverter(); // Call - TestDelegate call = () => converter.ConvertFrom(context, CultureInfo.CurrentCulture, text); + void Call() => converter.ConvertFrom(context, CultureInfo.CurrentCulture, text); // Assert - string message = Assert.Throws(call).Message; + string message = Assert.Throws(Call).Message; Assert.AreEqual("De waarde kon niet geïnterpreteerd worden als een kans.", message); mocks.VerifyAll(); } @@ -215,10 +215,10 @@ var converter = new NoProbabilityValueDoubleConverter(); // Call - TestDelegate call = () => converter.ConvertFrom(context, CultureInfo.CurrentCulture, text); + void Call() => converter.ConvertFrom(context, CultureInfo.CurrentCulture, text); // Assert - string message = Assert.Throws(call).Message; + string message = Assert.Throws(Call).Message; Assert.AreEqual("De waarde is te groot of te klein.", message); mocks.VerifyAll(); } @@ -256,10 +256,10 @@ var converter = new NoProbabilityValueDoubleConverter(); // Call - TestDelegate call = () => converter.ConvertTo(1.1, typeof(object)); + void Call() => converter.ConvertTo(1.1, typeof(object)); // Assert - Assert.Throws(call); + Assert.Throws(Call); } [Test]