Index: Core/Common/src/Core.Common.Base/Exceptions/DoubleParsingException.cs
===================================================================
diff -u
--- Core/Common/src/Core.Common.Base/Exceptions/DoubleParsingException.cs (revision 0)
+++ Core/Common/src/Core.Common.Base/Exceptions/DoubleParsingException.cs (revision a3e4620f5e663d447936fbc69068b02168764733)
@@ -0,0 +1,69 @@
+// Copyright (C) Stichting Deltares and State of the Netherlands 2023. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Runtime.Serialization;
+using Core.Common.Base.Data;
+
+namespace Core.Common.Base.Exceptions
+{
+ ///
+ /// Exception thrown when the could not be parsed successfully.
+ ///
+ [Serializable]
+ public class DoubleParsingException : Exception
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public DoubleParsingException() {}
+
+ ///
+ /// Initializes a new instance of the class
+ /// with a specified error message.
+ ///
+ /// The message that describes the error.
+ public DoubleParsingException(string message)
+ : base(message) {}
+
+ ///
+ /// Initializes a new instance of the class with a specified error message
+ /// and a reference to the inner exception that is the cause of this exception.
+ ///
+ /// The error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception,
+ /// or null if no inner exception is specified.
+ public DoubleParsingException(string message, Exception innerException) : base(message, innerException) {}
+
+ ///
+ /// Initializes a new instance of with
+ /// serialized data.
+ /// The that holds the serialized
+ /// object data about the exception being thrown.
+ /// The that contains contextual
+ /// information about the source or destination.
+ /// The parameter is
+ /// null.
+ /// The class name is null or
+ /// is zero (0).
+ protected DoubleParsingException(SerializationInfo info, StreamingContext context) : base(info, context) {}
+ }
+}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Base/Helpers/DoubleParsingHelper.cs
===================================================================
diff -u
--- Core/Common/src/Core.Common.Base/Helpers/DoubleParsingHelper.cs (revision 0)
+++ Core/Common/src/Core.Common.Base/Helpers/DoubleParsingHelper.cs (revision a3e4620f5e663d447936fbc69068b02168764733)
@@ -0,0 +1,65 @@
+// Copyright (C) Stichting Deltares and State of the Netherlands 2023. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Globalization;
+using Core.Common.Base.Exceptions;
+using Core.Common.Base.Properties;
+
+namespace Core.Common.Base.Helpers
+{
+ ///
+ /// Helper class to parse .
+ ///
+ public static class DoubleParsingHelper
+ {
+ ///
+ /// Parses a string value to a .
+ ///
+ /// The value to be parsed.
+ /// A .
+ /// Thrown when could not be successfully
+ /// parsed as a .
+ public static double Parse(string value)
+ {
+ try
+ {
+ return Convert.ToDouble(value, CultureInfo.CurrentCulture);
+ }
+ catch (FormatException exception)
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ throw new DoubleParsingException(Resources.RoundedDoubleConverter_ConvertFrom_String_cannot_be_empty,
+ exception);
+ }
+
+ throw new DoubleParsingException(Resources.RoundedDoubleConverter_ConvertFrom_String_must_represent_number,
+ exception);
+ }
+ catch (OverflowException exception)
+ {
+ throw new DoubleParsingException(Resources.RoundedDoubleConverter_ConvertFrom_String_too_small_or_too_big_to_represent_as_double,
+ exception);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Core/Common/test/Core.Common.Base.Test/Exceptions/DoubleParsingExceptionTest.cs
===================================================================
diff -u
--- Core/Common/test/Core.Common.Base.Test/Exceptions/DoubleParsingExceptionTest.cs (revision 0)
+++ Core/Common/test/Core.Common.Base.Test/Exceptions/DoubleParsingExceptionTest.cs (revision a3e4620f5e663d447936fbc69068b02168764733)
@@ -0,0 +1,32 @@
+// Copyright (C) Stichting Deltares and State of the Netherlands 2023. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using Core.Common.Base.Exceptions;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+
+namespace Core.Common.Base.Test.Exceptions
+{
+ [TestFixture]
+ public class DoubleParsingExceptionTest :
+ CustomExceptionDesignGuidelinesTestFixture {}
+}
\ No newline at end of file
Index: Core/Common/test/Core.Common.Base.Test/Helpers/DoubleParsingHelperTest.cs
===================================================================
diff -u
--- Core/Common/test/Core.Common.Base.Test/Helpers/DoubleParsingHelperTest.cs (revision 0)
+++ Core/Common/test/Core.Common.Base.Test/Helpers/DoubleParsingHelperTest.cs (revision a3e4620f5e663d447936fbc69068b02168764733)
@@ -0,0 +1,119 @@
+// Copyright (C) Stichting Deltares and State of the Netherlands 2023. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Globalization;
+using Core.Common.Base.Exceptions;
+using Core.Common.Base.Helpers;
+using NUnit.Framework;
+
+namespace Core.Common.Base.Test.Helpers
+{
+ [TestFixture]
+ 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("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.000000001)]
+ [TestCase("-13,3701231", -13.3701231)]
+ [TestCase("-13.137,37446", -13137.37446)]
+ public void Parse_ValidStringInDutchCulture_ReturnsExpectedOutput(string value, double expectedValue)
+ {
+ // Call
+ double parsedValue = DoubleParsingHelper.Parse(value);
+
+ // Assert
+ Assert.AreEqual(expectedValue, parsedValue);
+ }
+
+ [Test]
+ [SetCulture("en-US")]
+ [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.000000001)]
+ [TestCase("-13.3701231", -13.3701231)]
+ [TestCase("-13,137.37446", -13137.37446)]
+ public void Parse_ValidStringInEnglishCulture_ReturnsExpectedOutput(string value, double expectedValue)
+ {
+ // Call
+ double parsedValue = DoubleParsingHelper.Parse(value);
+
+ // Assert
+ Assert.AreEqual(expectedValue, parsedValue);
+ }
+
+ [Test]
+ public void Parse_ValueDoesNotRepresentRoundedDouble_ThrowsProbabilityParsingException()
+ {
+ // Setup
+ const string invalidValue = "I'm not a number!";
+
+ // Call
+ void Call() => DoubleParsingHelper.Parse(invalidValue);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.IsInstanceOf(exception.InnerException);
+ Assert.AreEqual("De waarde kon niet geïnterpreteerd worden als een kommagetal.", exception.Message);
+ }
+
+ [Test]
+ public void Parse_ValueTooLargeToStoreInDouble_ThrowsProbabilityParsingException()
+ {
+ // Setup
+ string invalidValue = "1" + 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);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag a3e4620f5e663d447936fbc69068b02168764733 refers to a dead (removed) revision in file `Riskeer/Common/src/Riskeer.Common.Forms/Exceptions/DoubleParsingException.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag a3e4620f5e663d447936fbc69068b02168764733 refers to a dead (removed) revision in file `Riskeer/Common/src/Riskeer.Common.Forms/Helpers/DoubleParsingHelper.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag a3e4620f5e663d447936fbc69068b02168764733 refers to a dead (removed) revision in file `Riskeer/Common/test/Riskeer.Common.Forms.Test/Exceptions/DoubleParsingExceptionTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag a3e4620f5e663d447936fbc69068b02168764733 refers to a dead (removed) revision in file `Riskeer/Common/test/Riskeer.Common.Forms.Test/Helpers/DoubleParsingHelperTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsScenariosView.cs
===================================================================
diff -u -rc177e088a4639af8a923349631c106d509737c2b -ra3e4620f5e663d447936fbc69068b02168764733
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsScenariosView.cs (.../MacroStabilityInwardsScenariosView.cs) (revision c177e088a4639af8a923349631c106d509737c2b)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsScenariosView.cs (.../MacroStabilityInwardsScenariosView.cs) (revision a3e4620f5e663d447936fbc69068b02168764733)
@@ -26,15 +26,15 @@
using System.Windows.Forms;
using Core.Common.Base;
using Core.Common.Base.Data;
+using Core.Common.Base.Exceptions;
using Core.Common.Base.Geometry;
+using Core.Common.Base.Helpers;
using Core.Common.Controls.Views;
using Core.Common.Util.Extensions;
using Riskeer.Common.Data.AssessmentSection;
using Riskeer.Common.Data.Calculation;
using Riskeer.Common.Data.FailureMechanism;
using Riskeer.Common.Data.Probability;
-using Riskeer.Common.Forms.Exceptions;
-using Riskeer.Common.Forms.Helpers;
using Riskeer.MacroStabilityInwards.Data;
using Riskeer.MacroStabilityInwards.Forms.PresentationObjects;
using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources;
@@ -94,7 +94,7 @@
UpdateSectionsListBox();
UpdateScenarioControls();
-
+
UpdateLengthEffectControls();
UpdateLengthEffectData();
}
Index: Riskeer/Piping/src/Riskeer.Piping.Forms/Views/PipingScenariosView.cs
===================================================================
diff -u -rc177e088a4639af8a923349631c106d509737c2b -ra3e4620f5e663d447936fbc69068b02168764733
--- Riskeer/Piping/src/Riskeer.Piping.Forms/Views/PipingScenariosView.cs (.../PipingScenariosView.cs) (revision c177e088a4639af8a923349631c106d509737c2b)
+++ Riskeer/Piping/src/Riskeer.Piping.Forms/Views/PipingScenariosView.cs (.../PipingScenariosView.cs) (revision a3e4620f5e663d447936fbc69068b02168764733)
@@ -25,15 +25,15 @@
using System.Windows.Forms;
using Core.Common.Base;
using Core.Common.Base.Data;
+using Core.Common.Base.Exceptions;
using Core.Common.Base.Geometry;
+using Core.Common.Base.Helpers;
using Core.Common.Controls.Views;
using Core.Common.Util.Enums;
using Core.Common.Util.Extensions;
using Riskeer.Common.Data.AssessmentSection;
using Riskeer.Common.Data.Calculation;
using Riskeer.Common.Data.Probability;
-using Riskeer.Common.Forms.Exceptions;
-using Riskeer.Common.Forms.Helpers;
using Riskeer.Piping.Data;
using Riskeer.Piping.Data.Probabilistic;
using Riskeer.Piping.Data.SemiProbabilistic;