Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresInput.cs =================================================================== diff -u --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresInput.cs (revision 0) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresInput.cs (revision 51f60243a241f8c02b09ace2f9488af3a93fd6b4) @@ -0,0 +1,406 @@ +// 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 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; +using Core.Common.Base.Data; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.Probabilistics; + +namespace Ringtoets.ClosingStructures.Data +{ + public class ClosingStructuresInput : Observable, ICalculationInput + { + private RoundedDouble orientationOfTheNormalOfTheStructure; + private RoundedDouble factorStormDurationOpenStructure; + + private readonly NormalDistribution thresholdLowWeirHeight; + private readonly NormalDistribution drainCoefficient; + private readonly LogNormalDistribution areaFlowApertures; + private double failureProbablityOpenStructure; + private double failureProbabilityReparation; + private readonly NormalDistribution levelCrestOfStructureNotClosing; + private readonly NormalDistribution waterLevelInside; + private readonly LogNormalDistribution storageStructureArea; + private readonly LogNormalDistribution allowableIncreaseOfLevelForStorage; + private readonly LogNormalDistribution flowWidthAtBottomProtection; + private double failureProbabilityOfStructureGivenErosion; + private readonly NormalDistribution widthOfFlowApertures; + private readonly LogNormalDistribution stormDuration; + private double probabilityOpenStructureBeforeFlooding; + + public ClosingStructuresInput() + { + orientationOfTheNormalOfTheStructure = new RoundedDouble(2); + factorStormDurationOpenStructure = new RoundedDouble(2); + + thresholdLowWeirHeight = new NormalDistribution(2) + { + Mean = (RoundedDouble) double.NaN, + StandardDeviation = (RoundedDouble) 0.1 + }; + + drainCoefficient = new NormalDistribution(2) + { + Mean = (RoundedDouble) 1, + StandardDeviation = (RoundedDouble) 0.2 + }; + + areaFlowApertures = new LogNormalDistribution(2) + { + Mean = (RoundedDouble) double.NaN, + StandardDeviation = (RoundedDouble) 0.01 + }; + + levelCrestOfStructureNotClosing = new NormalDistribution(2) + { + Mean = (RoundedDouble) double.NaN, + StandardDeviation = (RoundedDouble) 0.05 + }; + + waterLevelInside = new NormalDistribution(2) + { + Mean = (RoundedDouble) double.NaN, + StandardDeviation = (RoundedDouble) 0.1 + }; + + allowableIncreaseOfLevelForStorage = new LogNormalDistribution(2) + { + Mean = (RoundedDouble) double.NaN, + StandardDeviation = (RoundedDouble) 0.1 + }; + + storageStructureArea = new LogNormalDistribution(2) + { + Mean = (RoundedDouble) double.NaN, + StandardDeviation = (RoundedDouble) 0.1 + }; + + flowWidthAtBottomProtection = new LogNormalDistribution(2) + { + Mean = (RoundedDouble) double.NaN, + StandardDeviation = (RoundedDouble) 0.05 + }; + + widthOfFlowApertures = new NormalDistribution(2) + { + Mean = (RoundedDouble) double.NaN, + }; + widthOfFlowApertures.SetStandardDeviationFromVariationCoefficient(0.05); + + stormDuration = new LogNormalDistribution(2) + { + Mean = (RoundedDouble) 7.5 + }; + stormDuration.SetStandardDeviationFromVariationCoefficient(0.25); + + probabilityOpenStructureBeforeFlooding = 1.0; + } + + #region Deterministic inputs + + /// + /// Gets or sets the storm duration for an open structure. + /// + public RoundedDouble FactorStormDurationOpenStructure + { + get + { + return factorStormDurationOpenStructure; + } + set + { + factorStormDurationOpenStructure = value.ToPrecision(factorStormDurationOpenStructure.NumberOfDecimalPlaces); + } + } + + /// + /// Gets or sets the orientation of the normal of the structure. + /// + public RoundedDouble OrientationOfTheNormalOfTheStructure + { + get + { + return orientationOfTheNormalOfTheStructure; + } + set + { + orientationOfTheNormalOfTheStructure = value.ToPrecision(orientationOfTheNormalOfTheStructure.NumberOfDecimalPlaces); + } + } + + /// + /// Gets or sets the identical apertures to use during the calculation. + /// + public int IdenticalAperture { get; set; } + + /// + /// Gets or sets the failure probability of an open structure. + /// + /// Thrown when the value of the probability + /// is not between [0, 1]. + public double FailureProbabilityOpenStructure + { + get + { + return failureProbablityOpenStructure; + } + set + { + if (value < 0 || value > 1) + { + // TODO: refactor this in HeightStructures input to Common Forms Resources + throw new ArgumentException("De waarde voor de faalkans moet in het bereik tussen [0, 1] liggen."); + } + failureProbablityOpenStructure = value; + } + } + + /// + /// Gets or sets the reparation failure probability. + /// + /// Thrown when the value of the probability + /// is not between [0, 1]. + public double FailureProbablityReparation + { + get + { + return failureProbabilityReparation; + } + set + { + if (value < 0 || value > 1) + { + // TODO: refactor this in HeightStructures input to Common Forms Resources + throw new ArgumentException("De waarde voor de faalkans moet in het bereik tussen [0, 1] liggen."); + } + failureProbabilityReparation = value; + } + } + + /// + /// Gets or sets the failure probability of structure given erosion. + /// + /// Thrown when the value of the probability + /// is not between [0, 1]. + public double FailureProbabilityOfStructureGivenErosion + { + get + { + return failureProbabilityOfStructureGivenErosion; + } + set + { + if (value < 0 || value > 1) + { + // TODO: refactor this in HeightStructures input to Common Forms Resources + throw new ArgumentException("De waarde voor de faalkans moet in het bereik tussen [0, 1] liggen."); + } + failureProbabilityOfStructureGivenErosion = value; + } + } + + /// + /// Gets or sets the failure probability of an open structure before flooding. + /// + /// Thrown when the value of the probability + /// is not between [0, 1]. + public double ProbabilityOpenStructureBeforeFlooding + { + get + { + return probabilityOpenStructureBeforeFlooding; + } + set + { + if (value < 0 || value > 1) + { + // TODO: refactor this in HeightStructures input to Common Forms Resources + throw new ArgumentException("De waarde voor de faalkans moet in het bereik tussen [0, 1] liggen."); + } + probabilityOpenStructureBeforeFlooding = value; + } + } + + #endregion + + #region Probabilistic inputs + + /// + /// Gets the drain coefficient normal distribution and sets the the drain coefficient mean. + /// + public NormalDistribution DrainCoefficient + { + get + { + return drainCoefficient; + } + set + { + drainCoefficient.Mean = value.Mean; + } + } + + /// + /// Gets the threshold low weir height normal distribution and sets the threshold low weir height mean. + /// + public NormalDistribution ThresholdLowWeirHeight + { + get + { + return thresholdLowWeirHeight; + } + set + { + thresholdLowWeirHeight.Mean = value.Mean; + } + } + + /// + /// Gets and sets the area flow apertures normal distribution. + /// + public LogNormalDistribution AreaFlowApertures + { + get + { + return areaFlowApertures; + } + set + { + areaFlowApertures.Mean = value.Mean; + areaFlowApertures.StandardDeviation = value.StandardDeviation; + } + } + + /// + /// Gets or sets the level crest of structure not closing normal distribution. + /// + public NormalDistribution LevelCrestOfStructureNotClosing + { + get + { + return levelCrestOfStructureNotClosing; + } + set + { + levelCrestOfStructureNotClosing.Mean = value.Mean; + levelCrestOfStructureNotClosing.StandardDeviation = value.StandardDeviation; + } + } + + /// + /// Gets or sets the water level inside normal distribution. + /// + public NormalDistribution WaterLevelInside + { + get + { + return waterLevelInside; + } + set + { + waterLevelInside.Mean = value.Mean; + waterLevelInside.StandardDeviation = value.StandardDeviation; + } + } + + /// + /// Gets or sets the allowable increase of level for storage log normal distribution. + /// + public LogNormalDistribution AllowableIncreaseOfLevelForStorage + { + get + { + return allowableIncreaseOfLevelForStorage; + } + set + { + allowableIncreaseOfLevelForStorage.Mean = value.Mean; + allowableIncreaseOfLevelForStorage.StandardDeviation = value.StandardDeviation; + } + } + + /// + /// Gets or sets the storage structure area log normal distribution. + /// + public LogNormalDistribution StorageStructureArea + { + get + { + return storageStructureArea; + } + set + { + storageStructureArea.Mean = value.Mean; + storageStructureArea.StandardDeviation = value.StandardDeviation; + } + } + + /// + /// Gets or sets the flow widt at bottom protection log normal distribution. + /// + public LogNormalDistribution FlowWidthAtBottomProtection + { + get + { + return flowWidthAtBottomProtection; + } + set + { + flowWidthAtBottomProtection.Mean = value.Mean; + flowWidthAtBottomProtection.StandardDeviation = value.StandardDeviation; + } + } + + /// + /// Gets or sets the width of flow apertures normal distribution. + /// + public NormalDistribution WidthOfFlowApertures + { + get + { + return widthOfFlowApertures; + } + set + { + widthOfFlowApertures.Mean = value.Mean; + widthOfFlowApertures.StandardDeviation = value.StandardDeviation; + } + } + + /// + /// Gets the storm duration log normal distribution and sets the storm duration mean. + /// + public LogNormalDistribution StormDuration + { + get + { + return stormDuration; + } + set + { + stormDuration.Mean = value.Mean; + } + } + + #endregion + } +} \ No newline at end of file Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/GeneralClosingStructuresInput.cs =================================================================== diff -u -rccce1ae96e85aa2603c218de61de03fb14cfae11 -r51f60243a241f8c02b09ace2f9488af3a93fd6b4 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/GeneralClosingStructuresInput.cs (.../GeneralClosingStructuresInput.cs) (revision ccce1ae96e85aa2603c218de61de03fb14cfae11) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/GeneralClosingStructuresInput.cs (.../GeneralClosingStructuresInput.cs) (revision 51f60243a241f8c02b09ace2f9488af3a93fd6b4) @@ -55,8 +55,9 @@ ModelFactorForSubCriticalFlow = new NormalDistribution(1) { Mean = (RoundedDouble) 1, - StandardDeviation = (RoundedDouble) 0.1 }; + ModelfactorForSubcriticalFlow.SetStandardDeviationFromVariationCoefficient(0.1); + ModelFactorForIncomingFlowVolume = new RoundedDouble(2, 1); } Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/Ringtoets.ClosingStructures.Data.csproj =================================================================== diff -u -rfbf9eca188c20c352a702ee20c183e5dc3c7acf1 -r51f60243a241f8c02b09ace2f9488af3a93fd6b4 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/Ringtoets.ClosingStructures.Data.csproj (.../Ringtoets.ClosingStructures.Data.csproj) (revision fbf9eca188c20c352a702ee20c183e5dc3c7acf1) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/Ringtoets.ClosingStructures.Data.csproj (.../Ringtoets.ClosingStructures.Data.csproj) (revision 51f60243a241f8c02b09ace2f9488af3a93fd6b4) @@ -42,6 +42,7 @@ + Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs =================================================================== diff -u --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs (revision 0) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs (revision 51f60243a241f8c02b09ace2f9488af3a93fd6b4) @@ -0,0 +1,421 @@ +// 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 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; +using Core.Common.Base.Data; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Common.Data.TestUtil; + +namespace Ringtoets.ClosingStructures.Data.Test +{ + [TestFixture] + public class ClosingStructuresInputTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var input = new ClosingStructuresInput(); + + // Assert + Assert.IsInstanceOf(input); + Assert.IsInstanceOf(input); + + AssertEqualValues(0.1, input.ThresholdLowWeirHeight.StandardDeviation); + + AssertEqualValues(1, input.DrainCoefficient.Mean); + AssertEqualValues(0.2, input.DrainCoefficient.StandardDeviation); + + AssertEqualValues(0.01, input.AreaFlowApertures.StandardDeviation); + AssertEqualValues(0.05, input.LevelCrestOfStructureNotClosing.StandardDeviation); + AssertEqualValues(0.1, input.WaterLevelInside.StandardDeviation); + + AssertEqualValues(0.1, input.AllowableIncreaseOfLevelForStorage.StandardDeviation); + AssertEqualValues(0.1, input.StorageStructureArea.StandardDeviation); + AssertEqualValues(0.05, input.FlowWidthAtBottomProtection.StandardDeviation); + AssertEqualValues(7.5, input.StormDuration.Mean); + AssertEqualValues(0.25, input.StormDuration.GetVariationCoefficient()); + Assert.AreEqual(1, input.ProbabilityOpenStructureBeforeFlooding); + } + + [Test] + public void Properties_OrientationOfTheNormalStructure_ExpectedValues() + { + // Setup + var input = new ClosingStructuresInput(); + var random = new Random(22); + + var orientationOfTheNormalStructure = new RoundedDouble(5, random.NextDouble()); + + // Call + input.OrientationOfTheNormalOfTheStructure = orientationOfTheNormalStructure; + + // Assert + Assert.AreEqual(2, input.OrientationOfTheNormalOfTheStructure.NumberOfDecimalPlaces); + AssertEqualValues(orientationOfTheNormalStructure, input.OrientationOfTheNormalOfTheStructure); + } + + [Test] + public void Properties_FactorStormDurationOpenStructure_ExpectedValues() + { + // Setup + var input = new ClosingStructuresInput(); + var random = new Random(22); + + var factorStormDuration = new RoundedDouble(5, random.NextDouble()); + + // Call + input.FactorStormDurationOpenStructure = factorStormDuration; + + // Assert + Assert.AreEqual(2, input.FactorStormDurationOpenStructure.NumberOfDecimalPlaces); + AssertEqualValues(factorStormDuration, input.FactorStormDurationOpenStructure); + } + + [Test] + public void Properties_ThresholdLowWeirHeight_ExpectedValues() + { + // Setup + var input = new ClosingStructuresInput(); + NormalDistribution thresholdLowWeirHeight = GenerateNormalDistribution(); + + RoundedDouble initialStd = input.ThresholdLowWeirHeight.StandardDeviation; + + //Call + input.ThresholdLowWeirHeight = thresholdLowWeirHeight; + + //Assert + Assert.AreEqual(thresholdLowWeirHeight.Mean, input.ThresholdLowWeirHeight.Mean); + AssertEqualValues(initialStd, input.ThresholdLowWeirHeight.StandardDeviation); + } + + [Test] + public void Properties_DrainCoefficient_ExpectedValues() + { + // Setup + var input = new ClosingStructuresInput(); + NormalDistribution drainCoefficient = GenerateNormalDistribution(); + + RoundedDouble initialStd = input.DrainCoefficient.StandardDeviation; + + //Call + input.DrainCoefficient = drainCoefficient; + + //Assert + Assert.AreEqual(drainCoefficient.Mean, input.DrainCoefficient.Mean); + AssertEqualValues(initialStd, input.DrainCoefficient.StandardDeviation); + } + + [Test] + public void Properties_AreaFlowApertures_ExpectedValues() + { + // Setup + var input = new ClosingStructuresInput(); + LogNormalDistribution areaFlowApertures = GenerateLogNormalDistribution(); + + //Call + input.AreaFlowApertures = areaFlowApertures; + + //Assert + Assert.AreEqual(areaFlowApertures.Mean, input.AreaFlowApertures.Mean); + AssertEqualValues(areaFlowApertures.StandardDeviation, input.AreaFlowApertures.StandardDeviation); + } + + [Test] + [TestCase(-1.1)] + [TestCase(2)] + public void Properties_FailureProbablityOpenStructure_ThrowArgumentException(double probability) + { + // Setup + var input = new ClosingStructuresInput(); + + // Call + TestDelegate call = () => input.FailureProbabilityOpenStructure = probability; + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "De waarde voor de faalkans moet in het bereik tussen [0, 1] liggen."); + } + + [Test] + [TestCase(0)] + [TestCase(0.5)] + [TestCase(1.0)] + public void Properties_FailureProbabilityOpenStructure_ExpectedValues(double probability) + { + // Setup + var input = new ClosingStructuresInput(); + + // Call + input.FailureProbabilityOpenStructure = probability; + + // Assert + Assert.AreEqual(probability, input.FailureProbabilityOpenStructure); + } + + [Test] + [TestCase(-1.1)] + [TestCase(2)] + public void Properties_FailureProbablityReparation_ThrowArgumentException(double probability) + { + // Setup + var input = new ClosingStructuresInput(); + + // Call + TestDelegate call = () => input.FailureProbablityReparation = probability; + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "De waarde voor de faalkans moet in het bereik tussen [0, 1] liggen."); + } + + [Test] + [TestCase(0)] + [TestCase(0.5)] + [TestCase(1.0)] + public void Properties_FailureProbabilityReparation_ExpectedValues(double probability) + { + // Setup + var input = new ClosingStructuresInput(); + + // Call + input.FailureProbablityReparation = probability; + + // Assert + Assert.AreEqual(probability, input.FailureProbablityReparation); + } + + [Test] + public void Properties_IdenticalAperture_ExpectedValues() + { + // Setup + var input = new ClosingStructuresInput(); + var random = new Random(22); + + int identicalAperture = random.Next(); + + // Call + input.IdenticalAperture = identicalAperture; + + // Assert + Assert.AreEqual(identicalAperture, input.IdenticalAperture); + } + + [Test] + public void Properties_LevelCrestOfStructureNotClosing_ExpectedValues() + { + // Setup + var input = new ClosingStructuresInput(); + NormalDistribution levelCrestOfStructureNotClosing = GenerateNormalDistribution(); + + //Call + input.LevelCrestOfStructureNotClosing = levelCrestOfStructureNotClosing; + + //Assert + Assert.AreEqual(levelCrestOfStructureNotClosing.Mean, input.LevelCrestOfStructureNotClosing.Mean); + Assert.AreEqual(levelCrestOfStructureNotClosing.StandardDeviation, input.LevelCrestOfStructureNotClosing.StandardDeviation); + } + + [Test] + public void Properties_WaterLevelInside_ExpectedValues() + { + // Setup + var input = new ClosingStructuresInput(); + NormalDistribution waterLevelInside = GenerateNormalDistribution(); + + //Call + input.WaterLevelInside = waterLevelInside; + + //Assert + Assert.AreEqual(waterLevelInside.Mean, input.WaterLevelInside.Mean); + Assert.AreEqual(waterLevelInside.StandardDeviation, input.WaterLevelInside.StandardDeviation); + } + + [Test] + public void Properties_AllowableIncreaseOfLevelForStorage_ExpectedValues() + { + // Setup + var input = new ClosingStructuresInput(); + LogNormalDistribution allowableIncreaseOfLevelForStorage = GenerateLogNormalDistribution(); + + //Call + input.AllowableIncreaseOfLevelForStorage = allowableIncreaseOfLevelForStorage; + + //Assert + Assert.AreEqual(allowableIncreaseOfLevelForStorage.Mean, input.AllowableIncreaseOfLevelForStorage.Mean); + Assert.AreEqual(allowableIncreaseOfLevelForStorage.StandardDeviation, input.AllowableIncreaseOfLevelForStorage.StandardDeviation); + } + + [Test] + public void Properties_StorageStructureArea_ExpectedValues() + { + // Setup + var input = new ClosingStructuresInput(); + LogNormalDistribution storageStructureArea = GenerateLogNormalDistribution(); + + //Call + input.StorageStructureArea = storageStructureArea; + + //Assert + Assert.AreEqual(storageStructureArea.Mean, input.StorageStructureArea.Mean); + Assert.AreEqual(storageStructureArea.StandardDeviation, input.StorageStructureArea.StandardDeviation); + } + + [Test] + public void Properties_FlowWidthAtBottomProtection_ExpectedValues() + { + // Setup + var input = new ClosingStructuresInput(); + LogNormalDistribution flowWidthAtBottomProtection = GenerateLogNormalDistribution(); + + //Call + input.FlowWidthAtBottomProtection = flowWidthAtBottomProtection; + + //Assert + Assert.AreEqual(flowWidthAtBottomProtection.Mean, input.FlowWidthAtBottomProtection.Mean); + Assert.AreEqual(flowWidthAtBottomProtection.StandardDeviation, input.FlowWidthAtBottomProtection.StandardDeviation); + } + + [Test] + [TestCase(-1.1)] + [TestCase(2)] + public void Properties_FailureProbabilityOfStructureGivenErosion_ThrowArgumentException(double probability) + { + // Setup + var input = new ClosingStructuresInput(); + + // Call + TestDelegate call = () => input.FailureProbabilityOfStructureGivenErosion = probability; + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "De waarde voor de faalkans moet in het bereik tussen [0, 1] liggen."); + } + + [Test] + [TestCase(0)] + [TestCase(0.5)] + [TestCase(1.0)] + public void Properties_FailureProbabilityOfStructureGivenErosion_ExpectedValues(double probability) + { + // Setup + var input = new ClosingStructuresInput(); + + // Call + input.FailureProbabilityOfStructureGivenErosion = probability; + + // Assert + Assert.AreEqual(probability, input.FailureProbabilityOfStructureGivenErosion); + } + + + [Test] + public void Properties_WidthOfFlowApertures_ExpectedValues() + { + // Setup + var input = new ClosingStructuresInput(); + NormalDistribution widthOfFlowApertures = GenerateNormalDistribution(); + + //Call + input.WidthOfFlowApertures = widthOfFlowApertures; + + //Assert + Assert.AreEqual(widthOfFlowApertures.Mean, input.WidthOfFlowApertures.Mean); + Assert.AreEqual(widthOfFlowApertures.StandardDeviation, input.WidthOfFlowApertures.StandardDeviation); + } + + [Test] + [TestCase(-1.1)] + [TestCase(2)] + public void Properties_ProbabilityOpenStructureBeforeFlooding_ThrowArgumentException(double probability) + { + // Setup + var input = new ClosingStructuresInput(); + + // Call + TestDelegate call = () => input.ProbabilityOpenStructureBeforeFlooding = probability; + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "De waarde voor de faalkans moet in het bereik tussen [0, 1] liggen."); + } + + [Test] + [TestCase(0)] + [TestCase(0.5)] + [TestCase(1.0)] + public void Properties_ProbabilityOpenStructureBeforeFlooding_ExpectedValues(double probability) + { + // Setup + var input = new ClosingStructuresInput(); + + // Call + input.ProbabilityOpenStructureBeforeFlooding = probability; + + // Assert + Assert.AreEqual(probability, input.ProbabilityOpenStructureBeforeFlooding); + } + + + [Test] + public void Properties_StormDuration_ExpectedValues() + { + // Setup + var input = new ClosingStructuresInput(); + LogNormalDistribution stormDuration = GenerateLogNormalDistribution(); + + RoundedDouble initialStd = input.StormDuration.StandardDeviation; + + //Call + input.StormDuration = stormDuration; + + //Assert + Assert.AreEqual(stormDuration.Mean, input.StormDuration.Mean); + AssertEqualValues(initialStd, input.StormDuration.StandardDeviation); + } + + + private void AssertEqualValues(double expectedValue, RoundedDouble actualValue) + { + Assert.AreEqual(expectedValue, actualValue, actualValue.GetAccuracy()); + } + + private static LogNormalDistribution GenerateLogNormalDistribution() + { + var random = new Random(22); + return new LogNormalDistribution(2) + { + Mean = (RoundedDouble)(0.01 + random.NextDouble()), + StandardDeviation = (RoundedDouble)random.NextDouble() + }; + } + + private static NormalDistribution GenerateNormalDistribution() + { + var random = new Random(22); + return new NormalDistribution(2) + { + Mean = (RoundedDouble)(0.01 + random.NextDouble()), + StandardDeviation = (RoundedDouble)random.NextDouble() + }; + } + } +} Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/GeneralClosingStructuresInputTest.cs =================================================================== diff -u -rccce1ae96e85aa2603c218de61de03fb14cfae11 -r51f60243a241f8c02b09ace2f9488af3a93fd6b4 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/GeneralClosingStructuresInputTest.cs (.../GeneralClosingStructuresInputTest.cs) (revision ccce1ae96e85aa2603c218de61de03fb14cfae11) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/GeneralClosingStructuresInputTest.cs (.../GeneralClosingStructuresInputTest.cs) (revision 51f60243a241f8c02b09ace2f9488af3a93fd6b4) @@ -57,19 +57,19 @@ var modelFactorOvertoppingFlow = new LogNormalDistribution(3) { - Mean = new RoundedDouble(2, 0.09), - StandardDeviation = new RoundedDouble(2, 0.06) + Mean = new RoundedDouble(2, 0.09), + StandardDeviation = new RoundedDouble(2, 0.06) }; Assert.AreEqual(modelFactorOvertoppingFlow.Mean, inputParameters.ModelFactorOvertoppingFlow.Mean); Assert.AreEqual(modelFactorOvertoppingFlow.StandardDeviation, inputParameters.ModelFactorOvertoppingFlow.StandardDeviation); var modelfactorForStorageVolume = new LogNormalDistribution(2) { - Mean = (RoundedDouble) 1.0, - StandardDeviation = (RoundedDouble) 0.2 + Mean = (RoundedDouble) 1.0 }; Assert.AreEqual(modelfactorForStorageVolume.Mean, inputParameters.ModelFactorForStorageVolume.Mean); - Assert.AreEqual(modelfactorForStorageVolume.StandardDeviation, inputParameters.ModelFactorForStorageVolume.StandardDeviation); + Assert.AreEqual(0.2, inputParameters.ModelFactorForStorageVolume.GetVariationCoefficient(), + inputParameters.ModelFactorForStorageVolume.GetVariationCoefficient().GetAccuracy()); Assert.AreEqual(2, inputParameters.ModelFactorForIncomingFlowVolume.NumberOfDecimalPlaces); Assert.AreEqual(1.0, inputParameters.ModelFactorForIncomingFlowVolume, inputParameters.ModelFactorForIncomingFlowVolume.GetAccuracy()); Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/Ringtoets.ClosingStructures.Data.Test.csproj =================================================================== diff -u -rfbf9eca188c20c352a702ee20c183e5dc3c7acf1 -r51f60243a241f8c02b09ace2f9488af3a93fd6b4 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/Ringtoets.ClosingStructures.Data.Test.csproj (.../Ringtoets.ClosingStructures.Data.Test.csproj) (revision fbf9eca188c20c352a702ee20c183e5dc3c7acf1) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/Ringtoets.ClosingStructures.Data.Test.csproj (.../Ringtoets.ClosingStructures.Data.Test.csproj) (revision 51f60243a241f8c02b09ace2f9488af3a93fd6b4) @@ -50,6 +50,7 @@ + @@ -65,6 +66,10 @@ {3BBFD65B-B277-4E50-AE6D-BD24C3434609} Core.Common.Base + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + {D4200F43-3F72-4F42-AF0A-8CED416A38EC} Ringtoets.Common.Data