Index: Riskeer/Common/src/Riskeer.Common.Forms/Helpers/DoubleParsingHelper.cs =================================================================== diff -u -r5bf7ae701104475a5df3759c8c5102fdbe43f430 -rc177e088a4639af8a923349631c106d509737c2b --- Riskeer/Common/src/Riskeer.Common.Forms/Helpers/DoubleParsingHelper.cs (.../DoubleParsingHelper.cs) (revision 5bf7ae701104475a5df3759c8c5102fdbe43f430) +++ Riskeer/Common/src/Riskeer.Common.Forms/Helpers/DoubleParsingHelper.cs (.../DoubleParsingHelper.cs) (revision c177e088a4639af8a923349631c106d509737c2b) @@ -20,7 +20,6 @@ // All rights reserved. using System; -using Core.Common.Base.Data; using Riskeer.Common.Forms.Exceptions; using Riskeer.Common.Forms.Properties; @@ -35,19 +34,18 @@ /// Parses a string value to a . /// /// The value to be parsed. - /// The number of decimals. - /// A . + /// A . /// Thrown when could not be successfully parsed as a probability. - public static RoundedDouble Parse(string value, int nrOfDecimals) + public static double Parse(string value) { if (string.IsNullOrWhiteSpace(value)) { - return RoundedDouble.NaN; + return double.NaN; } try { - return new RoundedDouble(nrOfDecimals, Convert.ToDouble(value)); + return Convert.ToDouble(value); } catch (FormatException exception) { Index: Riskeer/Common/test/Riskeer.Common.Forms.Test/Helpers/DoubleParsingHelperTest.cs =================================================================== diff -u -r5bf7ae701104475a5df3759c8c5102fdbe43f430 -rc177e088a4639af8a923349631c106d509737c2b --- Riskeer/Common/test/Riskeer.Common.Forms.Test/Helpers/DoubleParsingHelperTest.cs (.../DoubleParsingHelperTest.cs) (revision 5bf7ae701104475a5df3759c8c5102fdbe43f430) +++ Riskeer/Common/test/Riskeer.Common.Forms.Test/Helpers/DoubleParsingHelperTest.cs (.../DoubleParsingHelperTest.cs) (revision c177e088a4639af8a923349631c106d509737c2b) @@ -21,9 +21,7 @@ using System; using System.Globalization; -using Core.Common.Base.Data; using NUnit.Framework; -using Riskeer.Common.Data.TestUtil; using Riskeer.Common.Forms.Exceptions; using Riskeer.Common.Forms.Helpers; @@ -39,74 +37,63 @@ [TestCase(null)] public void Parse_NullOrEmptyString_ReturnsExpectedOutput(string value) { - // Setup - var random = new Random(21); - // Call - double parsedValue = DoubleParsingHelper.Parse(value, random.Next()); + double parsedValue = DoubleParsingHelper.Parse(value); // Assert Assert.IsNaN(parsedValue); } [Test] - [TestCase("13.137,371446", 13137.371)] - [TestCase("13,3701231", 13.370)] - [TestCase("1,000000001", 1.0)] + [SetCulture("nl-NL")] + [TestCase("13.137,371446", 13137.371446)] + [TestCase("13,3701231", 13.3701231)] + [TestCase("1,000000001", 1.000000001)] [TestCase("1e-2", 0.01)] [TestCase("0,003", 0.003)] [TestCase("-0,003", -0.003)] [TestCase("-1e-2", -0.01)] - [TestCase("-1,000000001", -1.0)] - [TestCase("-13,3701231", -13.370)] - [TestCase("-13.137,37446", -13137.374)] + [TestCase("-1,000000001", -1.000000001)] + [TestCase("-13,3701231", -13.3701231)] + [TestCase("-13.137,37446", -13137.37446)] public void Parse_ValidStringInDutchCulture_ReturnsExpectedOutput(string value, double expectedValue) { - // Setup - const int nrOfDecimals = 3; - // Call - RoundedDouble parsedValue = DoubleParsingHelper.Parse(value, nrOfDecimals); + double parsedValue = DoubleParsingHelper.Parse(value); // Assert - Assert.AreEqual(nrOfDecimals, parsedValue.NumberOfDecimalPlaces); - Assert.AreEqual(expectedValue, parsedValue, parsedValue.GetAccuracy()); + Assert.AreEqual(expectedValue, parsedValue); } [Test] [SetCulture("en-US")] - [TestCase("13,137.371446", 13137.371)] - [TestCase("13.3701231", 13.370)] - [TestCase("1.000000001", 1.0)] + [TestCase("13,137.371446", 13137.371446)] + [TestCase("13.3701231", 13.3701231)] + [TestCase("1.000000001", 1.000000001)] [TestCase("1e-2", 0.01)] [TestCase("0.003", 0.003)] [TestCase("-0.003", -0.003)] [TestCase("-1e-2", -0.01)] - [TestCase("-1.000000001", -1.0)] - [TestCase("-13.3701231", -13.370)] - [TestCase("-13,137.37446", -13137.374)] + [TestCase("-1.000000001", -1.000000001)] + [TestCase("-13.3701231", -13.3701231)] + [TestCase("-13,137.37446", -13137.37446)] public void Parse_ValidStringInEnglishCulture_ReturnsExpectedOutput(string value, double expectedValue) { - // Setup - const int nrOfDecimals = 3; - // Call - RoundedDouble parsedValue = DoubleParsingHelper.Parse(value, nrOfDecimals); + double parsedValue = DoubleParsingHelper.Parse(value); // Assert - Assert.AreEqual(nrOfDecimals, parsedValue.NumberOfDecimalPlaces); - Assert.AreEqual(expectedValue, parsedValue, parsedValue.GetAccuracy()); + Assert.AreEqual(expectedValue, parsedValue); } [Test] public void Parse_ValueDoesNotRepresentRoundedDouble_ThrowsProbabilityParsingException() { // Setup - var random = new Random(21); const string invalidValue = "I'm not a number!"; // Call - void Call() => DoubleParsingHelper.Parse(invalidValue, random.Next()); + void Call() => DoubleParsingHelper.Parse(invalidValue); // Assert var exception = Assert.Throws(Call); @@ -118,11 +105,10 @@ public void Parse_ValueTooLargeToStoreInDouble_ThrowsProbabilityParsingException() { // Setup - var random = new Random(21); string invalidValue = "1" + double.MaxValue.ToString(CultureInfo.CurrentCulture); // Call - void Call() => DoubleParsingHelper.Parse(invalidValue, random.Next()); + void Call() => DoubleParsingHelper.Parse(invalidValue); // Assert var exception = Assert.Throws(Call); Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsScenariosView.cs =================================================================== diff -u -r5bf7ae701104475a5df3759c8c5102fdbe43f430 -rc177e088a4639af8a923349631c106d509737c2b --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsScenariosView.cs (.../MacroStabilityInwardsScenariosView.cs) (revision 5bf7ae701104475a5df3759c8c5102fdbe43f430) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsScenariosView.cs (.../MacroStabilityInwardsScenariosView.cs) (revision c177e088a4639af8a923349631c106d509737c2b) @@ -327,7 +327,7 @@ { MacroStabilityInwardsScenarioConfigurationPerFailureMechanismSection scenarioConfigurationPerSection = selectedFailureMechanismSection.ScenarioConfigurationPerSection; - scenarioConfigurationPerSection.A = DoubleParsingHelper.Parse(lengthEffectATextBox.Text, 3); + scenarioConfigurationPerSection.A = (RoundedDouble) DoubleParsingHelper.Parse(lengthEffectATextBox.Text); scenarioConfigurationPerSection.NotifyObservers(); UpdateScenarioRows(); Index: Riskeer/Piping/src/Riskeer.Piping.Forms/Views/PipingScenariosView.cs =================================================================== diff -u -r5bf7ae701104475a5df3759c8c5102fdbe43f430 -rc177e088a4639af8a923349631c106d509737c2b --- Riskeer/Piping/src/Riskeer.Piping.Forms/Views/PipingScenariosView.cs (.../PipingScenariosView.cs) (revision 5bf7ae701104475a5df3759c8c5102fdbe43f430) +++ Riskeer/Piping/src/Riskeer.Piping.Forms/Views/PipingScenariosView.cs (.../PipingScenariosView.cs) (revision c177e088a4639af8a923349631c106d509737c2b) @@ -468,7 +468,7 @@ { PipingScenarioConfigurationPerFailureMechanismSection scenarioConfigurationPerSection = selectedFailureMechanismSection.ScenarioConfigurationPerSection; - scenarioConfigurationPerSection.A = DoubleParsingHelper.Parse(lengthEffectATextBox.Text, 3); + scenarioConfigurationPerSection.A = (RoundedDouble) DoubleParsingHelper.Parse(lengthEffectATextBox.Text); scenarioConfigurationPerSection.NotifyObservers(); UpdateScenarioRows();