Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/DerivedMacroStabilityInwardsOutput.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/DerivedMacroStabilityInwardsOutput.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/DerivedMacroStabilityInwardsOutput.cs (revision 490ca61d1c7791776cc522141816391f075a9752) @@ -0,0 +1,121 @@ +// Copyright (C) Stichting Deltares 2017. 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 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 Ringtoets.Common.Data.Probability; + +namespace Ringtoets.MacroStabilityInwards.Data +{ + /// + /// This class contains the results of a semi-probabilistic assessment of the macro stability inwards + /// failure mechanism. + /// + public class DerivedMacroStabilityInwardsOutput + { + private double requiredProbability; + private double macroStabilityInwardsProbability; + + /// + /// Creates a new instance of . + /// + /// The calculated factor of stability of the macro stability inwards failure mechanism. + /// The required (maximum allowed) probability of failure due to macro stability inwards. + /// The required (maximum allowed) reliability of the macro stability inwards failure mechanism + /// The calculated probability of failing due to macro stability inwards. + /// The calculated reliability of the macro stability inwards failure mechanism. + /// The factor of safety for the macro stability inwards failure mechanism. + /// Thrown when setting a probability that falls + /// outside the [0.0, 1.0] range or isn't . + public DerivedMacroStabilityInwardsOutput(double factorOfStability, double requiredProbability, double requiredReliability, + double macroStabilityInwardsProbability, double macroStabilityInwardsReliability, + double macroStabilityInwardsFactorOfSafety) + { + FactorOfStability = new RoundedDouble(3, factorOfStability); + RequiredProbability = requiredProbability; + RequiredReliability = new RoundedDouble(5, requiredReliability); + MacroStabilityInwardsProbability = macroStabilityInwardsProbability; + MacroStabilityInwardsReliability = new RoundedDouble(5, macroStabilityInwardsReliability); + MacroStabilityInwardsFactorOfSafety = new RoundedDouble(3, macroStabilityInwardsFactorOfSafety); + } + + /// + /// Gets the factor of stability of the macro stability inwards failure mechanism. + /// + public RoundedDouble FactorOfStability { get; } + + /// + /// Gets the required probability of the macro stability inwards failure mechanism, + /// which value in range [0,1]. + /// + /// Thrown when setting a value that falls + /// outside the [0.0, 1.0] range or isn't . + public double RequiredProbability + { + get + { + return requiredProbability; + } + private set + { + ProbabilityHelper.ValidateProbability(value, nameof(value), true); + requiredProbability = value; + } + } + + /// + /// Get the required reliability of the macro stability inwards failure mechanism, + /// which is a value greater than 0. + /// + public RoundedDouble RequiredReliability { get; } + + /// + /// Gets the factor of safety of the macro stability inwards failure mechanism, + /// which is a value greater than 0. + /// + public RoundedDouble MacroStabilityInwardsFactorOfSafety { get; } + + /// + /// Gets the reliability of the macro stability inwards failure mechanism, + /// which is a value greater than 0. + /// + public RoundedDouble MacroStabilityInwardsReliability { get; } + + /// + /// Gets the probability of failing due to the macro stability inwards failure mechanism, + /// which value in range [0,1]. + /// + /// Thrown when setting a value that falls + /// outside the [0.0, 1.0] range or isn't . + public double MacroStabilityInwardsProbability + { + get + { + return macroStabilityInwardsProbability; + } + private set + { + ProbabilityHelper.ValidateProbability(value, nameof(value), true); + macroStabilityInwardsProbability = value; + } + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj =================================================================== diff -u -rac96d7c315129af851634ed5a4a6800b59ede718 -r490ca61d1c7791776cc522141816391f075a9752 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj (.../Ringtoets.MacroStabilityInwards.Data.csproj) (revision ac96d7c315129af851634ed5a4a6800b59ede718) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj (.../Ringtoets.MacroStabilityInwards.Data.csproj) (revision 490ca61d1c7791776cc522141816391f075a9752) @@ -12,6 +12,7 @@ + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/DerivedMacroStabilityInwardsOutputTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/DerivedMacroStabilityInwardsOutputTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/DerivedMacroStabilityInwardsOutputTest.cs (revision 490ca61d1c7791776cc522141816391f075a9752) @@ -0,0 +1,186 @@ +// Copyright (C) Stichting Deltares 2017. 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 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.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.TestUtil; + +namespace Ringtoets.MacroStabilityInwards.Data.Test +{ + [TestFixture] + public class DerivedMacroStabilityInwardsOutputTest + { + [Test] + public void Constructor_Expectedvalues() + { + // Setup + var random = new Random(21); + double factorOfStability = random.NextDouble(); + double requiredProbability = random.NextDouble(); + double requiredReliability = random.NextDouble(); + double macroStabilityInwardsProbability = random.NextDouble(); + double macroStabilityInwardsReliability = random.NextDouble(); + double macroStabilityInwardsFactorOfSafety = random.NextDouble(); + + // Call + var output = new MacroStabilityInwardsSemiProbabilisticOutput( + factorOfStability, + requiredProbability, + requiredReliability, + macroStabilityInwardsProbability, + macroStabilityInwardsReliability, + macroStabilityInwardsFactorOfSafety); + + // Assert + Assert.AreEqual(factorOfStability, output.FactorOfStability, output.FactorOfStability.GetAccuracy()); + Assert.AreEqual(3, output.FactorOfStability.NumberOfDecimalPlaces); + Assert.AreEqual(requiredProbability, output.RequiredProbability); + Assert.AreEqual(5, output.RequiredReliability.NumberOfDecimalPlaces); + Assert.AreEqual(requiredReliability, output.RequiredReliability, output.RequiredReliability.GetAccuracy()); + Assert.AreEqual(macroStabilityInwardsProbability, output.MacroStabilityInwardsProbability); + Assert.AreEqual(5, output.MacroStabilityInwardsReliability.NumberOfDecimalPlaces); + Assert.AreEqual(macroStabilityInwardsReliability, output.MacroStabilityInwardsReliability, output.MacroStabilityInwardsReliability.GetAccuracy()); + Assert.AreEqual(3, output.MacroStabilityInwardsFactorOfSafety.NumberOfDecimalPlaces); + Assert.AreEqual(macroStabilityInwardsFactorOfSafety, output.MacroStabilityInwardsFactorOfSafety, output.MacroStabilityInwardsFactorOfSafety.GetAccuracy()); + } + + [Test] + [TestCase(double.NaN)] + [TestCase(0.0)] + [TestCase(0.123456789)] + [TestCase(1.0)] + public void RequiredProbability_SetValidValues_ReturnNewlySetValue(double requiredProbability) + { + // Setup + var random = new Random(21); + double factorOfStability = random.NextDouble(); + double requiredReliability = random.NextDouble(); + double macroStabilityInwardsProbability = random.NextDouble(); + double macroStabilityInwardsReliability = random.NextDouble(); + double macroStabilityInwardsFactorOfSafety = random.NextDouble(); + + // Call + var output = new MacroStabilityInwardsSemiProbabilisticOutput( + factorOfStability, + requiredProbability, + requiredReliability, + macroStabilityInwardsProbability, + macroStabilityInwardsReliability, + macroStabilityInwardsFactorOfSafety); + + // Assert + Assert.AreEqual(requiredProbability, output.RequiredProbability); + } + + [Test] + [SetCulture("nl-NL")] + [TestCase(double.PositiveInfinity)] + [TestCase(double.NegativeInfinity)] + [TestCase(0.0 - 1e-6)] + [TestCase(-346587.456)] + [TestCase(1.0 + 1e-6)] + [TestCase(346587.456)] + public void RequiredProbability_SetInvalidValues_ThrowArgumentOutOfRangeException(double requiredProbability) + { + // Setup + var random = new Random(21); + double factorOfStability = random.NextDouble(); + double requiredReliability = random.NextDouble(); + double macroStabilityInwardsProbability = random.NextDouble(); + double macroStabilityInwardsReliability = random.NextDouble(); + double macroStabilityInwardsFactorOfSafety = random.NextDouble(); + + // Call + TestDelegate call = () => new MacroStabilityInwardsSemiProbabilisticOutput( + factorOfStability, + requiredProbability, + requiredReliability, + macroStabilityInwardsProbability, + macroStabilityInwardsReliability, + macroStabilityInwardsFactorOfSafety); + + // Assert + const string expectedMessage = "Kans moet in het bereik [0,0, 1,0] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] + [TestCase(double.NaN)] + [TestCase(0.0)] + [TestCase(0.123456789)] + [TestCase(1.0)] + public void MacroStabilityInwardsProbability_SetValidValues_ReturnNewlySetValue(double macroStabilityInwardsProbability) + { + // Setup + var random = new Random(21); + double factorOfStability = random.NextDouble(); + double requiredProbability = random.NextDouble(); + double requiredReliability = random.NextDouble(); + double macroStabilityInwardsReliability = random.NextDouble(); + double macroStabilityInwardsFactorOfSafety = random.NextDouble(); + + // Call + var output = new MacroStabilityInwardsSemiProbabilisticOutput( + factorOfStability, + requiredProbability, + requiredReliability, + macroStabilityInwardsProbability, + macroStabilityInwardsReliability, + macroStabilityInwardsFactorOfSafety); + + // Assert + Assert.AreEqual(macroStabilityInwardsProbability, output.MacroStabilityInwardsProbability); + } + + [Test] + [SetCulture("nl-NL")] + [TestCase(double.PositiveInfinity)] + [TestCase(double.NegativeInfinity)] + [TestCase(0.0 - 1e-2)] + [TestCase(-346587.456)] + [TestCase(1.0 + 1e-2)] + [TestCase(346587.456)] + public void MacroStabilityInwardsProbability_SetInvalidValues_ThrowArgumentOutOfRangeException(double macroStabilityInwardsProbability) + { + // Setup + var random = new Random(21); + double factorOfStability = random.NextDouble(); + double requiredProbability = random.NextDouble(); + double requiredReliability = random.NextDouble(); + double macroStabilityInwardsReliability = random.NextDouble(); + double macroStabilityInwardsFactorOfSafety = random.NextDouble(); + + // Call + TestDelegate call = () => new MacroStabilityInwardsSemiProbabilisticOutput( + factorOfStability, + requiredProbability, + requiredReliability, + macroStabilityInwardsProbability, + macroStabilityInwardsReliability, + macroStabilityInwardsFactorOfSafety); + + // Assert + const string expectedMessage = "Kans moet in het bereik [0,0, 1,0] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj =================================================================== diff -u -rac96d7c315129af851634ed5a4a6800b59ede718 -r490ca61d1c7791776cc522141816391f075a9752 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.Test.csproj) (revision ac96d7c315129af851634ed5a4a6800b59ede718) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.Test.csproj) (revision 490ca61d1c7791776cc522141816391f075a9752) @@ -21,6 +21,7 @@ +