Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HeightStructures/HeightStructuresCalculationCreateExtensions.cs
===================================================================
diff -u -r50e7c9ffa6c528abd1a1ee61784f78d5983465fe -r8a11d2a7974d1fb39e142516dc3fd041e1eb4603
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HeightStructures/HeightStructuresCalculationCreateExtensions.cs (.../HeightStructuresCalculationCreateExtensions.cs) (revision 50e7c9ffa6c528abd1a1ee61784f78d5983465fe)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HeightStructures/HeightStructuresCalculationCreateExtensions.cs (.../HeightStructuresCalculationCreateExtensions.cs) (revision 8a11d2a7974d1fb39e142516dc3fd041e1eb4603)
@@ -78,6 +78,7 @@
entity.StructureNormalOrientation = input.StructureNormalOrientation.Value.ToNaNAsNull();
entity.ModelFactorSuperCriticalFlowMean = input.ModelFactorSuperCriticalFlow.Mean.Value.ToNaNAsNull();
+
entity.AllowedLevelIncreaseStorageMean = input.AllowedLevelIncreaseStorage.Mean.Value.ToNaNAsNull();
entity.AllowedLevelIncreaseStorageStandardDeviation = input.AllowedLevelIncreaseStorage.StandardDeviation.Value.ToNaNAsNull();
@@ -96,8 +97,10 @@
entity.WidthFlowAperturesCoefficientOfVariation = input.WidthFlowApertures.CoefficientOfVariation.Value.ToNaNAsNull();
entity.StormDurationMean = input.StormDuration.Mean.Value.ToNaNAsNull();
+
entity.LevelCrestStructureMean = input.LevelCrestStructure.Mean.Value.ToNaNAsNull();
entity.LevelCrestStructureStandardDeviation = input.LevelCrestStructure.StandardDeviation.Value.ToNaNAsNull();
+
entity.DeviationWaveDirection = input.DeviationWaveDirection.Value.ToNaNAsNull();
entity.BreakWaterHeight = input.BreakWater.Height.Value.ToNaNAsNull();
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructuresCalculationCreateExtensionsTest.cs
===================================================================
diff -u -r03a0bbc245b8da50ca603f18d5b9b8fb2d7593c5 -r8a11d2a7974d1fb39e142516dc3fd041e1eb4603
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructuresCalculationCreateExtensionsTest.cs (.../HeightStructuresCalculationCreateExtensionsTest.cs) (revision 03a0bbc245b8da50ca603f18d5b9b8fb2d7593c5)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructuresCalculationCreateExtensionsTest.cs (.../HeightStructuresCalculationCreateExtensionsTest.cs) (revision 8a11d2a7974d1fb39e142516dc3fd041e1eb4603)
@@ -66,47 +66,47 @@
Comments = comments,
InputParameters =
{
- StructureNormalOrientation = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 0, 360),
+ StructureNormalOrientation = (RoundedDouble) random.GetFromRange(0, 360),
ModelFactorSuperCriticalFlow =
{
- Mean = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, -9999.9999, 9999.9999)
+ Mean = (RoundedDouble) random.GetFromRange(-9999.9999, 9999.9999)
},
AllowedLevelIncreaseStorage =
{
- Mean = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- StandardDeviation = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999)
+ Mean = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999),
+ StandardDeviation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999)
},
StorageStructureArea =
{
- Mean = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- CoefficientOfVariation = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999)
+ Mean = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999),
+ CoefficientOfVariation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999)
},
FlowWidthAtBottomProtection =
{
- Mean = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- StandardDeviation = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999)
+ Mean = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999),
+ StandardDeviation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999)
},
CriticalOvertoppingDischarge =
{
- Mean = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- CoefficientOfVariation = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999)
+ Mean = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999),
+ CoefficientOfVariation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999)
},
FailureProbabilityStructureWithErosion = random.NextDouble(),
WidthFlowApertures =
{
- Mean = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, -9999.9999, 9999.9999),
- CoefficientOfVariation = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999)
+ Mean = (RoundedDouble) random.GetFromRange(-9999.9999, 9999.9999),
+ CoefficientOfVariation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999)
},
StormDuration =
{
- Mean = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- CoefficientOfVariation = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999)
+ Mean = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999),
+ CoefficientOfVariation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999)
},
DeviationWaveDirection = (RoundedDouble) random.NextDouble(),
LevelCrestStructure =
{
- Mean = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, -9999.9999, 9999.9999),
- StandardDeviation = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999)
+ Mean = (RoundedDouble) random.GetFromRange(-9999.9999, 9999.9999),
+ StandardDeviation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999)
},
UseBreakWater = true,
UseForeshore = false,
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructuresFailureMechanismCreateExtensionsTest.cs
===================================================================
diff -u -r64ad0bbe91a9c7e9229fa9800b93b65f619b9e31 -r8a11d2a7974d1fb39e142516dc3fd041e1eb4603
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructuresFailureMechanismCreateExtensionsTest.cs (.../HeightStructuresFailureMechanismCreateExtensionsTest.cs) (revision 64ad0bbe91a9c7e9229fa9800b93b65f619b9e31)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructuresFailureMechanismCreateExtensionsTest.cs (.../HeightStructuresFailureMechanismCreateExtensionsTest.cs) (revision 8a11d2a7974d1fb39e142516dc3fd041e1eb4603)
@@ -188,12 +188,14 @@
.OrderBy(cge => cge.Order)
.ToArray();
Assert.AreEqual(2, childGroupEntities.Length);
- Assert.AreEqual("A", childGroupEntities[0].Name);
- Assert.AreEqual(1, childGroupEntities[0].IsEditable);
- Assert.AreEqual(0, childGroupEntities[0].Order);
- Assert.AreEqual("B", childGroupEntities[1].Name);
- Assert.AreEqual(1, childGroupEntities[1].IsEditable);
- Assert.AreEqual(1, childGroupEntities[1].Order);
+ CalculationGroupEntity childGroupEntity1 = childGroupEntities[0];
+ Assert.AreEqual("A", childGroupEntity1.Name);
+ Assert.AreEqual(1, childGroupEntity1.IsEditable);
+ Assert.AreEqual(0, childGroupEntity1.Order);
+ CalculationGroupEntity childGroupEntity2 = childGroupEntities[1];
+ Assert.AreEqual("B", childGroupEntity2.Name);
+ Assert.AreEqual(1, childGroupEntity2.IsEditable);
+ Assert.AreEqual(1, childGroupEntity2.Order);
}
}
}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingCalculationScenarioCreateExtensionsTest.cs
===================================================================
diff -u -r03a0bbc245b8da50ca603f18d5b9b8fb2d7593c5 -r8a11d2a7974d1fb39e142516dc3fd041e1eb4603
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingCalculationScenarioCreateExtensionsTest.cs (.../PipingCalculationScenarioCreateExtensionsTest.cs) (revision 03a0bbc245b8da50ca603f18d5b9b8fb2d7593c5)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingCalculationScenarioCreateExtensionsTest.cs (.../PipingCalculationScenarioCreateExtensionsTest.cs) (revision 8a11d2a7974d1fb39e142516dc3fd041e1eb4603)
@@ -74,29 +74,29 @@
EntryPointL = (RoundedDouble) entryPoint,
PhreaticLevelExit =
{
- Mean = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, -9999.9999, 9999.9999),
- StandardDeviation = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999)
+ Mean = (RoundedDouble) random.GetFromRange(-9999.9999, 9999.9999),
+ StandardDeviation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999)
},
DampingFactorExit =
{
- Mean = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- StandardDeviation = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999)
+ Mean = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999),
+ StandardDeviation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999)
},
SaturatedVolumicWeightOfCoverageLayer =
{
- Mean = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 10.0, 9999.9999),
- StandardDeviation = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- Shift = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 10.0)
+ Mean = (RoundedDouble) random.GetFromRange(10.0, 9999.9999),
+ StandardDeviation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999),
+ Shift = (RoundedDouble) random.GetFromRange(1e-6, 10.0)
},
Diameter70 =
{
- Mean = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- StandardDeviation = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999)
+ Mean = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999),
+ StandardDeviation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999)
},
DarcyPermeability =
{
- Mean = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- StandardDeviation = (RoundedDouble) RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999)
+ Mean = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999),
+ StandardDeviation = (RoundedDouble) random.GetFromRange(1e-6, 9999.9999)
}
}
};
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HeightStructures/HeightStructuresCalculationEntityReadExtensionsTest.cs
===================================================================
diff -u -r03a0bbc245b8da50ca603f18d5b9b8fb2d7593c5 -r8a11d2a7974d1fb39e142516dc3fd041e1eb4603
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HeightStructures/HeightStructuresCalculationEntityReadExtensionsTest.cs (.../HeightStructuresCalculationEntityReadExtensionsTest.cs) (revision 03a0bbc245b8da50ca603f18d5b9b8fb2d7593c5)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HeightStructures/HeightStructuresCalculationEntityReadExtensionsTest.cs (.../HeightStructuresCalculationEntityReadExtensionsTest.cs) (revision 8a11d2a7974d1fb39e142516dc3fd041e1eb4603)
@@ -65,21 +65,21 @@
Comments = comments,
UseForeshore = Convert.ToByte(false),
UseBreakWater = Convert.ToByte(false),
- StructureNormalOrientation = RandomNumberGenerator.GetRandomDoubleFromRange(random, 0, 360),
- ModelFactorSuperCriticalFlowMean = RandomNumberGenerator.GetRandomDoubleFromRange(random, -9999.9999, 9999.9999),
- AllowedLevelIncreaseStorageMean = RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- AllowedLevelIncreaseStorageStandardDeviation = RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- FlowWidthAtBottomProtectionMean = RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- FlowWidthAtBottomProtectionStandardDeviation = RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- CriticalOvertoppingDischargeMean = RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- CriticalOvertoppingDischargeCoefficientOfVariation = RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
+ StructureNormalOrientation = random.GetFromRange(0, 360),
+ ModelFactorSuperCriticalFlowMean = random.GetFromRange(-9999.9999, 9999.9999),
+ AllowedLevelIncreaseStorageMean = random.GetFromRange(1e-6, 9999.9999),
+ AllowedLevelIncreaseStorageStandardDeviation = random.GetFromRange(1e-6, 9999.9999),
+ FlowWidthAtBottomProtectionMean = random.GetFromRange(1e-6, 9999.9999),
+ FlowWidthAtBottomProtectionStandardDeviation = random.GetFromRange(1e-6, 9999.9999),
+ CriticalOvertoppingDischargeMean = random.GetFromRange(1e-6, 9999.9999),
+ CriticalOvertoppingDischargeCoefficientOfVariation = random.GetFromRange(1e-6, 9999.9999),
FailureProbabilityStructureWithErosion = random.NextDouble(),
- WidthFlowAperturesMean = RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- WidthFlowAperturesCoefficientOfVariation = RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- StormDurationMean = RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- LevelCrestStructureMean = RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- LevelCrestStructureStandardDeviation = RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 9999.9999),
- DeviationWaveDirection = RandomNumberGenerator.GetRandomDoubleFromRange(random, -360, 360)
+ WidthFlowAperturesMean = random.GetFromRange(1e-6, 9999.9999),
+ WidthFlowAperturesCoefficientOfVariation = random.GetFromRange(1e-6, 9999.9999),
+ StormDurationMean = random.GetFromRange(1e-6, 9999.9999),
+ LevelCrestStructureMean = random.GetFromRange(1e-6, 9999.9999),
+ LevelCrestStructureStandardDeviation = random.GetFromRange(1e-6, 9999.9999),
+ DeviationWaveDirection = random.GetFromRange(-360, 360)
};
var collector = new ReadConversionCollector();
Index: Core/Common/test/Core.Common.TestUtil.Test/Core.Common.TestUtil.Test.csproj
===================================================================
diff -u -r03a0bbc245b8da50ca603f18d5b9b8fb2d7593c5 -r8a11d2a7974d1fb39e142516dc3fd041e1eb4603
--- Core/Common/test/Core.Common.TestUtil.Test/Core.Common.TestUtil.Test.csproj (.../Core.Common.TestUtil.Test.csproj) (revision 03a0bbc245b8da50ca603f18d5b9b8fb2d7593c5)
+++ Core/Common/test/Core.Common.TestUtil.Test/Core.Common.TestUtil.Test.csproj (.../Core.Common.TestUtil.Test.csproj) (revision 8a11d2a7974d1fb39e142516dc3fd041e1eb4603)
@@ -67,7 +67,7 @@
True
Resources.resx
-
+
Index: Core/Common/test/Core.Common.TestUtil.Test/RandomExtensionsTest.cs
===================================================================
diff -u
--- Core/Common/test/Core.Common.TestUtil.Test/RandomExtensionsTest.cs (revision 0)
+++ Core/Common/test/Core.Common.TestUtil.Test/RandomExtensionsTest.cs (revision 8a11d2a7974d1fb39e142516dc3fd041e1eb4603)
@@ -0,0 +1,97 @@
+// 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 NUnit.Framework;
+
+namespace Core.Common.TestUtil.Test
+{
+ [TestFixture]
+ public class RandomExtensionsTest
+ {
+ [Test]
+ public void GetFromRange_RandomIsNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => ((Random) null).GetFromRange(0, 0);
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("random", paramName);
+ }
+
+ [Test]
+ public void GetFromRange_LowerLimitLargerThanUpperLimit_ThrowsArgumentException()
+ {
+ // Setup
+ var random = new Random();
+
+ // Call
+ TestDelegate test = () => random.GetFromRange(1, 0);
+
+ // Assert
+ string message = Assert.Throws(test).Message;
+ Assert.AreEqual("lowerLimit is larger than upperLimit", message);
+ }
+
+ [Test]
+ [TestCase(double.MinValue, double.MaxValue)]
+ [TestCase(double.NegativeInfinity, 0)]
+ [TestCase(0, double.PositiveInfinity)]
+ [TestCase(double.NaN, 0)]
+ [TestCase(0, double.NaN)]
+ public void GetFromRange_LimitsTooLarge_ThrowsNotFiniteNumberException(double lowerLimit, double upperLimit)
+ {
+ // Setup
+ var random = new Random();
+
+ // Call
+ TestDelegate test = () => random.GetFromRange(lowerLimit, upperLimit);
+
+ // Assert
+ string message = Assert.Throws(test).Message;
+ string expectedMessage = string.Format("Creating a new random value with lower limit {0} " +
+ "and upper limit {1} did not result in a finite value.",
+ lowerLimit, upperLimit);
+ Assert.AreEqual(expectedMessage, message);
+ }
+
+ [Test]
+ [TestCase(double.MinValue, 0)]
+ [TestCase(0, double.MaxValue)]
+ [TestCase(-10, 0)]
+ [TestCase(0, 0)]
+ [TestCase(0, 10)]
+ [TestCase(0, 10)]
+ public void GetFromRange_VariousLimits_RandomNumberBetweenLimits(double lowerLimit, double upperLimit)
+ {
+ // Setup
+ var random = new Random();
+
+ // Call
+ var randomValue = random.GetFromRange(lowerLimit, upperLimit);
+
+ // Assert
+ Assert.LessOrEqual(randomValue, upperLimit);
+ Assert.GreaterOrEqual(randomValue, lowerLimit);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 8a11d2a7974d1fb39e142516dc3fd041e1eb4603 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.TestUtil.Test/RandomNumberGeneratorTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Core/Common/test/Core.Common.TestUtil/Core.Common.TestUtil.csproj
===================================================================
diff -u -r03a0bbc245b8da50ca603f18d5b9b8fb2d7593c5 -r8a11d2a7974d1fb39e142516dc3fd041e1eb4603
--- Core/Common/test/Core.Common.TestUtil/Core.Common.TestUtil.csproj (.../Core.Common.TestUtil.csproj) (revision 03a0bbc245b8da50ca603f18d5b9b8fb2d7593c5)
+++ Core/Common/test/Core.Common.TestUtil/Core.Common.TestUtil.csproj (.../Core.Common.TestUtil.csproj) (revision 8a11d2a7974d1fb39e142516dc3fd041e1eb4603)
@@ -101,7 +101,7 @@
True
True
-
+
Index: Core/Common/test/Core.Common.TestUtil/RandomExtensions.cs
===================================================================
diff -u
--- Core/Common/test/Core.Common.TestUtil/RandomExtensions.cs (revision 0)
+++ Core/Common/test/Core.Common.TestUtil/RandomExtensions.cs (revision 8a11d2a7974d1fb39e142516dc3fd041e1eb4603)
@@ -0,0 +1,65 @@
+// 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;
+
+namespace Core.Common.TestUtil
+{
+ ///
+ /// Extension methods for .
+ ///
+ public static class RandomExtensions
+ {
+ ///
+ /// Generates a new pseudo-random number between and .
+ ///
+ /// A pseudo-random number generator.
+ /// The lower limit of the new random number.
+ /// The upper limit of the new random number.
+ /// A new random number.
+ /// Thrown when is null.
+ /// Thrown when is larger than .
+ /// Thrown when the generated value is not finite.
+ public static double GetFromRange(this Random random, double lowerLimit, double upperLimit)
+ {
+ if (random == null)
+ {
+ throw new ArgumentNullException("random");
+ }
+
+ if (lowerLimit > upperLimit)
+ {
+ throw new ArgumentException("lowerLimit is larger than upperLimit");
+ }
+
+ double difference = upperLimit - lowerLimit;
+ double randomValue = lowerLimit + random.NextDouble() * difference;
+ if (double.IsInfinity(randomValue) || double.IsNaN(randomValue))
+ {
+ string message = string.Format("Creating a new random value with lower limit {0} " +
+ "and upper limit {1} did not result in a finite value.",
+ lowerLimit, upperLimit);
+ throw new NotFiniteNumberException(message, randomValue);
+ }
+ return randomValue;
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 8a11d2a7974d1fb39e142516dc3fd041e1eb4603 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.TestUtil/RandomNumberGenerator.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationServiceTest.cs
===================================================================
diff -u -r03a0bbc245b8da50ca603f18d5b9b8fb2d7593c5 -r8a11d2a7974d1fb39e142516dc3fd041e1eb4603
--- Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationServiceTest.cs (.../PipingCalculationServiceTest.cs) (revision 03a0bbc245b8da50ca603f18d5b9b8fb2d7593c5)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationServiceTest.cs (.../PipingCalculationServiceTest.cs) (revision 8a11d2a7974d1fb39e142516dc3fd041e1eb4603)
@@ -426,9 +426,9 @@
new PipingSoilLayer(10.5)
{
IsAquifer = false,
- BelowPhreaticLevelDeviation = RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 999.999),
- BelowPhreaticLevelMean = RandomNumberGenerator.GetRandomDoubleFromRange(random, 10.0, 999.999),
- BelowPhreaticLevelShift = RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 10.0)
+ BelowPhreaticLevelDeviation = random.GetFromRange(1e-6, 999.999),
+ BelowPhreaticLevelMean = random.GetFromRange(10.0, 999.999),
+ BelowPhreaticLevelShift = random.GetFromRange(1e-6, 10.0)
},
incompletePipingSoilLayer
},
@@ -486,9 +486,9 @@
new PipingSoilLayer(10.5)
{
IsAquifer = false,
- BelowPhreaticLevelDeviation = RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 999.999),
- BelowPhreaticLevelMean = RandomNumberGenerator.GetRandomDoubleFromRange(random, 10.0, 999.999),
- BelowPhreaticLevelShift = RandomNumberGenerator.GetRandomDoubleFromRange(random, 1e-6, 10.0)
+ BelowPhreaticLevelDeviation = random.GetFromRange(1e-6, 999.999),
+ BelowPhreaticLevelMean = random.GetFromRange(10.0, 999.999),
+ BelowPhreaticLevelShift = random.GetFromRange(1e-6, 10.0)
},
incompletePipingSoilLayer
},