Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresInput.cs =================================================================== diff -u -rf2053e36f2f245041599654de6aff095721e81bf -r64fea503e6e9cacfb0ff8f22cfdd864b60c95bab --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresInput.cs (.../ClosingStructuresInput.cs) (revision f2053e36f2f245041599654de6aff095721e81bf) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresInput.cs (.../ClosingStructuresInput.cs) (revision 64fea503e6e9cacfb0ff8f22cfdd864b60c95bab) @@ -20,64 +20,41 @@ // All rights reserved. using System; -using System.Linq; -using Core.Common.Base; using Core.Common.Base.Data; -using Core.Common.Base.Geometry; -using Ringtoets.Common.Data.Calculation; -using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.Probabilistics; -using Ringtoets.HydraRing.Data; +using Ringtoets.Common.Data.Structures; using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; namespace Ringtoets.ClosingStructures.Data { /// /// Class that holds all closing structures calculation specific input parameters. /// - public class ClosingStructuresInput : Observable, ICalculationInput + public class ClosingStructuresInput : StructuresInputBase { - private readonly NormalDistribution modelFactorSuperCriticalFlow; private readonly NormalDistribution thresholdHeightOpenWeir; private readonly NormalDistribution drainCoefficient; private readonly LogNormalDistribution areaFlowApertures; private readonly NormalDistribution levelCrestStructureNotClosing; private readonly NormalDistribution insideWaterLevel; - private readonly VariationCoefficientLogNormalDistribution storageStructureArea; - private readonly LogNormalDistribution allowedLevelIncreaseStorage; - private readonly LogNormalDistribution flowWidthAtBottomProtection; - private readonly VariationCoefficientNormalDistribution widthFlowApertures; - private readonly VariationCoefficientLogNormalDistribution stormDuration; - private readonly VariationCoefficientLogNormalDistribution criticalOvertoppingDischarge; - private RoundedDouble structureNormalOrientation; private RoundedDouble factorStormDurationOpenStructure; private double failureProbabilityOpenStructure; private double failureProbabilityReparation; - private double failureProbabilityStructureWithErosion; private double probabilityOpenStructureBeforeFlooding; private RoundedDouble deviationWaveDirection; - private ForeshoreProfile foreshoreProfile; /// /// Creates a new instance of the class. /// public ClosingStructuresInput() { - structureNormalOrientation = new RoundedDouble(2, double.NaN); factorStormDurationOpenStructure = new RoundedDouble(2, double.NaN); deviationWaveDirection = new RoundedDouble(2, double.NaN); failureProbabilityOpenStructure = double.NaN; failureProbabilityReparation = double.NaN; - failureProbabilityStructureWithErosion = double.NaN; probabilityOpenStructureBeforeFlooding = 1.0; - modelFactorSuperCriticalFlow = new NormalDistribution(2) - { - Mean = (RoundedDouble) 1.1, - StandardDeviation = (RoundedDouble) 0.03 - }; - thresholdHeightOpenWeir = new NormalDistribution(2) { Mean = (RoundedDouble) double.NaN, @@ -108,58 +85,12 @@ StandardDeviation = (RoundedDouble) 0.1 }; - allowedLevelIncreaseStorage = new LogNormalDistribution(2) - { - Mean = (RoundedDouble) double.NaN, - StandardDeviation = (RoundedDouble) 0.1 - }; - - storageStructureArea = new VariationCoefficientLogNormalDistribution(2) - { - Mean = (RoundedDouble) double.NaN, - CoefficientOfVariation = (RoundedDouble) 0.1 - }; - - flowWidthAtBottomProtection = new LogNormalDistribution(2) - { - Mean = (RoundedDouble) double.NaN, - StandardDeviation = (RoundedDouble) 0.05 - }; - - criticalOvertoppingDischarge = new VariationCoefficientLogNormalDistribution(2) - { - Mean = (RoundedDouble) double.NaN, - CoefficientOfVariation = (RoundedDouble) 0.15 - }; - - widthFlowApertures = new VariationCoefficientNormalDistribution(2) - { - Mean = (RoundedDouble) double.NaN, - CoefficientOfVariation = (RoundedDouble) 0.05 - }; - - stormDuration = new VariationCoefficientLogNormalDistribution(2) - { - Mean = (RoundedDouble) 6.0, - CoefficientOfVariation = (RoundedDouble) 0.25 - }; - - UpdateForeshoreProperties(); + UpdateStructureProperties(); } - - private static bool ValidProbabilityValue(double probability) - { - return !double.IsNaN(probability) && probability <= 1 && probability >= 0; - } - + #region Structure /// - /// Gets or sets the closing structure. - /// - public ClosingStructure ClosingStructure { get; set; } - - /// /// Gets or sets the type of closing structure inflow model. /// public ClosingStructureInflowModelType InflowModelType { get; set; } @@ -169,22 +100,6 @@ #region Model factors /// - /// Gets or sets the model factor for the super critical flow. - /// - /// Only sets the mean. - public NormalDistribution ModelFactorSuperCriticalFlow - { - get - { - return modelFactorSuperCriticalFlow; - } - set - { - modelFactorSuperCriticalFlow.Mean = value.Mean; - } - } - - /// /// Gets or sets the drain coefficient. /// /// Only sets the mean. @@ -219,80 +134,7 @@ #region Hydraulic data - public HydraulicBoundaryLocation HydraulicBoundaryLocation { get; set; } - - #region Foreshore Profile - /// - /// Gets or sets the foreshore profile. - /// - public ForeshoreProfile ForeshoreProfile - { - get - { - return foreshoreProfile; - } - set - { - foreshoreProfile = value; - UpdateForeshoreProperties(); - } - } - - /// - /// Gets or sets whether the needs to be taken into account. - /// - public bool UseBreakWater { get; set; } - - /// - /// Gets or sets whether the needs to be taken into account. - /// - public bool UseForeshore { get; set; } - - /// - /// Gets the geometry of the foreshore. - /// - public RoundedPoint2DCollection ForeshoreGeometry - { - get - { - return foreshoreProfile != null - ? foreshoreProfile.Geometry - : new RoundedPoint2DCollection(2, Enumerable.Empty()); - } - } - - /// - /// Gets the . - /// - public BreakWater BreakWater { get; private set; } - - private void UpdateForeshoreProperties() - { - if (foreshoreProfile == null) - { - UseForeshore = false; - UseBreakWater = false; - BreakWater = GetDefaultBreakWaterProperties(); - } - else - { - UseForeshore = foreshoreProfile.Geometry.Count() > 1; - UseBreakWater = foreshoreProfile.HasBreakWater; - BreakWater = foreshoreProfile.HasBreakWater ? - new BreakWater(foreshoreProfile.BreakWater.Type, foreshoreProfile.BreakWater.Height) : - GetDefaultBreakWaterProperties(); - } - } - - private BreakWater GetDefaultBreakWaterProperties() - { - return new BreakWater(BreakWaterType.Dam, 0.0); - } - - #endregion - - /// /// Gets or sets the inside water level. /// [m+NAP] /// @@ -325,56 +167,11 @@ } } - /// - /// Gets or sets the storm duration. - /// [hrs] - /// - /// Only sets the mean. - public VariationCoefficientLogNormalDistribution StormDuration - { - get - { - return stormDuration; - } - set - { - stormDuration.Mean = value.Mean; - } - } - #endregion #region Schematization /// - /// Gets or sets the orientation of the normal of the structure. - /// [degrees] - /// - ///Thown when the value for the orientation is not between [0,360] degrees. - public RoundedDouble StructureNormalOrientation - { - get - { - return structureNormalOrientation; - } - set - { - if (double.IsNaN(value)) - { - structureNormalOrientation = value.ToPrecision(structureNormalOrientation.NumberOfDecimalPlaces); - return; - } - - RoundedDouble newOrientationValue = value.ToPrecision(structureNormalOrientation.NumberOfDecimalPlaces); - if (newOrientationValue < 0 || newOrientationValue > 360) - { - throw new ArgumentOutOfRangeException("value", RingtoetsCommonDataResources.Orientation_Value_needs_to_be_between_0_and_360); - } - structureNormalOrientation = newOrientationValue; - } - } - - /// /// Gets or sets the threshold height of the open weir. /// [m+NAP] /// @@ -475,113 +272,6 @@ } /// - /// Gets or sets the allowed increase of level for storage. - /// [m] - /// - public LogNormalDistribution AllowedLevelIncreaseStorage - { - get - { - return allowedLevelIncreaseStorage; - } - set - { - allowedLevelIncreaseStorage.Mean = value.Mean; - allowedLevelIncreaseStorage.StandardDeviation = value.StandardDeviation; - } - } - - /// - /// Gets or sets the storage structure area. - /// [m^2] - /// - public VariationCoefficientLogNormalDistribution StorageStructureArea - { - get - { - return storageStructureArea; - } - set - { - storageStructureArea.Mean = value.Mean; - storageStructureArea.CoefficientOfVariation = value.CoefficientOfVariation; - } - } - - /// - /// Gets or sets the flow width at the bottom protection. - /// [m] - /// - public LogNormalDistribution FlowWidthAtBottomProtection - { - get - { - return flowWidthAtBottomProtection; - } - set - { - flowWidthAtBottomProtection.Mean = value.Mean; - flowWidthAtBottomProtection.StandardDeviation = value.StandardDeviation; - } - } - - /// - /// Gets or sets the critical overtopping discharge. - /// [m^3/s/m] - /// - public VariationCoefficientLogNormalDistribution CriticalOvertoppingDischarge - { - get - { - return criticalOvertoppingDischarge; - } - set - { - criticalOvertoppingDischarge.Mean = value.Mean; - criticalOvertoppingDischarge.CoefficientOfVariation = value.CoefficientOfVariation; - } - } - - /// - /// Gets or sets the failure probability of structure given erosion. - /// [1/year] - /// - /// Thrown when the value of the probability - /// is not between [0, 1]. - public double FailureProbabilityStructureWithErosion - { - get - { - return failureProbabilityStructureWithErosion; - } - set - { - if (!ValidProbabilityValue(value)) - { - throw new ArgumentOutOfRangeException("value", RingtoetsCommonDataResources.FailureProbability_Value_needs_to_be_between_0_and_1); - } - failureProbabilityStructureWithErosion = value; - } - } - - /// - /// Gets or sets the width of flow apertures. - /// [m] - /// - public VariationCoefficientNormalDistribution WidthFlowApertures - { - get - { - return widthFlowApertures; - } - set - { - widthFlowApertures.Mean = value.Mean; - widthFlowApertures.CoefficientOfVariation = value.CoefficientOfVariation; - } - } - - /// /// Gets or sets the failure probability of an open structure before flooding. /// /// Thrown when the value of the probability @@ -603,5 +293,27 @@ } #endregion + + protected override void UpdateStructureProperties() + { + if (Structure != null) + { + StructureNormalOrientation = Structure.StructureNormalOrientation; + LevelCrestStructureNotClosing = Structure.LevelCrestStructureNotClosing; + FlowWidthAtBottomProtection = Structure.FlowWidthAtBottomProtection; + CriticalOvertoppingDischarge = Structure.CriticalOvertoppingDischarge; + WidthFlowApertures = Structure.WidthFlowApertures; + StorageStructureArea = Structure.StorageStructureArea; + AllowedLevelIncreaseStorage = Structure.AllowedLevelIncreaseStorage; + InflowModelType = Structure.InflowModelType; + AreaFlowApertures = Structure.AreaFlowApertures; + FailureProbabilityOpenStructure = Structure.FailureProbabilityOpenStructure; + FailureProbabilityReparation = Structure.FailureProbabilityReparation; + IdenticalApertures = Structure.IdenticalApertures; + InsideWaterLevel = Structure.InsideWaterLevel; + ProbabilityOpenStructureBeforeFlooding = Structure.ProbabilityOpenStructureBeforeFlooding; + ThresholdHeightOpenWeir = Structure.ThresholdHeightOpenWeir; + } + } } } \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs =================================================================== diff -u -r12e5f6a6009617b69828d1b6e31b1eb3deda96b2 -r64fea503e6e9cacfb0ff8f22cfdd864b60c95bab --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs (.../ClosingStructuresInputTest.cs) (revision 12e5f6a6009617b69828d1b6e31b1eb3deda96b2) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs (.../ClosingStructuresInputTest.cs) (revision 64fea503e6e9cacfb0ff8f22cfdd864b60c95bab) @@ -20,17 +20,13 @@ // All rights reserved. using System; -using System.Collections.Generic; -using Core.Common.Base; using Core.Common.Base.Data; -using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; -using Ringtoets.Common.Data.Calculation; -using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.ClosingStructures.Data.TestUtil; using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Data.TestUtil; -using Ringtoets.HydraRing.Data; namespace Ringtoets.ClosingStructures.Data.Test { @@ -47,18 +43,6 @@ StandardDeviation = (RoundedDouble) 0.1 }; - var stormDuration = new VariationCoefficientLogNormalDistribution(2) - { - Mean = (RoundedDouble) 6, - CoefficientOfVariation = (RoundedDouble) 0.25 - }; - - var modelFactorSuperCriticalFlow = new NormalDistribution(2) - { - Mean = (RoundedDouble) 1.1, - StandardDeviation = (RoundedDouble) 0.03 - }; - var drainCoefficient = new NormalDistribution(2) { Mean = (RoundedDouble) 1, @@ -83,76 +67,23 @@ StandardDeviation = (RoundedDouble) 0.05 }; - var allowedLevelIncreaseStorage = new LogNormalDistribution(2) - { - Mean = (RoundedDouble) double.NaN, - StandardDeviation = (RoundedDouble) 0.1 - }; - - var storageStructureArea = new VariationCoefficientLogNormalDistribution(2) - { - Mean = (RoundedDouble) double.NaN, - CoefficientOfVariation = (RoundedDouble) 0.1 - }; - - var flowWidthAtBottomProtection = new LogNormalDistribution(2) - { - Mean = (RoundedDouble) double.NaN, - StandardDeviation = (RoundedDouble) 0.05 - }; - - var criticalOvertoppingDischarge = new VariationCoefficientLogNormalDistribution(2) - { - Mean = (RoundedDouble) double.NaN, - CoefficientOfVariation = (RoundedDouble) 0.15 - }; - - var widthFlowApertures = new VariationCoefficientNormalDistribution(2) - { - Mean = (RoundedDouble) double.NaN, - CoefficientOfVariation = (RoundedDouble) 0.05 - }; - // Call var input = new ClosingStructuresInput(); // Assert - Assert.IsInstanceOf(input); - Assert.IsInstanceOf(input); + Assert.IsInstanceOf>(input); - Assert.IsNull(input.HydraulicBoundaryLocation); - Assert.IsNull(input.ClosingStructure); - - AssertEqualValue(double.NaN, input.StructureNormalOrientation); - Assert.AreEqual(2, input.StructureNormalOrientation.NumberOfDecimalPlaces); - - Assert.IsNull(input.ForeshoreProfile); - Assert.IsFalse(input.UseBreakWater); - Assert.AreEqual(BreakWaterType.Dam, input.BreakWater.Type); - Assert.AreEqual(0, input.BreakWater.Height.Value); - Assert.AreEqual(2, input.BreakWater.Height.NumberOfDecimalPlaces); - Assert.IsFalse(input.UseForeshore); - CollectionAssert.IsEmpty(input.ForeshoreGeometry); - Assert.IsNaN(input.FailureProbabilityOpenStructure); - Assert.IsNaN(input.FailureProbabilityStructureWithErosion); Assert.IsNaN(input.FailureProbabilityReparation); Assert.IsNaN(input.FactorStormDurationOpenStructure); Assert.IsNaN(input.DeviationWaveDirection); DistributionAssert.AreEqual(insideWaterLevel, input.InsideWaterLevel); - DistributionAssert.AreEqual(stormDuration, input.StormDuration); - DistributionAssert.AreEqual(modelFactorSuperCriticalFlow, input.ModelFactorSuperCriticalFlow); DistributionAssert.AreEqual(drainCoefficient, input.DrainCoefficient); DistributionAssert.AreEqual(thresholdHeightOpenWeir, input.ThresholdHeightOpenWeir); DistributionAssert.AreEqual(areaFlowApertures, input.AreaFlowApertures); DistributionAssert.AreEqual(levelCrestStructureNotClosing, input.LevelCrestStructureNotClosing); - DistributionAssert.AreEqual(allowedLevelIncreaseStorage, input.AllowedLevelIncreaseStorage); - DistributionAssert.AreEqual(storageStructureArea, input.StorageStructureArea); - DistributionAssert.AreEqual(flowWidthAtBottomProtection, input.FlowWidthAtBottomProtection); - DistributionAssert.AreEqual(criticalOvertoppingDischarge, input.CriticalOvertoppingDischarge); - DistributionAssert.AreEqual(widthFlowApertures, input.WidthFlowApertures); Assert.AreEqual(1.0, input.ProbabilityOpenStructureBeforeFlooding); Assert.AreEqual(0, input.IdenticalApertures); @@ -175,184 +106,6 @@ } [Test] - public void Properties_HydraulicBoundaryLocation_ExpectedValues() - { - // Setup - var input = new ClosingStructuresInput(); - var location = new HydraulicBoundaryLocation(0, "test", 0, 0); - - // Call - input.HydraulicBoundaryLocation = location; - - // Assert - Assert.AreSame(location, input.HydraulicBoundaryLocation); - } - - [Test] - [Combinatorial] - public void ForeshoreProfile_SetNewValue_InputSyncedAccordingly( - [Values(true, false)] bool withBreakWater, - [Values(true, false)] bool withValidForeshore) - { - // Setup - var input = new ClosingStructuresInput(); - BreakWaterType originalBreakWaterType = input.BreakWater.Type; - RoundedDouble originalBreakWaterHeight = input.BreakWater.Height; - HydraulicBoundaryLocation originalHydraulicBoundaryLocation = input.HydraulicBoundaryLocation; - - var foreshoreGeometry = new List - { - new Point2D(2.2, 3.3) - }; - - if (withValidForeshore) - { - foreshoreGeometry.Add(new Point2D(4.4, 5.5)); - } - - BreakWater breakWater = null; - if (withBreakWater) - { - var nonDefaultBreakWaterType = BreakWaterType.Wall; - var nonDefaultBreakWaterHeight = 5.5; - - // Precondition - Assert.AreNotEqual(nonDefaultBreakWaterType, input.BreakWater.Type); - Assert.AreNotEqual(nonDefaultBreakWaterHeight, input.BreakWater.Height); - - breakWater = new BreakWater(nonDefaultBreakWaterType, nonDefaultBreakWaterHeight); - } - - double orientation = 96; - var foreshoreProfile = new ForeshoreProfile(new Point2D(0, 0), - foreshoreGeometry.ToArray(), - breakWater, - new ForeshoreProfile.ConstructionProperties - { - Orientation = orientation - }); - - // Call - input.ForeshoreProfile = foreshoreProfile; - - // Assert - Assert.AreSame(foreshoreProfile, input.ForeshoreProfile); - Assert.AreEqual(withBreakWater, input.UseBreakWater); - Assert.AreEqual(withBreakWater ? foreshoreProfile.BreakWater.Type : originalBreakWaterType, input.BreakWater.Type); - Assert.AreEqual(withBreakWater ? foreshoreProfile.BreakWater.Height : originalBreakWaterHeight, input.BreakWater.Height); - Assert.AreEqual(withValidForeshore, input.UseForeshore); - CollectionAssert.AreEqual(foreshoreProfile.Geometry, input.ForeshoreGeometry); - Assert.AreEqual(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation); - } - - [Test] - public void Foreshore_SetNullValue_InputSyncedToDefaults() - { - // Setup - var input = new ClosingStructuresInput(); - BreakWaterType originalBreakWaterType = input.BreakWater.Type; - RoundedDouble originalBreakWaterHeight = input.BreakWater.Height; - HydraulicBoundaryLocation originalHydraulicBoundaryLocation = input.HydraulicBoundaryLocation; - - var foreshoreProfile = new ForeshoreProfile(new Point2D(0, 0), - new[] - { - new Point2D(3.3, 4.4), - new Point2D(5.5, 6.6) - }, - new BreakWater(BreakWaterType.Caisson, 2.2), - new ForeshoreProfile.ConstructionProperties - { - Orientation = 96 - }); - - input.ForeshoreProfile = foreshoreProfile; - - // Precondition - Assert.AreSame(foreshoreProfile, input.ForeshoreProfile); - Assert.IsTrue(input.UseBreakWater); - Assert.AreNotEqual(originalBreakWaterType, input.BreakWater.Type); - Assert.AreNotEqual(originalBreakWaterHeight, input.BreakWater.Height); - Assert.IsTrue(input.UseForeshore); - CollectionAssert.IsNotEmpty(input.ForeshoreGeometry); - Assert.AreEqual(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation); - - // Call - input.ForeshoreProfile = null; - - // Assert - Assert.IsFalse(input.UseBreakWater); - Assert.AreEqual(originalBreakWaterType, input.BreakWater.Type); - Assert.AreEqual(originalBreakWaterHeight, input.BreakWater.Height); - Assert.IsFalse(input.UseForeshore); - CollectionAssert.IsEmpty(input.ForeshoreGeometry); - Assert.AreEqual(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation); - } - - [Test] - [TestCase(360.004)] - [TestCase(300)] - [TestCase(0)] - [TestCase(-0.004)] - [TestCase(double.NaN)] - public void Properties_StructureNormalOrientationValidValues_NewValueSet(double orientation) - { - // Setup - var input = new ClosingStructuresInput(); - - // Call - input.StructureNormalOrientation = (RoundedDouble) orientation; - - // Assert - Assert.AreEqual(2, input.StructureNormalOrientation.NumberOfDecimalPlaces); - AssertEqualValue(orientation, input.StructureNormalOrientation); - } - - [Test] - [TestCase(400)] - [TestCase(360.05)] - [TestCase(-0.005)] - [TestCase(-23)] - [TestCase(double.PositiveInfinity)] - [TestCase(double.NegativeInfinity)] - public void Properties_StructureNormalOrientationInValidValues_ThrowsArgumentOutOfRangeException(double invalidValue) - { - // Setup - var input = new ClosingStructuresInput(); - - // Call - TestDelegate call = () => input.StructureNormalOrientation = (RoundedDouble) invalidValue; - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "De waarde voor de oriƫntatie moet in het bereik tussen [0, 360] graden liggen."); - } - - [Test] - public void Properties_ModelFactorSuperCriticalFlow_ExpectedValues() - { - // Setup - var random = new Random(22); - var input = new ClosingStructuresInput(); - var mean = (RoundedDouble) (0.01 + random.NextDouble()); - var expectedDistribution = new NormalDistribution(2) - { - Mean = mean, - StandardDeviation = input.ModelFactorSuperCriticalFlow.StandardDeviation - }; - var distributionToSet = new NormalDistribution(5) - { - Mean = mean, - StandardDeviation = (RoundedDouble) random.NextDouble() - }; - - // Call - input.ModelFactorSuperCriticalFlow = distributionToSet; - - // Assert - AssertDistributionCorrectlySet(input.ModelFactorSuperCriticalFlow, distributionToSet, expectedDistribution); - } - - [Test] public void Properties_FactorStormDurationOpenStructure_ExpectedValues() { // Setup @@ -366,7 +119,7 @@ // Assert Assert.AreEqual(2, input.FactorStormDurationOpenStructure.NumberOfDecimalPlaces); - AssertEqualValue(factorStormDuration, input.FactorStormDurationOpenStructure); + AssertAreEqual(factorStormDuration, input.FactorStormDurationOpenStructure); } [Test] @@ -579,120 +332,33 @@ } [Test] - public void Properties_AllowedLevelIncreaseStorage_ExpectedValues() + public void Properties_DeviationWaveDirection_ExpectedValues() { // Setup - var random = new Random(22); var input = new ClosingStructuresInput(); - var mean = (RoundedDouble) (0.01 + random.NextDouble()); - var standardDeviation = (RoundedDouble) (0.01 + random.NextDouble()); - var expectedDistribution = new LogNormalDistribution(2) - { - Mean = mean, - StandardDeviation = standardDeviation - }; - var distributionToSet = new LogNormalDistribution(5) - { - Mean = mean, - StandardDeviation = standardDeviation - }; - - // Call - input.AllowedLevelIncreaseStorage = distributionToSet; - - // Assert - AssertDistributionCorrectlySet(input.AllowedLevelIncreaseStorage, distributionToSet, expectedDistribution); - } - - [Test] - public void Properties_StorageStructureArea_ExpectedValues() - { - // Setup var random = new Random(22); - var input = new ClosingStructuresInput(); - var mean = (RoundedDouble) (0.01 + random.NextDouble()); - var variation = (RoundedDouble) (0.01 + random.NextDouble()); - var expectedDistribution = new VariationCoefficientLogNormalDistribution(2) - { - Mean = mean, - CoefficientOfVariation = variation - }; - var distributionToSet = new VariationCoefficientLogNormalDistribution(5) - { - Mean = mean, - CoefficientOfVariation = variation - }; - // Call - input.StorageStructureArea = distributionToSet; + var deviationWaveDirection = new RoundedDouble(5, random.NextDouble()); - // Assert - AssertDistributionCorrectlySet(input.StorageStructureArea, distributionToSet, expectedDistribution); - } - - [Test] - public void Properties_FlowWidthAtBottomProtection_ExpectedValues() - { - // Setup - var random = new Random(22); - var input = new ClosingStructuresInput(); - var mean = (RoundedDouble) (0.01 + random.NextDouble()); - var standardDeviation = (RoundedDouble) (0.01 + random.NextDouble()); - var expectedDistribution = new LogNormalDistribution(2) - { - Mean = mean, - StandardDeviation = standardDeviation - }; - var distributionToSet = new LogNormalDistribution(5) - { - Mean = mean, - StandardDeviation = standardDeviation - }; - // Call - input.FlowWidthAtBottomProtection = distributionToSet; + input.DeviationWaveDirection = deviationWaveDirection; // Assert - AssertDistributionCorrectlySet(input.FlowWidthAtBottomProtection, distributionToSet, expectedDistribution); + Assert.AreEqual(2, input.DeviationWaveDirection.NumberOfDecimalPlaces); + AssertAreEqual(deviationWaveDirection, input.DeviationWaveDirection); } [Test] - public void Properties_CriticalOvertoppingDischarge_ExpectedValues() - { - // Setup - var random = new Random(22); - var input = new ClosingStructuresInput(); - var mean = (RoundedDouble) (0.01 + random.NextDouble()); - var variation = (RoundedDouble) (0.01 + random.NextDouble()); - var expectedDistribution = new VariationCoefficientLogNormalDistribution(2) - { - Mean = mean, - CoefficientOfVariation = variation - }; - var distributionToSet = new VariationCoefficientLogNormalDistribution(5) - { - Mean = mean, - CoefficientOfVariation = variation - }; - - // Call - input.CriticalOvertoppingDischarge = distributionToSet; - - // Assert - AssertDistributionCorrectlySet(input.CriticalOvertoppingDischarge, distributionToSet, expectedDistribution); - } - - [Test] [TestCase(-1.1)] [TestCase(2)] [TestCase(double.NaN)] - public void Properties_FailureProbabilityStructureWithErosion_ThrowArgumentOutOfRangeException(double probability) + public void Properties_ProbabilityOpenStructureBeforeFlooding_ThrowArgumentException(double probability) { // Setup var input = new ClosingStructuresInput(); // Call - TestDelegate call = () => input.FailureProbabilityStructureWithErosion = probability; + TestDelegate call = () => input.ProbabilityOpenStructureBeforeFlooding = probability; // Assert TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "De waarde voor de faalkans moet in het bereik tussen [0, 1] liggen."); @@ -702,120 +368,90 @@ [TestCase(0)] [TestCase(0.5)] [TestCase(1.0)] - public void Properties_FailureProbabilityStructureWithErosion_ExpectedValues(double probability) + public void Properties_ProbabilityOpenStructureBeforeFlooding_ExpectedValues(double probability) { // Setup var input = new ClosingStructuresInput(); // Call - input.FailureProbabilityStructureWithErosion = probability; + input.ProbabilityOpenStructureBeforeFlooding = probability; // Assert - Assert.AreEqual(probability, input.FailureProbabilityStructureWithErosion); + Assert.AreEqual(probability, input.ProbabilityOpenStructureBeforeFlooding); } [Test] - public void Properties_WidthFlowApertures_ExpectedValues() + public void Properties_StructureNull_DoesNotChangeValues() { - // Setup - var random = new Random(22); var input = new ClosingStructuresInput(); - var mean = (RoundedDouble) (0.01 + random.NextDouble()); - var variation = (RoundedDouble) (0.01 + random.NextDouble()); - var expectedDistribution = new VariationCoefficientNormalDistribution(2) - { - Mean = mean, - CoefficientOfVariation = variation - }; - var distributionToSet = new VariationCoefficientNormalDistribution(5) - { - Mean = mean, - CoefficientOfVariation = variation - }; // Call - input.WidthFlowApertures = distributionToSet; + input.Structure = null; // Assert - AssertDistributionCorrectlySet(input.WidthFlowApertures, distributionToSet, expectedDistribution); + AssertClosingStructure(null, input); } [Test] - public void Properties_DeviationWaveDirection_ExpectedValues() + public void Properties_Structure_UpdateValuesAccordingly() { // Setup var input = new ClosingStructuresInput(); - var random = new Random(22); + TestClosingStructure structure = new TestClosingStructure(); - var deviationWaveDirection = new RoundedDouble(5, random.NextDouble()); - // Call - input.DeviationWaveDirection = deviationWaveDirection; + input.Structure = structure; // Assert - Assert.AreEqual(2, input.DeviationWaveDirection.NumberOfDecimalPlaces); - AssertEqualValue(deviationWaveDirection, input.DeviationWaveDirection); + AssertClosingStructure(structure, input); } - [Test] - public void Properties_StormDuration_ExpectedValues() + private static void AssertClosingStructure(ClosingStructure expectedClosingStructure, ClosingStructuresInput input) { - // Setup - var random = new Random(22); - var input = new ClosingStructuresInput(); - var mean = (RoundedDouble) (0.01 + random.NextDouble()); - var expectedDistribution = new VariationCoefficientLogNormalDistribution(2) + if (expectedClosingStructure == null) { - Mean = mean, - CoefficientOfVariation = input.StormDuration.CoefficientOfVariation - }; - var distributionToSet = new VariationCoefficientLogNormalDistribution(5) + Assert.IsNull(input.Structure); + var defaultInput = new ClosingStructuresInput(); + AssertAreEqual(defaultInput.StructureNormalOrientation, input.StructureNormalOrientation); + + DistributionAssert.AreEqual(defaultInput.LevelCrestStructureNotClosing, input.LevelCrestStructureNotClosing); + DistributionAssert.AreEqual(defaultInput.FlowWidthAtBottomProtection, input.FlowWidthAtBottomProtection); + DistributionAssert.AreEqual(defaultInput.CriticalOvertoppingDischarge, input.CriticalOvertoppingDischarge); + DistributionAssert.AreEqual(defaultInput.WidthFlowApertures, input.WidthFlowApertures); + DistributionAssert.AreEqual(defaultInput.StorageStructureArea, input.StorageStructureArea); + DistributionAssert.AreEqual(defaultInput.AllowedLevelIncreaseStorage, input.AllowedLevelIncreaseStorage); + Assert.AreEqual(defaultInput.InflowModelType, input.InflowModelType); + DistributionAssert.AreEqual(defaultInput.AreaFlowApertures, input.AreaFlowApertures); + Assert.AreEqual(defaultInput.FailureProbabilityOpenStructure, input.FailureProbabilityOpenStructure); + Assert.AreEqual(defaultInput.FailureProbabilityReparation, input.FailureProbabilityReparation); + Assert.AreEqual(defaultInput.IdenticalApertures, input.IdenticalApertures); + DistributionAssert.AreEqual(defaultInput.InsideWaterLevel, input.InsideWaterLevel); + Assert.AreEqual(defaultInput.ProbabilityOpenStructureBeforeFlooding, input.ProbabilityOpenStructureBeforeFlooding); + DistributionAssert.AreEqual(defaultInput.ThresholdHeightOpenWeir, input.ThresholdHeightOpenWeir); + } + else { - Mean = mean, - CoefficientOfVariation = (RoundedDouble) random.NextDouble() - }; + AssertAreEqual(expectedClosingStructure.StructureNormalOrientation, input.StructureNormalOrientation); - // Call - input.StormDuration = distributionToSet; - - // Assert - AssertDistributionCorrectlySet(input.StormDuration, distributionToSet, expectedDistribution); + DistributionAssert.AreEqual(expectedClosingStructure.LevelCrestStructureNotClosing, input.LevelCrestStructureNotClosing); + DistributionAssert.AreEqual(expectedClosingStructure.FlowWidthAtBottomProtection, input.FlowWidthAtBottomProtection); + DistributionAssert.AreEqual(expectedClosingStructure.CriticalOvertoppingDischarge, input.CriticalOvertoppingDischarge); + DistributionAssert.AreEqual(expectedClosingStructure.WidthFlowApertures, input.WidthFlowApertures); + DistributionAssert.AreEqual(expectedClosingStructure.StorageStructureArea, input.StorageStructureArea); + DistributionAssert.AreEqual(expectedClosingStructure.AllowedLevelIncreaseStorage, input.AllowedLevelIncreaseStorage); + Assert.AreEqual(expectedClosingStructure.InflowModelType, input.InflowModelType); + DistributionAssert.AreEqual(expectedClosingStructure.AreaFlowApertures, input.AreaFlowApertures); + Assert.AreEqual(expectedClosingStructure.FailureProbabilityOpenStructure, input.FailureProbabilityOpenStructure); + Assert.AreEqual(expectedClosingStructure.FailureProbabilityReparation, input.FailureProbabilityReparation); + Assert.AreEqual(expectedClosingStructure.IdenticalApertures, input.IdenticalApertures); + DistributionAssert.AreEqual(expectedClosingStructure.InsideWaterLevel, input.InsideWaterLevel); + Assert.AreEqual(expectedClosingStructure.ProbabilityOpenStructureBeforeFlooding, input.ProbabilityOpenStructureBeforeFlooding); + DistributionAssert.AreEqual(expectedClosingStructure.ThresholdHeightOpenWeir, input.ThresholdHeightOpenWeir); + } } - - [Test] - [TestCase(-1.1)] - [TestCase(2)] - [TestCase(double.NaN)] - public void Properties_ProbabilityOpenStructureBeforeFlooding_ThrowArgumentException(double probability) + + private static void AssertAreEqual(double expectedValue, RoundedDouble actualValue) { - // 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); - } - - private static void AssertEqualValue(double expectedValue, RoundedDouble actualValue) - { Assert.AreEqual(expectedValue, actualValue, actualValue.GetAccuracy()); } @@ -824,11 +460,5 @@ Assert.AreNotSame(setDistribution, distributionToAssert); DistributionAssert.AreEqual(expectedDistribution, distributionToAssert); } - - private static void AssertDistributionCorrectlySet(IVariationCoefficientDistribution distributionToAssert, IVariationCoefficientDistribution setDistribution, IVariationCoefficientDistribution expectedDistribution) - { - Assert.AreNotSame(setDistribution, distributionToAssert); - DistributionAssert.AreEqual(expectedDistribution, distributionToAssert); - } } } \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/Ringtoets.ClosingStructures.Data.Test.csproj =================================================================== diff -u -rb6a9219d1e628e4430ccf880e8ea390cec04fc04 -r64fea503e6e9cacfb0ff8f22cfdd864b60c95bab --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/Ringtoets.ClosingStructures.Data.Test.csproj (.../Ringtoets.ClosingStructures.Data.Test.csproj) (revision b6a9219d1e628e4430ccf880e8ea390cec04fc04) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/Ringtoets.ClosingStructures.Data.Test.csproj (.../Ringtoets.ClosingStructures.Data.Test.csproj) (revision 64fea503e6e9cacfb0ff8f22cfdd864b60c95bab) @@ -91,6 +91,10 @@ {C6309704-D67B-434C-BC98-9F8910BC1D10} Ringtoets.ClosingStructures.Data + + {F5B43C29-6169-4E9A-859E-09090330B94E} + Ringtoets.ClosingStructures.Data.TestUtil +