Index: Core/Common/src/Core.Common.Base/Core.Common.Base.csproj
===================================================================
diff -u -rf8eeb4e21d9e282d998f3f218593bfb0fec681b7 -r93b256575fba3e4068baadeeb62140533336371a
--- Core/Common/src/Core.Common.Base/Core.Common.Base.csproj (.../Core.Common.Base.csproj) (revision f8eeb4e21d9e282d998f3f218593bfb0fec681b7)
+++ Core/Common/src/Core.Common.Base/Core.Common.Base.csproj (.../Core.Common.Base.csproj) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -120,6 +120,7 @@
+
Copying.Lesser.licenseheader
Index: Core/Common/src/Core.Common.Base/Data/RoundedDouble.cs
===================================================================
diff -u -raf38c7a9724254095e2e3a631dd7e974465a1fb9 -r93b256575fba3e4068baadeeb62140533336371a
--- Core/Common/src/Core.Common.Base/Data/RoundedDouble.cs (.../RoundedDouble.cs) (revision af38c7a9724254095e2e3a631dd7e974465a1fb9)
+++ Core/Common/src/Core.Common.Base/Data/RoundedDouble.cs (.../RoundedDouble.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -1,14 +1,17 @@
using System;
+using System.ComponentModel;
using System.Globalization;
using Core.Common.Base.Properties;
+using Core.Common.Base.TypeConverters;
namespace Core.Common.Base.Data
{
///
/// This class represents a that is being rounded to a certain
/// number of places.
///
+ [TypeConverter(typeof(RoundedDoubleConverter))]
public struct RoundedDouble : IEquatable, IEquatable
{
///
@@ -24,9 +27,9 @@
/// given value.
///
/// The number of decimal places.
- /// The value to initalize the instance with.
+ /// The value to initialize the instance with.
///
- /// Thrown when is not in range [0, 15].
+ /// Thrown when is not in range [0, ].
///
public RoundedDouble(int numberOfDecimalPlaces, double value = 0.0)
{
@@ -68,6 +71,12 @@
return !Equals(left, right);
}
+ public static RoundedDouble operator -(RoundedDouble left, RoundedDouble right)
+ {
+ return new RoundedDouble(Math.Min(left.numberOfDecimalPlaces, right.numberOfDecimalPlaces),
+ left.value - right.value);
+ }
+
public static implicit operator double(RoundedDouble d)
{
return d.Value;
Index: Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs
===================================================================
diff -u -rf8eeb4e21d9e282d998f3f218593bfb0fec681b7 -r93b256575fba3e4068baadeeb62140533336371a
--- Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision f8eeb4e21d9e282d998f3f218593bfb0fec681b7)
+++ Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -179,6 +179,25 @@
}
///
+ /// 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 -rf8eeb4e21d9e282d998f3f218593bfb0fec681b7 -r93b256575fba3e4068baadeeb62140533336371a
--- Core/Common/src/Core.Common.Base/Properties/Resources.resx (.../Resources.resx) (revision f8eeb4e21d9e282d998f3f218593bfb0fec681b7)
+++ Core/Common/src/Core.Common.Base/Properties/Resources.resx (.../Resources.resx) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -159,4 +159,10 @@
-Oneindig
+
+ De tekst moet een getal zijn.
+
+
+ De tekst is een getal dat te groot of te klein is om gerepresenteerd te worden.
+
\ No newline at end of file
Index: Core/Common/src/Core.Common.Base/TypeConverters/RoundedDoubleConverter.cs
===================================================================
diff -u
--- Core/Common/src/Core.Common.Base/TypeConverters/RoundedDoubleConverter.cs (revision 0)
+++ Core/Common/src/Core.Common.Base/TypeConverters/RoundedDoubleConverter.cs (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -0,0 +1,69 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser 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.ComponentModel;
+using System.Globalization;
+
+using Core.Common.Base.Data;
+using Core.Common.Base.Properties;
+
+namespace Core.Common.Base.TypeConverters
+{
+ ///
+ /// Class that converts representations of a number to a corresponding
+ /// instance of .
+ ///
+ public class RoundedDoubleConverter : TypeConverter
+ {
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ if (sourceType == typeof(string))
+ {
+ return true;
+ }
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ var text = value as string;
+ if (text != null)
+ {
+ try
+ {
+ return (RoundedDouble)Convert.ToDouble(text);
+ }
+ catch (FormatException exception)
+ {
+ throw new NotSupportedException(Resources.RoundedDoubleConverter_ConvertFrom_String_must_represent_number,
+ exception);
+ }
+ catch (OverflowException exception)
+ {
+ throw new NotSupportedException(Resources.RoundedDoubleConverter_ConvertFrom_String_too_small_or_too_big_to_represent_as_double,
+ exception);
+ }
+ }
+ return base.ConvertFrom(context, culture, value);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 93b256575fba3e4068baadeeb62140533336371a refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Gui/Converters/RoundedDoubleConverter.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj
===================================================================
diff -u -ra5b051a25a6bb059d5928e29a8d741a8ec31fcd5 -r93b256575fba3e4068baadeeb62140533336371a
--- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision a5b051a25a6bb059d5928e29a8d741a8ec31fcd5)
+++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -134,7 +134,6 @@
-
Index: Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs
===================================================================
diff -u -ra5b051a25a6bb059d5928e29a8d741a8ec31fcd5 -r93b256575fba3e4068baadeeb62140533336371a
--- Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision a5b051a25a6bb059d5928e29a8d741a8ec31fcd5)
+++ Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -1490,25 +1490,6 @@
}
///
- /// 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 resource of type System.Drawing.Bitmap.
///
public static System.Drawing.Bitmap SaveAsHH {
Index: Core/Common/src/Core.Common.Gui/Properties/Resources.resx
===================================================================
diff -u -ra5b051a25a6bb059d5928e29a8d741a8ec31fcd5 -r93b256575fba3e4068baadeeb62140533336371a
--- Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision a5b051a25a6bb059d5928e29a8d741a8ec31fcd5)
+++ Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -688,10 +688,4 @@
Openen van een nieuw Ringtoetsproject geannuleerd.
-
- De tekst moet een getal zijn.
-
-
- De tekst is een getal dat te groot of te klein is om gerepresenteerd te worden.
-
\ No newline at end of file
Index: Core/Common/test/Core.Common.Base.Test/Core.Common.Base.Test.csproj
===================================================================
diff -u -rf8eeb4e21d9e282d998f3f218593bfb0fec681b7 -r93b256575fba3e4068baadeeb62140533336371a
--- Core/Common/test/Core.Common.Base.Test/Core.Common.Base.Test.csproj (.../Core.Common.Base.Test.csproj) (revision f8eeb4e21d9e282d998f3f218593bfb0fec681b7)
+++ Core/Common/test/Core.Common.Base.Test/Core.Common.Base.Test.csproj (.../Core.Common.Base.Test.csproj) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -102,6 +102,7 @@
+
Index: Core/Common/test/Core.Common.Base.Test/Data/RoundedDoubleTest.cs
===================================================================
diff -u -raf38c7a9724254095e2e3a631dd7e974465a1fb9 -r93b256575fba3e4068baadeeb62140533336371a
--- Core/Common/test/Core.Common.Base.Test/Data/RoundedDoubleTest.cs (.../RoundedDoubleTest.cs) (revision af38c7a9724254095e2e3a631dd7e974465a1fb9)
+++ Core/Common/test/Core.Common.Base.Test/Data/RoundedDoubleTest.cs (.../RoundedDoubleTest.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -1,6 +1,9 @@
using System;
+using System.ComponentModel;
+using System.Linq;
using Core.Common.Base.Data;
+using Core.Common.Base.TypeConverters;
using Core.Common.TestUtil;
using NUnit.Framework;
@@ -14,7 +17,7 @@
[TestCase(0)]
[TestCase(12)]
[TestCase(15)]
- public void Constructor_ExpectedValues(int numberOfDecimalPlaces)
+ public void Constructor_WithoutValue_ExpectedValues(int numberOfDecimalPlaces)
{
// Call
var roundedDouble = new RoundedDouble(numberOfDecimalPlaces);
@@ -24,6 +27,12 @@
Assert.IsInstanceOf>(roundedDouble);
Assert.AreEqual(numberOfDecimalPlaces, roundedDouble.NumberOfDecimalPlaces);
Assert.AreEqual(0.0, roundedDouble.Value);
+
+ TypeConverterAttribute[] typeAttributes = roundedDouble.GetType().GetCustomAttributes(typeof(TypeConverterAttribute), false)
+ .Cast()
+ .ToArray();
+ Assert.AreEqual(1, typeAttributes.Length);
+ Assert.AreEqual(new TypeConverterAttribute(typeof(RoundedDoubleConverter)), typeAttributes[0]);
}
[Test]
@@ -524,5 +533,39 @@
Assert.AreEqual(newPrecision, convertedResult.NumberOfDecimalPlaces);
Assert.AreEqual(expectedValue, convertedResult.Value);
}
+
+ [Test]
+ public void OperatorMinus_LeftHasLowestPrecision_ReturnRoundedDoubleWithDifferenceRoundedToLeastNumberOfDecimalPlaces()
+ {
+ // Setup
+ const int lowestNumberOfDecimalPlaces = 2;
+
+ var value1 = new RoundedDouble(lowestNumberOfDecimalPlaces, 1.12);
+ var value2 = new RoundedDouble(3, 3.456);
+
+ // Call
+ RoundedDouble diff = value1 - value2;
+
+ // Assert
+ Assert.AreEqual(lowestNumberOfDecimalPlaces, diff.NumberOfDecimalPlaces);
+ Assert.AreEqual(-2.34, diff.Value);
+ }
+
+ [Test]
+ public void OperatorMinus_RightHasLowestPrecision_ReturnRoundedDoubleWithDifferenceRoundedToLeastNumberOfDecimalPlaces()
+ {
+ // Setup
+ const int lowestNumberOfDecimalPlaces = 1;
+
+ var value1 = new RoundedDouble(6, 1.123456);
+ var value2 = new RoundedDouble(lowestNumberOfDecimalPlaces, -7.8);
+
+ // Call
+ RoundedDouble diff = value1 - value2;
+
+ // Assert
+ Assert.AreEqual(lowestNumberOfDecimalPlaces, diff.NumberOfDecimalPlaces);
+ Assert.AreEqual(8.9, diff.Value);
+ }
}
}
\ No newline at end of file
Index: Core/Common/test/Core.Common.Base.Test/TypeConverters/RoundedDoubleConverterTest.cs
===================================================================
diff -u
--- Core/Common/test/Core.Common.Base.Test/TypeConverters/RoundedDoubleConverterTest.cs (revision 0)
+++ Core/Common/test/Core.Common.Base.Test/TypeConverters/RoundedDoubleConverterTest.cs (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -0,0 +1,117 @@
+using System;
+using System.ComponentModel;
+using System.Globalization;
+
+using Core.Common.Base.Data;
+using Core.Common.Base.TypeConverters;
+
+using NUnit.Framework;
+
+namespace Core.Common.Base.Test.TypeConverters
+{
+ [TestFixture]
+ public class RoundedDoubleConverterTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var converter = new RoundedDoubleConverter();
+
+ // Assert
+ Assert.IsInstanceOf(converter);
+ }
+
+ [Test]
+ public void CanConvertFrom_StringType_ReturnTrue()
+ {
+ // Setup
+ var converter = new RoundedDoubleConverter();
+
+ // Call
+ bool conversionIsPossible = converter.CanConvertFrom(typeof(string));
+
+ // Assert
+ Assert.IsTrue(conversionIsPossible);
+ }
+
+ [Test]
+ public void CanConvertFrom_OtherType_ReturnFalse()
+ {
+ // Setup
+ var converter = new RoundedDoubleConverter();
+
+ // Call
+ bool conversionIsPossible = converter.CanConvertFrom(typeof(object));
+
+ // Assert
+ Assert.IsFalse(conversionIsPossible);
+ }
+
+ [Test]
+ [SetCulture("nl-NL")]
+ [TestCase(123.4567)]
+ [TestCase(-9.87654321)]
+ public void ConvertFrom_SomeNumericalTextInDutchCulture_ReturnConvertedRoundedDouble(double input)
+ {
+ DoConvertFrom_SomeNumericalTextInCurrentCulture_ReturnConvertedRoundedDouble(input);
+ }
+
+ [Test]
+ [SetCulture("en-US")]
+ [TestCase(12.34)]
+ [TestCase(-0.96834715)]
+ public void ConvertFrom_SomeNumericalTextInEnglishCulture_ReturnConvertedRoundedDouble(double input)
+ {
+ DoConvertFrom_SomeNumericalTextInCurrentCulture_ReturnConvertedRoundedDouble(input);
+ }
+
+ [Test]
+ public void ConvertFrom_TextDoesNotRepresentNumber_ThrowNotSupportedException()
+ {
+ // Setup
+ string text = "I'm not a number!";
+
+ var converter = new RoundedDoubleConverter();
+
+ // Call
+ TestDelegate call = () => converter.ConvertFrom(null, CultureInfo.CurrentCulture, text);
+
+ // Assert
+ string message = Assert.Throws(call).Message;
+ Assert.AreEqual("De tekst moet een getal zijn.", message);
+ }
+
+ [Test]
+ public void ConvertFrom_TextTooLongToStoreInDouble_ThrowNotSupportedException()
+ {
+ // Setup
+ string text = "1" + double.MaxValue.ToString(CultureInfo.CurrentCulture);
+
+ var converter = new RoundedDoubleConverter();
+
+ // Call
+ TestDelegate call = () => converter.ConvertFrom(null, CultureInfo.CurrentCulture, text);
+
+ // Assert
+ 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);
+ }
+
+ private static void DoConvertFrom_SomeNumericalTextInCurrentCulture_ReturnConvertedRoundedDouble(double input)
+ {
+ // Setup
+ string text = input.ToString(CultureInfo.CurrentCulture);
+
+ var converter = new RoundedDoubleConverter();
+
+ // Call
+ RoundedDouble conversionResult = (RoundedDouble)converter.ConvertFrom(null, CultureInfo.CurrentCulture, text);
+
+ // Assert
+ Assert.IsNotNull(conversionResult);
+ Assert.AreEqual(RoundedDouble.MaximumNumberOfDecimalPlaces, conversionResult.NumberOfDecimalPlaces);
+ Assert.AreEqual(input, conversionResult.Value);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 93b256575fba3e4068baadeeb62140533336371a refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Gui.Test/Converters/RoundedDoubleConverterTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj
===================================================================
diff -u -ra5b051a25a6bb059d5928e29a8d741a8ec31fcd5 -r93b256575fba3e4068baadeeb62140533336371a
--- Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision a5b051a25a6bb059d5928e29a8d741a8ec31fcd5)
+++ Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -112,7 +112,6 @@
-
Index: Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoDikeAssessmentSectionCommand.cs
===================================================================
diff -u -raf38c7a9724254095e2e3a631dd7e974465a1fb9 -r93b256575fba3e4068baadeeb62140533336371a
--- Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoDikeAssessmentSectionCommand.cs (.../AddNewDemoDikeAssessmentSectionCommand.cs) (revision af38c7a9724254095e2e3a631dd7e974465a1fb9)
+++ Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoDikeAssessmentSectionCommand.cs (.../AddNewDemoDikeAssessmentSectionCommand.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -117,10 +117,10 @@
var calculation = pipingFailureMechanism.CalculationsGroup.GetPipingCalculations().First();
calculation.InputParameters.SetSurfaceLine(pipingFailureMechanism.SurfaceLines.First(sl => sl.Name == "PK001_0001"));
calculation.InputParameters.SoilProfile = pipingFailureMechanism.SoilProfiles.First(sl => sl.Name == "AD640M00_Segment_36005_1D2");
- calculation.InputParameters.PhreaticLevelExit.Mean = 3;
+ calculation.InputParameters.PhreaticLevelExit.Mean = (RoundedDouble)3;
calculation.InputParameters.AssessmentLevel = (RoundedDouble)0.0;
- calculation.InputParameters.ThicknessCoverageLayer = new LognormalDistribution();
- calculation.InputParameters.ThicknessAquiferLayer = new LognormalDistribution();
+ calculation.InputParameters.ThicknessCoverageLayer = new LognormalDistribution(2);
+ calculation.InputParameters.ThicknessAquiferLayer = new LognormalDistribution(2);
}
}
}
\ No newline at end of file
Index: Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoDikeAssessmentSectionCommandTest.cs
===================================================================
diff -u -ra5b051a25a6bb059d5928e29a8d741a8ec31fcd5 -r93b256575fba3e4068baadeeb62140533336371a
--- Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoDikeAssessmentSectionCommandTest.cs (.../AddNewDemoDikeAssessmentSectionCommandTest.cs) (revision a5b051a25a6bb059d5928e29a8d741a8ec31fcd5)
+++ Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoDikeAssessmentSectionCommandTest.cs (.../AddNewDemoDikeAssessmentSectionCommandTest.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -135,11 +135,11 @@
PipingCalculationService.Calculate(calculation);
Assert.IsTrue(calculation.HasOutput);
Assert.AreEqual(99.0, calculation.Output.HeaveFactorOfSafety, 1e-3);
- Assert.AreEqual(118.627, calculation.Output.HeaveZValue, 1e-3);
+ Assert.AreEqual(116.706, calculation.Output.HeaveZValue, 1e-3);
Assert.AreEqual(99.0, calculation.Output.UpliftFactorOfSafety, 1e-3);
Assert.AreEqual(3.655, calculation.Output.UpliftZValue, 1e-3);
- Assert.AreEqual(-1.384, calculation.Output.SellmeijerFactorOfSafety, 1e-3);
- Assert.AreEqual(3.239, calculation.Output.SellmeijerZValue, 1e-3);
+ Assert.AreEqual(-1.391, calculation.Output.SellmeijerFactorOfSafety, 1e-3);
+ Assert.AreEqual(3.248, calculation.Output.SellmeijerZValue, 1e-3);
}
private static void AssertExpectedPipingInput(PipingInput inputParameters)
@@ -167,8 +167,8 @@
Assert.AreEqual(0.011, PipingSemiProbabilisticDesignValueFactory.GetThicknessCoverageLayer(inputParameters).GetDesignValue(), 1e-3);
Assert.AreEqual(81.175842733588766, PipingSemiProbabilisticDesignValueFactory.GetSeepageLength(inputParameters).GetDesignValue(), 1e-2);
Assert.AreEqual(0.011, PipingSemiProbabilisticDesignValueFactory.GetDiameter70(inputParameters).GetDesignValue(), 1e-3);
- Assert.AreEqual(2.345, PipingSemiProbabilisticDesignValueFactory.GetDarcyPermeability(inputParameters).GetDesignValue(), 1e-3);
- Assert.AreEqual(2.345, PipingSemiProbabilisticDesignValueFactory.GetThicknessAquiferLayer(inputParameters).GetDesignValue(), 1e-3);
+ Assert.AreEqual(2.347, PipingSemiProbabilisticDesignValueFactory.GetDarcyPermeability(inputParameters).GetDesignValue(), 1e-3);
+ Assert.AreEqual(2.35, PipingSemiProbabilisticDesignValueFactory.GetThicknessAquiferLayer(inputParameters).GetDesignValue(), 1e-2);
}
}
}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingInput.cs
===================================================================
diff -u -raf38c7a9724254095e2e3a631dd7e974465a1fb9 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingInput.cs (.../PipingInput.cs) (revision af38c7a9724254095e2e3a631dd7e974465a1fb9)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingInput.cs (.../PipingInput.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -62,26 +62,26 @@
entryPointL = new RoundedDouble(2, double.NaN);
assessmentLevel = new RoundedDouble(2, double.NaN);
- PhreaticLevelExit = new NormalDistribution();
- DampingFactorExit = new LognormalDistribution
+ PhreaticLevelExit = new NormalDistribution(3);
+ DampingFactorExit = new LognormalDistribution(3)
{
- Mean = 1.0
+ Mean = (RoundedDouble)1.0
};
- ThicknessCoverageLayer = new LognormalDistribution
+ ThicknessCoverageLayer = new LognormalDistribution(2)
{
- Mean = double.NaN,
+ Mean = (RoundedDouble)double.NaN,
StandardDeviation = 0.5
};
- SeepageLength = new LognormalDistribution
+ SeepageLength = new LognormalDistribution(2)
{
- Mean = double.NaN,
+ Mean = (RoundedDouble)double.NaN,
StandardDeviation = double.NaN
};
- Diameter70 = new LognormalDistribution();
- DarcyPermeability = new LognormalDistribution();
- ThicknessAquiferLayer = new LognormalDistribution
+ Diameter70 = new LognormalDistribution(2);
+ DarcyPermeability = new LognormalDistribution(3);
+ ThicknessAquiferLayer = new LognormalDistribution(2)
{
- Mean = double.NaN,
+ Mean = (RoundedDouble)double.NaN,
StandardDeviation = 0.5
};
}
@@ -319,7 +319,7 @@
}
catch (ArgumentOutOfRangeException e)
{
- SeepageLength.Mean = double.NaN;
+ SeepageLength.Mean = (RoundedDouble)double.NaN;
}
SeepageLength.StandardDeviation = SeepageLength.Mean * seepageLengthStandardDeviationFraction;
}
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Probabilistics/IDistribution.cs
===================================================================
diff -u -ra53a95e1f5f86ce62a66dbca8b71983096c7b766 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/Probabilistics/IDistribution.cs (.../IDistribution.cs) (revision a53a95e1f5f86ce62a66dbca8b71983096c7b766)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Probabilistics/IDistribution.cs (.../IDistribution.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -21,6 +21,8 @@
using System;
+using Core.Common.Base.Data;
+
namespace Ringtoets.Piping.Data.Probabilistics
{
///
@@ -31,7 +33,7 @@
///
/// Gets or sets the mean (expected value, E(X)) of the distribution.
///
- double Mean { get; set; }
+ RoundedDouble Mean { get; set; }
///
/// Gets or sets the standard deviation (square root of the Var(X)) of the distribution.
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Probabilistics/LognormalDistribution.cs
===================================================================
diff -u -ra53a95e1f5f86ce62a66dbca8b71983096c7b766 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/Probabilistics/LognormalDistribution.cs (.../LognormalDistribution.cs) (revision a53a95e1f5f86ce62a66dbca8b71983096c7b766)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Probabilistics/LognormalDistribution.cs (.../LognormalDistribution.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -21,6 +21,8 @@
using System;
+using Core.Common.Base.Data;
+
using Ringtoets.Piping.Data.Properties;
namespace Ringtoets.Piping.Data.Probabilistics
@@ -31,24 +33,34 @@
public class LognormalDistribution : IDistribution
{
private double standardDeviation;
- private double mean;
+ private RoundedDouble mean;
///
/// Initializes a new instance of the class,
/// initialized as the standard log-normal distribution (mu=0, sigma=1).
///
- public LognormalDistribution()
+ /// The number of decimal places.
+ ///
+ /// Thrown when is not in range [1, ].
+ ///
+ public LognormalDistribution(int numberOfDecimalPlaces)
{
+ if (numberOfDecimalPlaces == 0)
+ {
+ // This causes the default initialization set mean to 0, which is invalid.
+ throw new ArgumentOutOfRangeException("numberOfDecimalPlaces",
+ "Value must be in range [1, 15]");
+ }
// Simplified calculation mean and standard deviation given mu=0 and sigma=1.
- mean = Math.Exp(-0.5);
+ mean = new RoundedDouble(numberOfDecimalPlaces, Math.Exp(-0.5));
StandardDeviation = Math.Sqrt((Math.Exp(1) - 1) * Math.Exp(1));
}
///
/// Gets or sets the mean (expected value, E(X)) of the distribution.
///
/// Expected value is less then or equal to 0.
- public double Mean
+ public RoundedDouble Mean
{
get
{
@@ -60,7 +72,7 @@
{
throw new ArgumentOutOfRangeException("value", Resources.LognormalDistribution_Mean_must_be_greater_equal_to_zero);
}
- mean = value;
+ mean = value.ToPrecision(mean.NumberOfDecimalPlaces);
}
}
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Probabilistics/NormalDistribution.cs
===================================================================
diff -u -ra53a95e1f5f86ce62a66dbca8b71983096c7b766 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/Probabilistics/NormalDistribution.cs (.../NormalDistribution.cs) (revision a53a95e1f5f86ce62a66dbca8b71983096c7b766)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Probabilistics/NormalDistribution.cs (.../NormalDistribution.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -21,6 +21,8 @@
using System;
+using Core.Common.Base.Data;
+
using Ringtoets.Piping.Data.Properties;
namespace Ringtoets.Piping.Data.Probabilistics
@@ -31,18 +33,33 @@
public class NormalDistribution : IDistribution
{
private double standardDeviation;
+ private RoundedDouble mean;
///
/// Initializes a new instance of the class,
/// initialized as the standard normal distribution.
///
- public NormalDistribution()
+ /// The number of decimal places.
+ ///
+ /// Thrown when is not in range [0, ].
+ ///
+ public NormalDistribution(int numberOfDecimalPlaces)
{
- Mean = 0.0;
+ mean = new RoundedDouble(numberOfDecimalPlaces, 0.0);
StandardDeviation = 1.0;
}
- public double Mean { get; set; }
+ public RoundedDouble Mean
+ {
+ get
+ {
+ return mean;
+ }
+ set
+ {
+ mean = value.ToPrecision(mean.NumberOfDecimalPlaces);
+ }
+ }
public double StandardDeviation
{
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Probabilistics/ShiftedLognormalDistribution.cs
===================================================================
diff -u -r4512af7782ee31b36941bb280b54d9da2953dd71 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/Probabilistics/ShiftedLognormalDistribution.cs (.../ShiftedLognormalDistribution.cs) (revision 4512af7782ee31b36941bb280b54d9da2953dd71)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Probabilistics/ShiftedLognormalDistribution.cs (.../ShiftedLognormalDistribution.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -19,6 +19,8 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using Core.Common.Base.Data;
+
namespace Ringtoets.Piping.Data.Probabilistics
{
///
@@ -28,6 +30,16 @@
public class ShiftedLognormalDistribution : LognormalDistribution
{
///
+ /// Initializes a new instance of the class,
+ /// initialized as the standard log-normal distribution (mu=0, sigma=1).
+ ///
+ /// The number of decimal places.
+ ///
+ /// Thrown when is not in range [0, ].
+ ///
+ public ShiftedLognormalDistribution(int numberOfDecimalPlaces) : base(numberOfDecimalPlaces) {}
+
+ ///
/// Gets or sets the shift applied to the log-normal distribution.
///
public double Shift { get; set; }
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Extensions/PipingInputExtensions.cs
===================================================================
diff -u -ra5b051a25a6bb059d5928e29a8d741a8ec31fcd5 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Extensions/PipingInputExtensions.cs (.../PipingInputExtensions.cs) (revision a5b051a25a6bb059d5928e29a8d741a8ec31fcd5)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Extensions/PipingInputExtensions.cs (.../PipingInputExtensions.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -102,11 +102,11 @@
{
try
{
- input.ThicknessAquiferLayer.Mean = thicknessTopAquiferLayer;
+ input.ThicknessAquiferLayer.Mean = (RoundedDouble)thicknessTopAquiferLayer;
}
catch (ArgumentOutOfRangeException)
{
- input.ThicknessAquiferLayer.Mean = double.NaN;
+ input.ThicknessAquiferLayer.Mean = (RoundedDouble)double.NaN;
}
}
@@ -141,11 +141,11 @@
{
try
{
- input.ThicknessCoverageLayer.Mean = derivedThickness;
+ input.ThicknessCoverageLayer.Mean = (RoundedDouble)derivedThickness;
}
catch (ArgumentOutOfRangeException)
{
- input.ThicknessCoverageLayer.Mean = Double.NaN;
+ input.ThicknessCoverageLayer.Mean = (RoundedDouble)Double.NaN;
}
}
@@ -154,7 +154,7 @@
if (input.SurfaceLine == null)
{
input.ExitPointL = (RoundedDouble)double.NaN;
- input.SeepageLength.Mean = double.NaN;
+ input.SeepageLength.Mean = (RoundedDouble)double.NaN;
}
else
{
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs
===================================================================
diff -u -raf38c7a9724254095e2e3a631dd7e974465a1fb9 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision af38c7a9724254095e2e3a631dd7e974465a1fb9)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -25,7 +25,7 @@
using System.Drawing.Design;
using Core.Common.Base.Data;
-using Core.Common.Gui.Converters;
+using Core.Common.Base.TypeConverters;
using Core.Common.Gui.PropertyBag;
using Core.Common.Utils.Attributes;
using Ringtoets.HydraRing.Data;
@@ -295,7 +295,6 @@
#region Uplift
- [TypeConverter(typeof(RoundedDoubleConverter))]
[ResourcesCategory(typeof(Resources), "Categories_Uplift")]
[ResourcesDisplayName(typeof(Resources), "PipingInput_EntryPointL_DisplayName")]
[ResourcesDescription(typeof(Resources), "PipingInput_EntryPointL_Description")]
@@ -312,7 +311,6 @@
}
}
- [TypeConverter(typeof(RoundedDoubleConverter))]
[ResourcesCategory(typeof(Resources), "Categories_Uplift")]
[ResourcesDisplayName(typeof(Resources), "PipingInput_ExitPointL_DisplayName")]
[ResourcesDescription(typeof(Resources), "PipingInput_ExitPointL_Description")]
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/DesignVariableTypeConverter.cs
===================================================================
diff -u -r428346aca4810ed68d8778943246f581cb1a4386 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/DesignVariableTypeConverter.cs (.../DesignVariableTypeConverter.cs) (revision 428346aca4810ed68d8778943246f581cb1a4386)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/DesignVariableTypeConverter.cs (.../DesignVariableTypeConverter.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -25,6 +25,7 @@
using System.Linq;
using System.Linq.Expressions;
using Core.Common.Base;
+using Core.Common.Base.Data;
using Core.Common.Gui.PropertyBag;
using Ringtoets.Piping.Data.Probabilistics;
@@ -136,11 +137,25 @@
/// Type of object which as the parameter.
protected class ParameterDefinition
{
+ readonly Func getRoundedDouble;
+
///
/// Instantiates a new instance of for a
/// given parameter.
///
/// The parameter expression.
+ public ParameterDefinition(Expression> expression)
+ {
+ PropertyName = ((MemberExpression)expression.Body).Member.Name;
+ getRoundedDouble = expression.Compile();
+ GetValue = type => getRoundedDouble(type).Value;
+ }
+
+ ///
+ /// Instantiates a new instance of for a
+ /// given parameter.
+ ///
+ /// The parameter expression.
public ParameterDefinition(Expression> expression)
{
PropertyName = ((MemberExpression)expression.Body).Member.Name;
@@ -177,6 +192,8 @@
{
return String.Format("{0} = {1}",
Symbol,
+ getRoundedDouble != null ?
+ getRoundedDouble(distribution).ToString() :
GetValue(distribution).ToString(culture));
}
}
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs
===================================================================
diff -u -raf38c7a9724254095e2e3a631dd7e974465a1fb9 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs (.../PipingInputTest.cs) (revision af38c7a9724254095e2e3a631dd7e974465a1fb9)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs (.../PipingInputTest.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -26,19 +26,27 @@
Assert.IsInstanceOf(inputParameters);
Assert.IsInstanceOf(inputParameters.PhreaticLevelExit);
- Assert.AreEqual(0, inputParameters.PhreaticLevelExit.Mean);
+ Assert.AreEqual(0, inputParameters.PhreaticLevelExit.Mean.Value);
+ Assert.AreEqual(3, inputParameters.PhreaticLevelExit.Mean.NumberOfDecimalPlaces);
Assert.AreEqual(1, inputParameters.PhreaticLevelExit.StandardDeviation);
double defaultLogNormalMean = Math.Exp(-0.5);
double defaultLogNormalStandardDev = Math.Sqrt((Math.Exp(1) - 1) * Math.Exp(1));
Assert.IsInstanceOf(inputParameters.DampingFactorExit);
- Assert.AreEqual(1, inputParameters.DampingFactorExit.Mean);
+ Assert.AreEqual(1, inputParameters.DampingFactorExit.Mean.Value);
+ Assert.AreEqual(3, inputParameters.DampingFactorExit.Mean.NumberOfDecimalPlaces);
Assert.AreEqual(defaultLogNormalStandardDev, inputParameters.DampingFactorExit.StandardDeviation);
+
Assert.IsInstanceOf(inputParameters.Diameter70);
- Assert.AreEqual(defaultLogNormalMean, inputParameters.Diameter70.Mean);
+ Assert.AreEqual(defaultLogNormalMean, inputParameters.Diameter70.Mean,
+ Math.Pow(10.0, -inputParameters.Diameter70.Mean.NumberOfDecimalPlaces));
+ Assert.AreEqual(2, inputParameters.Diameter70.Mean.NumberOfDecimalPlaces);
Assert.AreEqual(defaultLogNormalStandardDev, inputParameters.Diameter70.StandardDeviation);
+
Assert.IsInstanceOf(inputParameters.DarcyPermeability);
- Assert.AreEqual(defaultLogNormalMean, inputParameters.DarcyPermeability.Mean);
+ Assert.AreEqual(defaultLogNormalMean, inputParameters.DarcyPermeability.Mean,
+ Math.Pow(10.0, -inputParameters.DarcyPermeability.Mean.NumberOfDecimalPlaces));
+ Assert.AreEqual(3, inputParameters.DarcyPermeability.Mean.NumberOfDecimalPlaces);
Assert.AreEqual(defaultLogNormalStandardDev, inputParameters.DarcyPermeability.StandardDeviation);
Assert.AreEqual(0, inputParameters.PiezometricHeadExit);
@@ -61,22 +69,27 @@
Assert.IsInstanceOf(inputParameters.ThicknessCoverageLayer);
Assert.IsNaN(inputParameters.ThicknessCoverageLayer.Mean);
+ Assert.AreEqual(2, inputParameters.ThicknessCoverageLayer.Mean.NumberOfDecimalPlaces);
Assert.AreEqual(0.5, inputParameters.ThicknessCoverageLayer.StandardDeviation);
Assert.IsInstanceOf(inputParameters.ThicknessAquiferLayer);
Assert.IsNaN(inputParameters.ThicknessAquiferLayer.Mean);
+ Assert.AreEqual(2, inputParameters.ThicknessAquiferLayer.Mean.NumberOfDecimalPlaces);
Assert.AreEqual(0.5, inputParameters.ThicknessAquiferLayer.StandardDeviation);
Assert.IsInstanceOf(inputParameters.SeepageLength);
Assert.IsNaN(inputParameters.SeepageLength.Mean);
+ Assert.AreEqual(2, inputParameters.SeepageLength.Mean.NumberOfDecimalPlaces);
Assert.IsNaN(inputParameters.SeepageLength.StandardDeviation);
Assert.IsNaN(inputParameters.ExitPointL);
+ Assert.AreEqual(2, inputParameters.ExitPointL.NumberOfDecimalPlaces);
Assert.IsNaN(inputParameters.EntryPointL);
+ Assert.AreEqual(2, inputParameters.EntryPointL.NumberOfDecimalPlaces);
Assert.IsInstanceOf(inputParameters.AssessmentLevel);
Assert.AreEqual(2, inputParameters.AssessmentLevel.NumberOfDecimalPlaces);
- Assert.IsNaN(inputParameters.AssessmentLevel.Value);
+ Assert.IsNaN(inputParameters.AssessmentLevel);
}
[Test]
@@ -171,7 +184,7 @@
pipingInput.EntryPointL = (RoundedDouble)entryPointL;
// Assert
- Assert.AreEqual(expectedSeepageLength, pipingInput.SeepageLength.Mean);
+ Assert.AreEqual(expectedSeepageLength, pipingInput.SeepageLength.Mean.Value);
Assert.AreEqual(expectedSeepageLength * 0.1, pipingInput.SeepageLength.StandardDeviation);
}
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/LognormalDistributionDesignVariableTest.cs
===================================================================
diff -u -r28b7fb952f3f2beb4beb5df841ba1b563d0b0def -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/LognormalDistributionDesignVariableTest.cs (.../LognormalDistributionDesignVariableTest.cs) (revision 28b7fb952f3f2beb4beb5df841ba1b563d0b0def)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/LognormalDistributionDesignVariableTest.cs (.../LognormalDistributionDesignVariableTest.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -1,5 +1,7 @@
using System;
+using Core.Common.Base.Data;
+
using NUnit.Framework;
using Ringtoets.Piping.Data.Probabilistics;
@@ -13,7 +15,7 @@
public void ParameterdConstructor_ValidLognormalDistribution_ExpectedValues()
{
// Setup
- var lognormalDistribution = new LognormalDistribution();
+ var lognormalDistribution = new LognormalDistribution(2);
// Call
var designValue = new LognormalDistributionDesignVariable(lognormalDistribution);
@@ -44,9 +46,9 @@
double expectedResult)
{
// Setup
- var lognormalDistribution = new LognormalDistribution
+ var lognormalDistribution = new LognormalDistribution(4)
{
- Mean = expectedValue,
+ Mean = (RoundedDouble)expectedValue,
StandardDeviation = Math.Sqrt(variance)
};
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/LognormalDistributionTest.cs
===================================================================
diff -u -ra53a95e1f5f86ce62a66dbca8b71983096c7b766 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/LognormalDistributionTest.cs (.../LognormalDistributionTest.cs) (revision a53a95e1f5f86ce62a66dbca8b71983096c7b766)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/LognormalDistributionTest.cs (.../LognormalDistributionTest.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -1,5 +1,7 @@
using System;
+using Core.Common.Base.Data;
+
using NUnit.Framework;
using Ringtoets.Piping.Data.Probabilistics;
@@ -10,27 +12,44 @@
public class LognormalDistributionTest
{
[Test]
- public void DefaultConstructor_ExpectedValues()
+ [TestCase(1)]
+ [TestCase(9)]
+ [TestCase(15)]
+ public void DefaultConstructor_ExpectedValues(int numberOfDecimalPlaces)
{
// Call
- var distribution = new LognormalDistribution();
+ var distribution = new LognormalDistribution(numberOfDecimalPlaces);
// Assert
Assert.IsInstanceOf(distribution);
- Assert.AreEqual(Math.Exp(-0.5), distribution.Mean);
+ Assert.AreEqual(Math.Exp(-0.5), distribution.Mean, Math.Pow(10.0, -numberOfDecimalPlaces));
+ Assert.AreEqual(numberOfDecimalPlaces, distribution.Mean.NumberOfDecimalPlaces);
Assert.AreEqual(Math.Sqrt((Math.Exp(1)-1)*Math.Exp(1)), distribution.StandardDeviation);
}
[Test]
[TestCase(0)]
+ public void Constructor_InvalidNumberOfDecimalPlaces_ThrowArgumentOutOfRangeException()
+ {
+ // Setup
+
+ // Call
+ TestDelegate call = () => new LognormalDistribution(0);
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ [TestCase(0)]
[TestCase(-123.45)]
public void Mean_SettingToLessThanOrEqualTo0_ThrowArgumentOutOfRangeException(double newMean)
{
// Setup
- var distribution = new LognormalDistribution();
+ var distribution = new LognormalDistribution(2);
// Call
- TestDelegate call = () => distribution.Mean = newMean;
+ TestDelegate call = () => distribution.Mean = (RoundedDouble)newMean;
// Assert
var exception = Assert.Throws(call);
@@ -39,18 +58,18 @@
}
[Test]
- [TestCase(0 + 1e-6)]
+ [TestCase(0 + 1e-4)]
[TestCase(156.23)]
public void Mean_SettingValidValue_ValueIsSet(double newMean)
{
// Setup
- var distribution = new LognormalDistribution();
+ var distribution = new LognormalDistribution(4);
// Call
- distribution.Mean = newMean;
+ distribution.Mean = (RoundedDouble)newMean;
// Assert
- Assert.AreEqual(newMean, distribution.Mean);
+ Assert.AreEqual(newMean, distribution.Mean, 1e-4);
}
[Test]
@@ -59,7 +78,7 @@
public void StandardDeviation_SettingNotGreaterThan0_ThrowArgumentOutOfRangeException(double newStd)
{
// Setup
- var distribution = new LognormalDistribution();
+ var distribution = new LognormalDistribution(4);
// Call
TestDelegate call = () => distribution.StandardDeviation = newStd;
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/NormalDistributionDesignVariableTest.cs
===================================================================
diff -u -r28b7fb952f3f2beb4beb5df841ba1b563d0b0def -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/NormalDistributionDesignVariableTest.cs (.../NormalDistributionDesignVariableTest.cs) (revision 28b7fb952f3f2beb4beb5df841ba1b563d0b0def)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/NormalDistributionDesignVariableTest.cs (.../NormalDistributionDesignVariableTest.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -1,5 +1,7 @@
using System;
+using Core.Common.Base.Data;
+
using NUnit.Framework;
using Ringtoets.Piping.Data.Probabilistics;
@@ -13,7 +15,7 @@
public void ParameterdConstructor_ValidLognormalDistribution_ExpectedValues()
{
// Setup
- var normalDistribution = new NormalDistribution();
+ var normalDistribution = new NormalDistribution(3);
// Call
var designValue = new NormalDistributionDesignVariable(normalDistribution);
@@ -44,9 +46,9 @@
double expectedResult)
{
// Setup
- var normalDistribution = new NormalDistribution
+ var normalDistribution = new NormalDistribution(4)
{
- Mean = expectedValue,
+ Mean = (RoundedDouble)expectedValue,
StandardDeviation = Math.Sqrt(variance)
};
@@ -59,7 +61,7 @@
double result = designVariable.GetDesignValue();
// Assert
- Assert.AreEqual(expectedResult, result, 1e-6);
+ Assert.AreEqual(expectedResult, result, 1e-4);
}
}
}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/NormalDistributionTest.cs
===================================================================
diff -u -ra53a95e1f5f86ce62a66dbca8b71983096c7b766 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/NormalDistributionTest.cs (.../NormalDistributionTest.cs) (revision a53a95e1f5f86ce62a66dbca8b71983096c7b766)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/NormalDistributionTest.cs (.../NormalDistributionTest.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -10,14 +10,18 @@
public class NomalDistributionTest
{
[Test]
- public void DefaultConstructor_ExpectedValues()
+ [TestCase(0)]
+ [TestCase(2)]
+ [TestCase(15)]
+ public void DefaultConstructor_ExpectedValues(int numberOfDecimalPlaces)
{
// Call
- var distribution = new NormalDistribution();
+ var distribution = new NormalDistribution(numberOfDecimalPlaces);
// Assert
Assert.IsInstanceOf(distribution);
- Assert.AreEqual(0.0, distribution.Mean);
+ Assert.AreEqual(0.0, distribution.Mean, Math.Pow(10.0, -numberOfDecimalPlaces));
+ Assert.AreEqual(numberOfDecimalPlaces, distribution.Mean.NumberOfDecimalPlaces);
Assert.AreEqual(1.0, distribution.StandardDeviation);
}
@@ -27,7 +31,7 @@
public void StandardDeviation_SettingNotGreaterThan0_ThrowArgumentOutOfRangeException(double newStd)
{
// Setup
- var distribution = new NormalDistribution();
+ var distribution = new NormalDistribution(2);
// Call
TestDelegate call = () => distribution.StandardDeviation = newStd;
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/ShiftedLognormalDistributionDesignVariableTest.cs
===================================================================
diff -u -r28b7fb952f3f2beb4beb5df841ba1b563d0b0def -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/ShiftedLognormalDistributionDesignVariableTest.cs (.../ShiftedLognormalDistributionDesignVariableTest.cs) (revision 28b7fb952f3f2beb4beb5df841ba1b563d0b0def)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/ShiftedLognormalDistributionDesignVariableTest.cs (.../ShiftedLognormalDistributionDesignVariableTest.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -1,5 +1,7 @@
using System;
+using Core.Common.Base.Data;
+
using NUnit.Framework;
using Ringtoets.Piping.Data.Probabilistics;
@@ -13,7 +15,7 @@
public void ParameterdConstructor_ValidLognormalDistribution_ExpectedValues()
{
// Setup
- var shiftedLognormalDistribution = new ShiftedLognormalDistribution();
+ var shiftedLognormalDistribution = new ShiftedLognormalDistribution(1);
// Call
var designValue = new ShiftedLognormalDistributionDesignVariable(shiftedLognormalDistribution);
@@ -47,9 +49,9 @@
double expectedResult)
{
// Setup
- var shiftedLognormalDistribution = new ShiftedLognormalDistribution
+ var shiftedLognormalDistribution = new ShiftedLognormalDistribution(4)
{
- Mean = expectedValue,
+ Mean = (RoundedDouble)expectedValue,
StandardDeviation = Math.Sqrt(variance),
Shift = shift
};
@@ -78,9 +80,9 @@
double expectedValue, double variance, double percentile)
{
// Setup
- var shiftedLognormalDistribution = new ShiftedLognormalDistribution
+ var shiftedLognormalDistribution = new ShiftedLognormalDistribution(6)
{
- Mean = expectedValue,
+ Mean = (RoundedDouble)expectedValue,
StandardDeviation = Math.Sqrt(variance),
Shift = 0
};
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/ShiftedLognormalDistributionTest.cs
===================================================================
diff -u -r394db7c1bd905eb7444b9b2c47bcb5111bb63af6 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/ShiftedLognormalDistributionTest.cs (.../ShiftedLognormalDistributionTest.cs) (revision 394db7c1bd905eb7444b9b2c47bcb5111bb63af6)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Probabilistics/ShiftedLognormalDistributionTest.cs (.../ShiftedLognormalDistributionTest.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -8,10 +8,13 @@
public class ShiftedLognormalDistributionTest
{
[Test]
- public void DefaultConstructor_ExpectedValues()
+ [TestCase(1)]
+ [TestCase(4)]
+ [TestCase(15)]
+ public void DefaultConstructor_ExpectedValues(int numberOfDecimalPlaces)
{
// Call
- var distribution = new ShiftedLognormalDistribution();
+ var distribution = new ShiftedLognormalDistribution(numberOfDecimalPlaces);
// Assert
Assert.IsInstanceOf(distribution);
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingCalculationFactory.cs
===================================================================
diff -u -rcd01ebb93138126cff40f436c309ee8b4bc9069e -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingCalculationFactory.cs (.../PipingCalculationFactory.cs) (revision cd01ebb93138126cff40f436c309ee8b4bc9069e)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingCalculationFactory.cs (.../PipingCalculationFactory.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -53,34 +53,34 @@
AssessmentLevel = (RoundedDouble)1.0,
DampingFactorExit =
{
- Mean = 1.0
+ Mean = (RoundedDouble)1.0
},
DarcyPermeability =
{
- Mean = 1.0
+ Mean = (RoundedDouble)1.0
},
Diameter70 =
{
- Mean = 1.0
+ Mean = (RoundedDouble)1.0
},
ExitPointL = (RoundedDouble)1.0,
PiezometricHeadExit = 1.0,
PiezometricHeadPolder = 1.0,
PhreaticLevelExit =
{
- Mean = 2.0
+ Mean = (RoundedDouble)2.0
},
SeepageLength =
{
- Mean = 1.0
+ Mean = (RoundedDouble)1.0
},
ThicknessAquiferLayer =
{
- Mean = 1.0
+ Mean = (RoundedDouble)1.0
},
ThicknessCoverageLayer =
{
- Mean = 1.0
+ Mean = (RoundedDouble)1.0
},
SurfaceLine = surfaceLine,
SoilProfile = soilProfile
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Extensions/PipingInputExtensionsTest.cs
===================================================================
diff -u -ra5b051a25a6bb059d5928e29a8d741a8ec31fcd5 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Extensions/PipingInputExtensionsTest.cs (.../PipingInputExtensionsTest.cs) (revision a5b051a25a6bb059d5928e29a8d741a8ec31fcd5)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Extensions/PipingInputExtensionsTest.cs (.../PipingInputExtensionsTest.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -36,7 +36,7 @@
inputParameters.SetSurfaceLine(surfaceLine);
// Assert
- Assert.AreEqual(secondPointX - firstPointX, inputParameters.SeepageLength.Mean);
+ Assert.AreEqual(secondPointX - firstPointX, inputParameters.SeepageLength.Mean.Value);
Assert.AreEqual(secondPointX - firstPointX, inputParameters.ExitPointL.Value);
}
@@ -88,7 +88,7 @@
inputParameters.SetSurfaceLine(surfaceLine);
// Assert
- Assert.AreEqual(secondPointX - firstPointX, inputParameters.SeepageLength.Mean);
+ Assert.AreEqual(secondPointX - firstPointX, inputParameters.SeepageLength.Mean.Value);
Assert.AreEqual(secondPointX - firstPointX, inputParameters.ExitPointL.Value);
}
@@ -116,7 +116,7 @@
inputParameters.SetSurfaceLine(surfaceLine);
// Assert
- Assert.AreEqual(2.0, inputParameters.SeepageLength.Mean);
+ Assert.AreEqual(2.0, inputParameters.SeepageLength.Mean.Value);
Assert.AreEqual(0.2, inputParameters.SeepageLength.StandardDeviation);
Assert.AreEqual(secondPointX - firstPointX, inputParameters.ExitPointL.Value);
}
@@ -145,7 +145,7 @@
inputParameters.SetSurfaceLine(surfaceLine);
// Assert
- Assert.AreEqual(2.0, inputParameters.SeepageLength.Mean);
+ Assert.AreEqual(2.0, inputParameters.SeepageLength.Mean.Value);
Assert.AreEqual(0.2, inputParameters.SeepageLength.StandardDeviation);
Assert.AreEqual(thirdPointX - firstPointX, inputParameters.ExitPointL.Value);
}
@@ -290,8 +290,7 @@
input.SetExitPointL(input.ExitPointL);
// Assert
- var thickness = input.ThicknessCoverageLayer.Mean;
- Assert.AreEqual(1.0, thickness);
+ Assert.AreEqual(1.0, input.ThicknessCoverageLayer.Mean.Value);
}
[Test]
@@ -395,8 +394,7 @@
input.SetSurfaceLine(input.SurfaceLine);
// Assert
- var thickness = input.ThicknessCoverageLayer.Mean;
- Assert.AreEqual(1.0, thickness);
+ Assert.AreEqual(1.0, input.ThicknessCoverageLayer.Mean.Value);
}
[Test]
@@ -411,7 +409,7 @@
// Assert
Assert.AreEqual(1.0, input.ExitPointL.Value);
- Assert.AreEqual(1.0, input.ThicknessCoverageLayer.Mean);
+ Assert.AreEqual(1.0, input.ThicknessCoverageLayer.Mean.Value);
}
[Test]
@@ -499,8 +497,7 @@
input.SetSoilProfile(input.SoilProfile);
// Assert
- var thickness = input.ThicknessCoverageLayer.Mean;
- Assert.AreEqual(1.0, thickness);
+ Assert.AreEqual(1.0, input.ThicknessCoverageLayer.Mean.Value);
}
[Test]
@@ -607,7 +604,7 @@
input.SetExitPointL(input.ExitPointL);
// Assert
- Assert.AreEqual(1.0, input.ThicknessAquiferLayer.Mean);
+ Assert.AreEqual(1.0, input.ThicknessAquiferLayer.Mean.Value);
}
[Test]
@@ -730,7 +727,7 @@
input.SetExitPointL(input.ExitPointL);
// Assert
- Assert.AreEqual(0.5, input.ThicknessAquiferLayer.Mean);
+ Assert.AreEqual(0.5, input.ThicknessAquiferLayer.Mean.Value);
}
[Test]
@@ -743,7 +740,7 @@
input.SetSurfaceLine(input.SurfaceLine);
// Assert
- Assert.AreEqual(1.0, input.ThicknessAquiferLayer.Mean);
+ Assert.AreEqual(1.0, input.ThicknessAquiferLayer.Mean.Value);
}
[Test]
@@ -758,7 +755,7 @@
// Assert
Assert.AreEqual(1.0, input.ExitPointL.Value);
- Assert.AreEqual(1.0, input.ThicknessAquiferLayer.Mean);
+ Assert.AreEqual(1.0, input.ThicknessAquiferLayer.Mean.Value);
}
[Test]
@@ -866,7 +863,7 @@
input.SetSurfaceLine(input.SurfaceLine);
// Assert
- Assert.AreEqual(0.5, input.ThicknessAquiferLayer.Mean);
+ Assert.AreEqual(0.5, input.ThicknessAquiferLayer.Mean.Value);
}
[Test]
@@ -879,7 +876,7 @@
input.SetSoilProfile(input.SoilProfile);
// Assert
- Assert.AreEqual(1.0, input.ThicknessAquiferLayer.Mean);
+ Assert.AreEqual(1.0, input.ThicknessAquiferLayer.Mean.Value);
}
[Test]
@@ -1002,7 +999,7 @@
input.SetSoilProfile(input.SoilProfile);
// Assert
- Assert.AreEqual(0.5, input.ThicknessAquiferLayer.Mean);
+ Assert.AreEqual(0.5, input.ThicknessAquiferLayer.Mean.Value);
}
#endregion
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs
===================================================================
diff -u -raf38c7a9724254095e2e3a631dd7e974465a1fb9 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision af38c7a9724254095e2e3a631dd7e974465a1fb9)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -149,13 +149,13 @@
double piezometricHeadExit = random.NextDouble();
double piezometricHeadPolder = random.NextDouble();
- var dampingFactorExit = new LognormalDistribution();
- var phreaticLevelExit = new NormalDistribution();
- var thicknessCoverageLayer = new LognormalDistribution();
- var seepageLength = new LognormalDistribution();
- var diameter70 = new LognormalDistribution();
- var darcyPermeability = new LognormalDistribution();
- var thicknessAquiferLayer = new LognormalDistribution();
+ var dampingFactorExit = new LognormalDistribution(3);
+ var phreaticLevelExit = new NormalDistribution(2);
+ var thicknessCoverageLayer = new LognormalDistribution(2);
+ var seepageLength = new LognormalDistribution(2);
+ var diameter70 = new LognormalDistribution(2);
+ var darcyPermeability = new LognormalDistribution(3);
+ var thicknessAquiferLayer = new LognormalDistribution(2);
var surfaceLine = ValidSurfaceLine(0.0, 4.0);
PipingSoilProfile soilProfile = new TestPipingSoilProfile();
@@ -268,7 +268,7 @@
// Call & Assert
- Assert.AreEqual(1.5, properties.SeepageLength.Distribution.Mean);
+ Assert.AreEqual(1.5, properties.SeepageLength.Distribution.Mean.Value);
Assert.AreEqual(properties.ExitPointL, inputParameters.ExitPointL);
Assert.AreEqual(properties.SeepageLength.Distribution.Mean, inputParameters.SeepageLength.Mean);
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationContextTreeNodeInfoTest.cs
===================================================================
diff -u -r1c01ea681887e96b5b80fb7d23680a4eeac9bd50 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationContextTreeNodeInfoTest.cs (.../PipingCalculationContextTreeNodeInfoTest.cs) (revision 1c01ea681887e96b5b80fb7d23680a4eeac9bd50)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationContextTreeNodeInfoTest.cs (.../PipingCalculationContextTreeNodeInfoTest.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using Core.Common.Base;
+using Core.Common.Base.Data;
using Core.Common.Controls.TreeView;
using Core.Common.Gui;
using Core.Common.Gui.ContextMenu;
@@ -624,16 +625,16 @@
plugin.Gui = gui;
calculation.InputParameters.AssessmentLevel = validPipingInput.AssessmentLevel;
- calculation.InputParameters.DampingFactorExit.Mean = validPipingInput.DampingFactorExit;
- calculation.InputParameters.DarcyPermeability.Mean = validPipingInput.DarcyPermeability;
- calculation.InputParameters.Diameter70.Mean = validPipingInput.Diameter70;
+ calculation.InputParameters.DampingFactorExit.Mean = (RoundedDouble)validPipingInput.DampingFactorExit;
+ calculation.InputParameters.DarcyPermeability.Mean = (RoundedDouble)validPipingInput.DarcyPermeability;
+ calculation.InputParameters.Diameter70.Mean = (RoundedDouble)validPipingInput.Diameter70;
calculation.InputParameters.ExitPointL = validPipingInput.ExitPointXCoordinate;
- calculation.InputParameters.PhreaticLevelExit.Mean = validPipingInput.PhreaticLevelExit;
+ calculation.InputParameters.PhreaticLevelExit.Mean = (RoundedDouble)validPipingInput.PhreaticLevelExit;
calculation.InputParameters.PiezometricHeadExit = validPipingInput.PiezometricHeadExit;
calculation.InputParameters.PiezometricHeadPolder = validPipingInput.PiezometricHeadPolder;
- calculation.InputParameters.SeepageLength.Mean = validPipingInput.SeepageLength;
- calculation.InputParameters.ThicknessAquiferLayer.Mean = validPipingInput.ThicknessAquiferLayer;
- calculation.InputParameters.ThicknessCoverageLayer.Mean = validPipingInput.ThicknessCoverageLayer;
+ calculation.InputParameters.SeepageLength.Mean = (RoundedDouble)validPipingInput.SeepageLength;
+ calculation.InputParameters.ThicknessAquiferLayer.Mean = (RoundedDouble)validPipingInput.ThicknessAquiferLayer;
+ calculation.InputParameters.ThicknessCoverageLayer.Mean = (RoundedDouble)validPipingInput.ThicknessCoverageLayer;
calculation.InputParameters.SurfaceLine = validPipingInput.SurfaceLine;
calculation.InputParameters.SoilProfile = validPipingInput.SoilProfile;
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/LognormalDistributionDesignVariableTypeConverterTest.cs
===================================================================
diff -u -r1c01ea681887e96b5b80fb7d23680a4eeac9bd50 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/LognormalDistributionDesignVariableTypeConverterTest.cs (.../LognormalDistributionDesignVariableTypeConverterTest.cs) (revision 1c01ea681887e96b5b80fb7d23680a4eeac9bd50)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/LognormalDistributionDesignVariableTypeConverterTest.cs (.../LognormalDistributionDesignVariableTypeConverterTest.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -2,6 +2,7 @@
using System.Linq;
using Core.Common.Base;
+using Core.Common.Base.Data;
using Core.Common.Gui.PropertyBag;
using NUnit.Framework;
@@ -46,9 +47,9 @@
public void ConvertTo_DestinationTypeIsString_ReturnLognormalDistributionSpecs()
{
// Setup
- var distribution = new LognormalDistribution
+ var distribution = new LognormalDistribution(1)
{
- Mean = 1.1,
+ Mean = (RoundedDouble)1.1,
StandardDeviation = 2.2
};
var designVariable = new LognormalDistributionDesignVariable(distribution);
@@ -81,7 +82,7 @@
public void GetProperties_Always_ReturnMeanAndStandardDeviation()
{
// Setup
- var distribution = new LognormalDistribution();
+ var distribution = new LognormalDistribution(2);
var designVariable = new LognormalDistributionDesignVariable(distribution);
var converter = new LognormalDistributionDesignVariableTypeConverter();
@@ -102,7 +103,7 @@
var meanPropertyDescriptor = properties[1];
Assert.AreEqual(distribution.GetType(), meanPropertyDescriptor.ComponentType);
- Assert.AreEqual(typeof(double), meanPropertyDescriptor.PropertyType);
+ Assert.AreEqual(typeof(RoundedDouble), meanPropertyDescriptor.PropertyType);
Assert.IsFalse(meanPropertyDescriptor.IsReadOnly);
Assert.AreEqual("Verwachtingswaarde", meanPropertyDescriptor.DisplayName);
Assert.AreEqual("De gemiddelde waarde van de lognormale verdeling.", meanPropertyDescriptor.Description);
@@ -161,17 +162,24 @@
Assert.IsNotNull(properties);
// Event
- const double newValue = 2.3;
- properties[propertyIndexToChange].SetValue(dampingFactorExitHeave, newValue);
-
+ const double newDoubleValue = 2.3;
+ if (propertyIndexToChange == 1)
+ {
+ properties[propertyIndexToChange].SetValue(dampingFactorExitHeave, (RoundedDouble)newDoubleValue);
+ }
+ else
+ {
+ properties[propertyIndexToChange].SetValue(dampingFactorExitHeave, newDoubleValue);
+ }
+
// Result
switch (propertyIndexToChange)
{
case 1:
- Assert.AreEqual(newValue, inputParameters.DampingFactorExit.Mean);
+ Assert.AreEqual(newDoubleValue, inputParameters.DampingFactorExit.Mean.Value);
break;
case 2:
- Assert.AreEqual(newValue, inputParameters.DampingFactorExit.StandardDeviation);
+ Assert.AreEqual(newDoubleValue, inputParameters.DampingFactorExit.StandardDeviation);
break;
}
mocks.VerifyAll();
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/NormalDistributionDesignVariableTypeConverterTest.cs
===================================================================
diff -u -r1c01ea681887e96b5b80fb7d23680a4eeac9bd50 -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/NormalDistributionDesignVariableTypeConverterTest.cs (.../NormalDistributionDesignVariableTypeConverterTest.cs) (revision 1c01ea681887e96b5b80fb7d23680a4eeac9bd50)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/NormalDistributionDesignVariableTypeConverterTest.cs (.../NormalDistributionDesignVariableTypeConverterTest.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -2,6 +2,7 @@
using System.Linq;
using Core.Common.Base;
+using Core.Common.Base.Data;
using Core.Common.Gui.PropertyBag;
using NUnit.Framework;
@@ -46,9 +47,9 @@
public void ConvertTo_DestinationTypeIsString_ReturnNormalDistributionSpecs()
{
// Setup
- var distribution = new NormalDistribution
+ var distribution = new NormalDistribution(2)
{
- Mean = 1.1,
+ Mean = (RoundedDouble)1.1,
StandardDeviation = 2.2
};
var designVariable = new NormalDistributionDesignVariable(distribution);
@@ -80,7 +81,7 @@
public void GetProperties_Always_ReturnMeanAndStandardDeviation()
{
// Setup
- var distribution = new NormalDistribution();
+ var distribution = new NormalDistribution(1);
var designVariable = new NormalDistributionDesignVariable(distribution);
var converter = new NormalDistributionDesignVariableTypeConverter();
@@ -101,7 +102,7 @@
var meanPropertyDescriptor = properties[1];
Assert.AreEqual(distribution.GetType(), meanPropertyDescriptor.ComponentType);
- Assert.AreEqual(typeof(double), meanPropertyDescriptor.PropertyType);
+ Assert.AreEqual(typeof(RoundedDouble), meanPropertyDescriptor.PropertyType);
Assert.IsFalse(meanPropertyDescriptor.IsReadOnly);
Assert.AreEqual("Verwachtingswaarde", meanPropertyDescriptor.DisplayName);
Assert.AreEqual("De gemiddelde waarde van de normale verdeling.", meanPropertyDescriptor.Description);
@@ -160,13 +161,20 @@
// Event
const double newValue = 2.3;
- properties[propertyIndexToChange].SetValue(phreaticLevelExitHeave, newValue);
+ if (propertyIndexToChange == 1)
+ {
+ properties[propertyIndexToChange].SetValue(phreaticLevelExitHeave, (RoundedDouble)newValue);
+ }
+ else
+ {
+ properties[propertyIndexToChange].SetValue(phreaticLevelExitHeave, newValue);
+ }
// Result
switch (propertyIndexToChange)
{
case 1:
- Assert.AreEqual(newValue, inputParameters.PhreaticLevelExit.Mean);
+ Assert.AreEqual(newValue, inputParameters.PhreaticLevelExit.Mean.Value);
break;
case 2:
Assert.AreEqual(newValue, inputParameters.PhreaticLevelExit.StandardDeviation);
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/ShiftedLognormalDistributionDesignVariableTypeConverterTest.cs
===================================================================
diff -u -r636f3e171b2d423e6716bed09cb241de68ea8a6a -r93b256575fba3e4068baadeeb62140533336371a
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/ShiftedLognormalDistributionDesignVariableTypeConverterTest.cs (.../ShiftedLognormalDistributionDesignVariableTypeConverterTest.cs) (revision 636f3e171b2d423e6716bed09cb241de68ea8a6a)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/ShiftedLognormalDistributionDesignVariableTypeConverterTest.cs (.../ShiftedLognormalDistributionDesignVariableTypeConverterTest.cs) (revision 93b256575fba3e4068baadeeb62140533336371a)
@@ -1,5 +1,7 @@
using System.ComponentModel;
+using Core.Common.Base.Data;
+
using NUnit.Framework;
using Ringtoets.Piping.Data.Probabilistics;
@@ -37,9 +39,9 @@
public void ConvertTo_DestinationTypeIsString_ReturnNormalDistributionSpecs()
{
// Setup
- var distribution = new ShiftedLognormalDistribution
+ var distribution = new ShiftedLognormalDistribution(5)
{
- Mean = 1.1,
+ Mean = (RoundedDouble)1.1,
StandardDeviation = 2.2,
Shift = 3.3
};
@@ -72,7 +74,7 @@
public void GetProperties_Always_ReturnMeanAndStandardDeviation()
{
// Setup
- var distribution = new ShiftedLognormalDistribution();
+ var distribution = new ShiftedLognormalDistribution(3);
var designVariable = new ShiftedLognormalDistributionDesignVariable(distribution);
var converter = new ShiftedLognormalDistributionDesignVariableTypeConverter();
@@ -93,7 +95,7 @@
var meanPropertyDescriptor = properties[1];
Assert.AreEqual(distribution.GetType().BaseType, meanPropertyDescriptor.ComponentType);
- Assert.AreEqual(typeof(double), meanPropertyDescriptor.PropertyType);
+ Assert.AreEqual(typeof(RoundedDouble), meanPropertyDescriptor.PropertyType);
Assert.IsFalse(meanPropertyDescriptor.IsReadOnly);
Assert.AreEqual("Verwachtingswaarde", meanPropertyDescriptor.DisplayName);
Assert.AreEqual("De gemiddelde waarde van de verschoven lognormale verdeling.", meanPropertyDescriptor.Description);