Index: Core/Common/src/Core.Common.Base/ObservableUniqueItemCollectionWithSourcePath.cs
===================================================================
diff -u -r6cdb90fc3f89fe0c44b62d3be7266a0090a6b891 -rc29ddf2e68499841e1d892129d60a42adc4ac134
--- Core/Common/src/Core.Common.Base/ObservableUniqueItemCollectionWithSourcePath.cs (.../ObservableUniqueItemCollectionWithSourcePath.cs) (revision 6cdb90fc3f89fe0c44b62d3be7266a0090a6b891)
+++ Core/Common/src/Core.Common.Base/ObservableUniqueItemCollectionWithSourcePath.cs (.../ObservableUniqueItemCollectionWithSourcePath.cs) (revision c29ddf2e68499841e1d892129d60a42adc4ac134)
@@ -77,7 +77,7 @@
/// The index.
/// The element at index in the collection.
/// Thrown when is not
- /// between [0, )
+ /// between [0, ]
public TElement this[int i]
{
get
Index: Riskeer/Common/src/Riskeer.Common.Data/Calculation/ICalculationScenario.cs
===================================================================
diff -u -r0a2ccc1740669e48d2c629e5bcfe3283f730b2f5 -rc29ddf2e68499841e1d892129d60a42adc4ac134
--- Riskeer/Common/src/Riskeer.Common.Data/Calculation/ICalculationScenario.cs (.../ICalculationScenario.cs) (revision 0a2ccc1740669e48d2c629e5bcfe3283f730b2f5)
+++ Riskeer/Common/src/Riskeer.Common.Data/Calculation/ICalculationScenario.cs (.../ICalculationScenario.cs) (revision c29ddf2e68499841e1d892129d60a42adc4ac134)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using Core.Common.Base.Data;
namespace Riskeer.Common.Data.Calculation
@@ -36,6 +37,8 @@
///
/// Gets or sets the contribution of the scenario.
///
+ /// Thrown when is not
+ /// between [0, 1].
RoundedDouble Contribution { get; set; }
}
}
\ No newline at end of file
Index: Riskeer/Common/src/Riskeer.Common.Data/Helpers/CalculationScenarioHelper.cs
===================================================================
diff -u
--- Riskeer/Common/src/Riskeer.Common.Data/Helpers/CalculationScenarioHelper.cs (revision 0)
+++ Riskeer/Common/src/Riskeer.Common.Data/Helpers/CalculationScenarioHelper.cs (revision c29ddf2e68499841e1d892129d60a42adc4ac134)
@@ -0,0 +1,57 @@
+// Copyright (C) Stichting Deltares 2019. 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.Data;
+using Riskeer.Common.Data.Calculation;
+using Riskeer.Common.Data.Properties;
+
+namespace Riskeer.Common.Data.Helpers
+{
+ ///
+ /// Helper class for dealing with .
+ ///
+ public static class CalculationScenarioHelper
+ {
+ ///
+ /// Gets the scenario contribution number of decimal places.
+ ///
+ public static int ContributionNumberOfDecimalPlaces => 4;
+
+ private static readonly Range contributionValidityRange = new Range(
+ new RoundedDouble(ContributionNumberOfDecimalPlaces),
+ new RoundedDouble(ContributionNumberOfDecimalPlaces, 1.0));
+
+ ///
+ /// Validates whether the is valid.
+ ///
+ /// The value to validate.
+ /// Thrown when is not
+ /// between [0, 1].
+ public static void ValidateScenarioContribution(RoundedDouble value)
+ {
+ if (!contributionValidityRange.InRange(value))
+ {
+ throw new ArgumentOutOfRangeException(null, string.Format(Resources.Contribution_must_be_within_Range_0_and_100));
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/Common/src/Riskeer.Common.Data/Structures/StructuresCalculationScenario.cs
===================================================================
diff -u -r7f3ed17a0e466320f1eacc1d55fd4f99016ae6cf -rc29ddf2e68499841e1d892129d60a42adc4ac134
--- Riskeer/Common/src/Riskeer.Common.Data/Structures/StructuresCalculationScenario.cs (.../StructuresCalculationScenario.cs) (revision 7f3ed17a0e466320f1eacc1d55fd4f99016ae6cf)
+++ Riskeer/Common/src/Riskeer.Common.Data/Structures/StructuresCalculationScenario.cs (.../StructuresCalculationScenario.cs) (revision c29ddf2e68499841e1d892129d60a42adc4ac134)
@@ -19,10 +19,9 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System;
using Core.Common.Base.Data;
using Riskeer.Common.Data.Calculation;
-using RiskeerCommonDataResources = Riskeer.Common.Data.Properties.Resources;
+using Riskeer.Common.Data.Helpers;
namespace Riskeer.Common.Data.Structures
{
@@ -33,17 +32,14 @@
where T : IStructuresCalculationInput, new()
{
private RoundedDouble contribution;
- private const int contributionNumberOfDecimalPlaces = 4;
- private readonly Range contributionValidityRange = new Range(new RoundedDouble(contributionNumberOfDecimalPlaces),
- new RoundedDouble(contributionNumberOfDecimalPlaces, 1.0));
///
/// Creates a new instance of .
///
public StructuresCalculationScenario()
{
IsRelevant = true;
- contribution = new RoundedDouble(4, 1);
+ contribution = new RoundedDouble(CalculationScenarioHelper.ContributionNumberOfDecimalPlaces, 1);
}
public bool IsRelevant { get; set; }
@@ -53,12 +49,9 @@
get => contribution;
set
{
- RoundedDouble newValue = value.ToPrecision(contributionNumberOfDecimalPlaces);
+ RoundedDouble newValue = value.ToPrecision(CalculationScenarioHelper.ContributionNumberOfDecimalPlaces);
- if (!contributionValidityRange.InRange(newValue))
- {
- throw new ArgumentOutOfRangeException(null, string.Format(RiskeerCommonDataResources.Contribution_must_be_within_Range_0_and_100));
- }
+ CalculationScenarioHelper.ValidateScenarioContribution(newValue);
contribution = newValue;
}
Index: Riskeer/Common/test/Riskeer.Common.Data.Test/Helpers/CalculationScenarioHelperTest.cs
===================================================================
diff -u
--- Riskeer/Common/test/Riskeer.Common.Data.Test/Helpers/CalculationScenarioHelperTest.cs (revision 0)
+++ Riskeer/Common/test/Riskeer.Common.Data.Test/Helpers/CalculationScenarioHelperTest.cs (revision c29ddf2e68499841e1d892129d60a42adc4ac134)
@@ -0,0 +1,69 @@
+// Copyright (C) Stichting Deltares 2019. 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.Data;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Riskeer.Common.Data.Helpers;
+using Riskeer.Common.Data.TestUtil;
+
+namespace Riskeer.Common.Data.Test.Helpers
+{
+ [TestFixture]
+ public class CalculationScenarioHelperTest
+ {
+ [Test]
+ public void ContributionNumberOfDecimalPlaces_Always_ReturnsExpectedValue()
+ {
+ // Call
+ int numberOfDecimalPlaces = CalculationScenarioHelper.ContributionNumberOfDecimalPlaces;
+
+ // Assert
+ Assert.AreEqual(4, numberOfDecimalPlaces);
+ }
+
+ [Test]
+ [TestCaseSource(typeof(CalculationScenarioTestHelper), nameof(CalculationScenarioTestHelper.GetInvalidScenarioContributionValues))]
+ public void ValidateScenarioContribution_InvalidValue_ThrowsArgumentException(double newValue)
+ {
+
+ // Call
+ void Call() => CalculationScenarioHelper.ValidateScenarioContribution((RoundedDouble) newValue);
+
+ // Assert
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, "De waarde moet binnen het bereik [0% en 100%] liggen.");
+ }
+
+ [Test]
+ [TestCase(-0.0)]
+ [TestCase(0.0)]
+ [TestCase(1.0)]
+ public void ValidateScenarioContribution_ValidValue_DoesNotThrow(double newValue)
+ {
+ // Call
+ void Call() => CalculationScenarioHelper.ValidateScenarioContribution((RoundedDouble) newValue);
+
+ // Assert
+ Assert.DoesNotThrow(Call);
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/Common/test/Riskeer.Common.Data.Test/Riskeer.Common.Data.Test.csproj
===================================================================
diff -u -r08e8d26a0715f0f3db57c1d3e86256aa06934db4 -rc29ddf2e68499841e1d892129d60a42adc4ac134
--- Riskeer/Common/test/Riskeer.Common.Data.Test/Riskeer.Common.Data.Test.csproj (.../Riskeer.Common.Data.Test.csproj) (revision 08e8d26a0715f0f3db57c1d3e86256aa06934db4)
+++ Riskeer/Common/test/Riskeer.Common.Data.Test/Riskeer.Common.Data.Test.csproj (.../Riskeer.Common.Data.Test.csproj) (revision c29ddf2e68499841e1d892129d60a42adc4ac134)
@@ -6,16 +6,16 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
Index: Riskeer/Common/test/Riskeer.Common.Data.Test/Structures/StructuresCalculationScenarioTest.cs
===================================================================
diff -u -r7f3ed17a0e466320f1eacc1d55fd4f99016ae6cf -rc29ddf2e68499841e1d892129d60a42adc4ac134
--- Riskeer/Common/test/Riskeer.Common.Data.Test/Structures/StructuresCalculationScenarioTest.cs (.../StructuresCalculationScenarioTest.cs) (revision 7f3ed17a0e466320f1eacc1d55fd4f99016ae6cf)
+++ Riskeer/Common/test/Riskeer.Common.Data.Test/Structures/StructuresCalculationScenarioTest.cs (.../StructuresCalculationScenarioTest.cs) (revision c29ddf2e68499841e1d892129d60a42adc4ac134)
@@ -50,13 +50,7 @@
}
[Test]
- [SetCulture("nl-NL")]
- [TestCase(double.NaN)]
- [TestCase(double.PositiveInfinity)]
- [TestCase(double.NegativeInfinity)]
- [TestCase(-0.1)]
- [TestCase(1.0001)]
- [TestCase(1.1)]
+ [TestCaseSource(typeof(CalculationScenarioTestHelper), nameof(CalculationScenarioTestHelper.GetInvalidScenarioContributionValues))]
public void Contribution_SetInvalidValue_ThrowArgumentException(double newValue)
{
// Setup
@@ -70,13 +64,8 @@
}
[Test]
- [SetCulture("nl-NL")]
- [TestCase(0.0)]
- [TestCase(0.00001)]
- [TestCase(0.0001)]
- [TestCase(1.0)]
- [TestCase(1.00001)]
- public void Contribution_SetValidValue_ValueSetAndSandParticlesVolumicWeightUpdated(double newValue)
+ [TestCaseSource(typeof(CalculationScenarioTestHelper), nameof(CalculationScenarioTestHelper.GetValidScenarioContributionValues))]
+ public void Contribution_SetValidValue_ValueSet(double newValue)
{
// Setup
var calculationScenario = new StructuresCalculationScenario();
Index: Riskeer/Common/test/Riskeer.Common.Data.TestUtil/CalculationScenarioTestHelper.cs
===================================================================
diff -u
--- Riskeer/Common/test/Riskeer.Common.Data.TestUtil/CalculationScenarioTestHelper.cs (revision 0)
+++ Riskeer/Common/test/Riskeer.Common.Data.TestUtil/CalculationScenarioTestHelper.cs (revision c29ddf2e68499841e1d892129d60a42adc4ac134)
@@ -0,0 +1,64 @@
+// Copyright (C) Stichting Deltares 2019. 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.Collections.Generic;
+using NUnit.Framework;
+using Riskeer.Common.Data.Calculation;
+
+namespace Riskeer.Common.Data.TestUtil
+{
+ ///
+ /// Helper class for testing .
+ ///
+ public static class CalculationScenarioTestHelper
+ {
+ ///
+ /// Gets the valid scenario contribution values.
+ ///
+ /// A collection of valid scenario contribution values.
+ public static IEnumerable GetValidScenarioContributionValues()
+ {
+ return new[]
+ {
+ new TestCaseData(-0.00001),
+ new TestCaseData(0.0),
+ new TestCaseData(1.0),
+ new TestCaseData(1.00001)
+ };
+ }
+
+ ///
+ /// Gets the invalid scenario contribution values.
+ ///
+ /// A collection of invalid scenario contribution values.
+ public static IEnumerable GetInvalidScenarioContributionValues()
+ {
+ return new[]
+ {
+ new TestCaseData(double.NaN),
+ new TestCaseData(double.PositiveInfinity),
+ new TestCaseData(double.NegativeInfinity),
+ new TestCaseData(-0.0001),
+ new TestCaseData(1.0001)
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsCalculationScenario.cs
===================================================================
diff -u -r04d505aa8ee5dc153f7e0e1155c7b1c0b39283f5 -rc29ddf2e68499841e1d892129d60a42adc4ac134
--- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsCalculationScenario.cs (.../GrassCoverErosionInwardsCalculationScenario.cs) (revision 04d505aa8ee5dc153f7e0e1155c7b1c0b39283f5)
+++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsCalculationScenario.cs (.../GrassCoverErosionInwardsCalculationScenario.cs) (revision c29ddf2e68499841e1d892129d60a42adc4ac134)
@@ -19,10 +19,9 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System;
using Core.Common.Base.Data;
using Riskeer.Common.Data.Calculation;
-using RiskeerCommonDataResources = Riskeer.Common.Data.Properties.Resources;
+using Riskeer.Common.Data.Helpers;
namespace Riskeer.GrassCoverErosionInwards.Data
{
@@ -32,17 +31,14 @@
public class GrassCoverErosionInwardsCalculationScenario : GrassCoverErosionInwardsCalculation, ICalculationScenario
{
private RoundedDouble contribution;
- private const int contributionNumberOfDecimalPlaces = 4;
- private static readonly Range contributionValidityRange = new Range(new RoundedDouble(contributionNumberOfDecimalPlaces),
- new RoundedDouble(contributionNumberOfDecimalPlaces, 1.0));
-
+
///
/// Creates a new instance of .
///
public GrassCoverErosionInwardsCalculationScenario()
{
IsRelevant = true;
- contribution = new RoundedDouble(4, 1);
+ contribution = new RoundedDouble(CalculationScenarioHelper.ContributionNumberOfDecimalPlaces, 1);
}
public bool IsRelevant { get; set; }
@@ -52,12 +48,9 @@
get => contribution;
set
{
- RoundedDouble newValue = value.ToPrecision(contributionNumberOfDecimalPlaces);
+ RoundedDouble newValue = value.ToPrecision(CalculationScenarioHelper.ContributionNumberOfDecimalPlaces);
- if (!contributionValidityRange.InRange(newValue))
- {
- throw new ArgumentOutOfRangeException(null, string.Format(RiskeerCommonDataResources.Contribution_must_be_within_Range_0_and_100));
- }
+ CalculationScenarioHelper.ValidateScenarioContribution(newValue);
contribution = newValue;
}
Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsCalculationScenarioTest.cs
===================================================================
diff -u -r04d505aa8ee5dc153f7e0e1155c7b1c0b39283f5 -rc29ddf2e68499841e1d892129d60a42adc4ac134
--- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsCalculationScenarioTest.cs (.../GrassCoverErosionInwardsCalculationScenarioTest.cs) (revision 04d505aa8ee5dc153f7e0e1155c7b1c0b39283f5)
+++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsCalculationScenarioTest.cs (.../GrassCoverErosionInwardsCalculationScenarioTest.cs) (revision c29ddf2e68499841e1d892129d60a42adc4ac134)
@@ -49,13 +49,7 @@
}
[Test]
- [SetCulture("nl-NL")]
- [TestCase(double.NaN)]
- [TestCase(double.PositiveInfinity)]
- [TestCase(double.NegativeInfinity)]
- [TestCase(-0.1)]
- [TestCase(1.0001)]
- [TestCase(1.1)]
+ [TestCaseSource(typeof(CalculationScenarioTestHelper), nameof(CalculationScenarioTestHelper.GetInvalidScenarioContributionValues))]
public void Contribution_SetInvalidValue_ThrowArgumentException(double newValue)
{
// Setup
@@ -69,13 +63,8 @@
}
[Test]
- [SetCulture("nl-NL")]
- [TestCase(0.0)]
- [TestCase(0.00001)]
- [TestCase(0.0001)]
- [TestCase(1.0)]
- [TestCase(1.00001)]
- public void Contribution_SetValidValue_ValueSetAndSandParticlesVolumicWeightUpdated(double newValue)
+ [TestCaseSource(typeof(CalculationScenarioTestHelper), nameof(CalculationScenarioTestHelper.GetValidScenarioContributionValues))]
+ public void Contribution_SetValidValue_ValueSet(double newValue)
{
// Setup
var calculationScenario = new GrassCoverErosionInwardsCalculationScenario();
Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Data/MacroStabilityInwardsCalculationScenario.cs
===================================================================
diff -u -r7e68d14a3867bef430305c683d7ee0221f99c261 -rc29ddf2e68499841e1d892129d60a42adc4ac134
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Data/MacroStabilityInwardsCalculationScenario.cs (.../MacroStabilityInwardsCalculationScenario.cs) (revision 7e68d14a3867bef430305c683d7ee0221f99c261)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Data/MacroStabilityInwardsCalculationScenario.cs (.../MacroStabilityInwardsCalculationScenario.cs) (revision c29ddf2e68499841e1d892129d60a42adc4ac134)
@@ -19,10 +19,9 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System;
using Core.Common.Base.Data;
using Riskeer.Common.Data.Calculation;
-using RiskeerCommonDataResources = Riskeer.Common.Data.Properties.Resources;
+using Riskeer.Common.Data.Helpers;
namespace Riskeer.MacroStabilityInwards.Data
{
@@ -32,9 +31,6 @@
public class MacroStabilityInwardsCalculationScenario : MacroStabilityInwardsCalculation, ICalculationScenario
{
private RoundedDouble contribution;
- private const int contributionNumberOfDecimalPlaces = 4;
- private static readonly Range contributionValidityRange = new Range(new RoundedDouble(contributionNumberOfDecimalPlaces),
- new RoundedDouble(contributionNumberOfDecimalPlaces, 1.0));
///
/// Creates a new instance of .
@@ -52,12 +48,9 @@
get => contribution;
set
{
- RoundedDouble newValue = value.ToPrecision(contributionNumberOfDecimalPlaces);
+ RoundedDouble newValue = value.ToPrecision(CalculationScenarioHelper.ContributionNumberOfDecimalPlaces);
- if (!contributionValidityRange.InRange(newValue))
- {
- throw new ArgumentOutOfRangeException(null, string.Format(RiskeerCommonDataResources.Contribution_must_be_within_Range_0_and_100));
- }
+ CalculationScenarioHelper.ValidateScenarioContribution(newValue);
contribution = newValue;
}
Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Data.Test/MacroStabilityInwardsCalculationScenarioTest.cs
===================================================================
diff -u -r7e68d14a3867bef430305c683d7ee0221f99c261 -rc29ddf2e68499841e1d892129d60a42adc4ac134
--- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Data.Test/MacroStabilityInwardsCalculationScenarioTest.cs (.../MacroStabilityInwardsCalculationScenarioTest.cs) (revision 7e68d14a3867bef430305c683d7ee0221f99c261)
+++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Data.Test/MacroStabilityInwardsCalculationScenarioTest.cs (.../MacroStabilityInwardsCalculationScenarioTest.cs) (revision c29ddf2e68499841e1d892129d60a42adc4ac134)
@@ -49,13 +49,7 @@
}
[Test]
- [SetCulture("nl-NL")]
- [TestCase(double.NaN)]
- [TestCase(double.PositiveInfinity)]
- [TestCase(double.NegativeInfinity)]
- [TestCase(-0.1)]
- [TestCase(1.0001)]
- [TestCase(1.1)]
+ [TestCaseSource(typeof(CalculationScenarioTestHelper), nameof(CalculationScenarioTestHelper.GetInvalidScenarioContributionValues))]
public void Contribution_SetInvalidValue_ThrowArgumentException(double newValue)
{
// Setup
@@ -69,13 +63,8 @@
}
[Test]
- [SetCulture("nl-NL")]
- [TestCase(0.0)]
- [TestCase(0.00001)]
- [TestCase(0.0001)]
- [TestCase(1.0)]
- [TestCase(1.00001)]
- public void Contribution_SetValidValue_ValueSetAndSandParticlesVolumicWeightUpdated(double newValue)
+ [TestCaseSource(typeof(CalculationScenarioTestHelper), nameof(CalculationScenarioTestHelper.GetValidScenarioContributionValues))]
+ public void Contribution_SetValidValue_ValueSet(double newValue)
{
// Setup
var calculationScenario = new MacroStabilityInwardsCalculationScenario();
Index: Riskeer/Piping/src/Riskeer.Piping.Data/Probabilistic/ProbabilisticPipingCalculationScenario.cs
===================================================================
diff -u -re2b60a183f95fefe71686ac319c22bb7ad644bca -rc29ddf2e68499841e1d892129d60a42adc4ac134
--- Riskeer/Piping/src/Riskeer.Piping.Data/Probabilistic/ProbabilisticPipingCalculationScenario.cs (.../ProbabilisticPipingCalculationScenario.cs) (revision e2b60a183f95fefe71686ac319c22bb7ad644bca)
+++ Riskeer/Piping/src/Riskeer.Piping.Data/Probabilistic/ProbabilisticPipingCalculationScenario.cs (.../ProbabilisticPipingCalculationScenario.cs) (revision c29ddf2e68499841e1d892129d60a42adc4ac134)
@@ -20,6 +20,7 @@
// All rights reserved.
using Core.Common.Base.Data;
+using Riskeer.Common.Data.Helpers;
namespace Riskeer.Piping.Data.Probabilistic
{
@@ -36,7 +37,7 @@
public ProbabilisticPipingCalculationScenario()
{
IsRelevant = true;
- contribution = new RoundedDouble(4, 1.0);
+ contribution = new RoundedDouble(CalculationScenarioHelper.ContributionNumberOfDecimalPlaces, 1.0);
}
public bool IsRelevant { get; set; }
Index: Riskeer/Piping/src/Riskeer.Piping.Data/SemiProbabilistic/SemiProbabilisticPipingCalculationScenario.cs
===================================================================
diff -u -r87a1bea2bd70c4f66957ae4b961e23f2756014ce -rc29ddf2e68499841e1d892129d60a42adc4ac134
--- Riskeer/Piping/src/Riskeer.Piping.Data/SemiProbabilistic/SemiProbabilisticPipingCalculationScenario.cs (.../SemiProbabilisticPipingCalculationScenario.cs) (revision 87a1bea2bd70c4f66957ae4b961e23f2756014ce)
+++ Riskeer/Piping/src/Riskeer.Piping.Data/SemiProbabilistic/SemiProbabilisticPipingCalculationScenario.cs (.../SemiProbabilisticPipingCalculationScenario.cs) (revision c29ddf2e68499841e1d892129d60a42adc4ac134)
@@ -19,9 +19,8 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System;
using Core.Common.Base.Data;
-using RiskeerCommonDataResources = Riskeer.Common.Data.Properties.Resources;
+using Riskeer.Common.Data.Helpers;
namespace Riskeer.Piping.Data.SemiProbabilistic
{
@@ -30,9 +29,6 @@
///
public class SemiProbabilisticPipingCalculationScenario : SemiProbabilisticPipingCalculation, IPipingCalculationScenario
{
- private const int contributionNumberOfDecimalPlaces = 4;
- private static readonly Range contributionValidityRange = new Range(new RoundedDouble(contributionNumberOfDecimalPlaces),
- new RoundedDouble(contributionNumberOfDecimalPlaces, 1.0));
private RoundedDouble contribution;
///
@@ -41,7 +37,7 @@
public SemiProbabilisticPipingCalculationScenario()
{
IsRelevant = true;
- contribution = new RoundedDouble(4, 1.0);
+ contribution = new RoundedDouble(CalculationScenarioHelper.ContributionNumberOfDecimalPlaces, 1.0);
}
public bool IsRelevant { get; set; }
@@ -51,12 +47,9 @@
get => contribution;
set
{
- RoundedDouble newValue = value.ToPrecision(contributionNumberOfDecimalPlaces);
+ RoundedDouble newValue = value.ToPrecision(CalculationScenarioHelper.ContributionNumberOfDecimalPlaces);
- if (!contributionValidityRange.InRange(newValue))
- {
- throw new ArgumentOutOfRangeException(null, string.Format(RiskeerCommonDataResources.Contribution_must_be_within_Range_0_and_100));
- }
+ CalculationScenarioHelper.ValidateScenarioContribution(newValue);
contribution = newValue;
}
Index: Riskeer/Piping/test/Riskeer.Piping.Data.Test/SemiProbabilistic/SemiProbabilisticPipingCalculationScenarioTest.cs
===================================================================
diff -u -r70e032bb8b84bfd974f2fc1da804978fd9bae5c5 -rc29ddf2e68499841e1d892129d60a42adc4ac134
--- Riskeer/Piping/test/Riskeer.Piping.Data.Test/SemiProbabilistic/SemiProbabilisticPipingCalculationScenarioTest.cs (.../SemiProbabilisticPipingCalculationScenarioTest.cs) (revision 70e032bb8b84bfd974f2fc1da804978fd9bae5c5)
+++ Riskeer/Piping/test/Riskeer.Piping.Data.Test/SemiProbabilistic/SemiProbabilisticPipingCalculationScenarioTest.cs (.../SemiProbabilisticPipingCalculationScenarioTest.cs) (revision c29ddf2e68499841e1d892129d60a42adc4ac134)
@@ -49,13 +49,7 @@
}
[Test]
- [SetCulture("nl-NL")]
- [TestCase(double.NaN)]
- [TestCase(double.PositiveInfinity)]
- [TestCase(double.NegativeInfinity)]
- [TestCase(-0.1)]
- [TestCase(1.0001)]
- [TestCase(1.1)]
+ [TestCaseSource(typeof(CalculationScenarioTestHelper), nameof(CalculationScenarioTestHelper.GetInvalidScenarioContributionValues))]
public void Contribution_SetInvalidValue_ThrowArgumentException(double newValue)
{
// Setup
@@ -69,13 +63,8 @@
}
[Test]
- [SetCulture("nl-NL")]
- [TestCase(0.0)]
- [TestCase(0.00001)]
- [TestCase(0.0001)]
- [TestCase(1.0)]
- [TestCase(1.00001)]
- public void Contribution_SetValidValue_ValueSetAndSandParticlesVolumicWeightUpdated(double newValue)
+ [TestCaseSource(typeof(CalculationScenarioTestHelper), nameof(CalculationScenarioTestHelper.GetValidScenarioContributionValues))]
+ public void Contribution_SetValidValue_ValueSet(double newValue)
{
// Setup
var calculationScenario = new SemiProbabilisticPipingCalculationScenario();