Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructureTest.cs =================================================================== diff -u -rf88343c0590cb04c7135ce141872940e59325927 -r12cec002453a1828efc68633fbd25219632c6c47 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructureTest.cs (.../ClosingStructureTest.cs) (revision f88343c0590cb04c7135ce141872940e59325927) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructureTest.cs (.../ClosingStructureTest.cs) (revision 12cec002453a1828efc68633fbd25219632c6c47) @@ -19,6 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Collections.Generic; +using System.Linq; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using NUnit.Framework; @@ -31,6 +33,169 @@ [TestFixture] public class ClosingStructureTest { + private static IEnumerable StructureCombinations + { + get + { + return GetInequalStructures.Concat(GetEqualStructures); + } + } + + private static IEnumerable GetEqualStructures + { + get + { + ClosingStructure structure = CreateFullyDefinedStructure(); + yield return new TestCaseData(structure, structure, true) + .SetName("SameStructure"); + yield return new TestCaseData(structure, CreateFullyDefinedStructure(), true) + .SetName("EqualStructure"); + } + } + + private static IEnumerable GetInequalStructures + { + get + { + ClosingStructure structure = CreateFullyDefinedStructure(); + + ClosingStructure.ConstructionProperties differentId = CreateFullyConfiguredConstructionProperties(); + differentId.Id = "differentId"; + yield return new TestCaseData(structure, new ClosingStructure(differentId), false) + .SetName(nameof(differentId)); + + ClosingStructure.ConstructionProperties differentName = CreateFullyConfiguredConstructionProperties(); + differentName.Name = "differentName"; + yield return new TestCaseData(structure, new ClosingStructure(differentName), false) + .SetName(nameof(differentName)); + + ClosingStructure.ConstructionProperties differentLocation = CreateFullyConfiguredConstructionProperties(); + differentLocation.Location = new Point2D(9, 9); + yield return new TestCaseData(structure, new ClosingStructure(differentLocation), false) + .SetName(nameof(differentLocation)); + + ClosingStructure.ConstructionProperties differentOrientation = CreateFullyConfiguredConstructionProperties(); + differentOrientation.StructureNormalOrientation = (RoundedDouble) 90; + yield return new TestCaseData(structure, new ClosingStructure(differentOrientation), false) + .SetName(nameof(differentOrientation)); + + ClosingStructure.ConstructionProperties differentAllowedLevelIncreaseStorageMean = CreateFullyConfiguredConstructionProperties(); + differentAllowedLevelIncreaseStorageMean.AreaFlowApertures.Mean = (RoundedDouble) 10.1; + yield return new TestCaseData(structure, new ClosingStructure(differentAllowedLevelIncreaseStorageMean), false) + .SetName(nameof(differentAllowedLevelIncreaseStorageMean)); + + ClosingStructure.ConstructionProperties differentAllowedLevelIncreaseStorageStandardDeviation = CreateFullyConfiguredConstructionProperties(); + differentAllowedLevelIncreaseStorageStandardDeviation.AllowedLevelIncreaseStorage.StandardDeviation = (RoundedDouble) 0.1; + yield return new TestCaseData(structure, new ClosingStructure(differentAllowedLevelIncreaseStorageStandardDeviation), false) + .SetName(nameof(differentAllowedLevelIncreaseStorageStandardDeviation)); + + ClosingStructure.ConstructionProperties differentAreaFlowAperturesMean = CreateFullyConfiguredConstructionProperties(); + differentAreaFlowAperturesMean.AreaFlowApertures.Mean = (RoundedDouble) 10.1; + yield return new TestCaseData(structure, new ClosingStructure(differentAreaFlowAperturesMean), false) + .SetName(nameof(differentAreaFlowAperturesMean)); + + ClosingStructure.ConstructionProperties differentAreaFlowAperturesStandardDeviation = CreateFullyConfiguredConstructionProperties(); + differentAreaFlowAperturesStandardDeviation.AreaFlowApertures.StandardDeviation = (RoundedDouble) 0.1; + yield return new TestCaseData(structure, new ClosingStructure(differentAreaFlowAperturesStandardDeviation), false) + .SetName(nameof(differentAreaFlowAperturesStandardDeviation)); + + ClosingStructure.ConstructionProperties differentCriticalOvertoppingDischargeMean = CreateFullyConfiguredConstructionProperties(); + differentCriticalOvertoppingDischargeMean.CriticalOvertoppingDischarge.Mean = (RoundedDouble) 10.1; + yield return new TestCaseData(structure, new ClosingStructure(differentCriticalOvertoppingDischargeMean), false) + .SetName(nameof(differentCriticalOvertoppingDischargeMean)); + + ClosingStructure.ConstructionProperties differentCriticalOvertoppingDischargeCoefficientOfVariation = CreateFullyConfiguredConstructionProperties(); + differentCriticalOvertoppingDischargeCoefficientOfVariation.CriticalOvertoppingDischarge.CoefficientOfVariation = (RoundedDouble) 0.1; + yield return new TestCaseData(structure, new ClosingStructure(differentCriticalOvertoppingDischargeCoefficientOfVariation), false) + .SetName(nameof(differentCriticalOvertoppingDischargeCoefficientOfVariation)); + + ClosingStructure.ConstructionProperties differentFailureProbabilityOpenStructure = CreateFullyConfiguredConstructionProperties(); + differentFailureProbabilityOpenStructure.FailureProbabilityOpenStructure = 987; + yield return new TestCaseData(structure, new ClosingStructure(differentFailureProbabilityOpenStructure), false) + .SetName(nameof(differentFailureProbabilityOpenStructure)); + + ClosingStructure.ConstructionProperties differentFailureProbabilityReparation = CreateFullyConfiguredConstructionProperties(); + differentFailureProbabilityReparation.FailureProbabilityReparation = 987; + yield return new TestCaseData(structure, new ClosingStructure(differentFailureProbabilityReparation), false) + .SetName(nameof(differentFailureProbabilityReparation)); + + ClosingStructure.ConstructionProperties differentFlowWidthAtBottomProtectionMean = CreateFullyConfiguredConstructionProperties(); + differentFlowWidthAtBottomProtectionMean.FlowWidthAtBottomProtection.Mean = (RoundedDouble) 10.1; + yield return new TestCaseData(structure, new ClosingStructure(differentFlowWidthAtBottomProtectionMean), false) + .SetName(nameof(differentFlowWidthAtBottomProtectionMean)); + + ClosingStructure.ConstructionProperties differentFlowWidthAtBottomProtectionStandardDeviation = CreateFullyConfiguredConstructionProperties(); + differentFlowWidthAtBottomProtectionStandardDeviation.FlowWidthAtBottomProtection.StandardDeviation = (RoundedDouble) 0.1; + yield return new TestCaseData(structure, new ClosingStructure(differentFlowWidthAtBottomProtectionStandardDeviation), false) + .SetName(nameof(differentFlowWidthAtBottomProtectionStandardDeviation)); + + ClosingStructure.ConstructionProperties differentIdenticalApertures = CreateFullyConfiguredConstructionProperties(); + differentIdenticalApertures.IdenticalApertures = 987; + yield return new TestCaseData(structure, new ClosingStructure(differentIdenticalApertures), false) + .SetName(nameof(differentIdenticalApertures)); + + ClosingStructure.ConstructionProperties differentInflowModelType = CreateFullyConfiguredConstructionProperties(); + differentInflowModelType.InflowModelType = ClosingStructureInflowModelType.FloodedCulvert; + yield return new TestCaseData(structure, new ClosingStructure(differentInflowModelType), false) + .SetName(nameof(differentInflowModelType)); + + ClosingStructure.ConstructionProperties differentInsideWaterLevelMean = CreateFullyConfiguredConstructionProperties(); + differentInsideWaterLevelMean.InsideWaterLevel.Mean = (RoundedDouble) 10.1; + yield return new TestCaseData(structure, new ClosingStructure(differentInsideWaterLevelMean), false) + .SetName(nameof(differentInsideWaterLevelMean)); + + ClosingStructure.ConstructionProperties differentInsideWaterLevelStandardDeviation = CreateFullyConfiguredConstructionProperties(); + differentInsideWaterLevelStandardDeviation.InsideWaterLevel.StandardDeviation = (RoundedDouble) 0.1; + yield return new TestCaseData(structure, new ClosingStructure(differentInsideWaterLevelStandardDeviation), false) + .SetName(nameof(differentInsideWaterLevelStandardDeviation)); + + ClosingStructure.ConstructionProperties differentLevelCrestStructureNotClosingMean = CreateFullyConfiguredConstructionProperties(); + differentLevelCrestStructureNotClosingMean.LevelCrestStructureNotClosing.Mean = (RoundedDouble) 10.1; + yield return new TestCaseData(structure, new ClosingStructure(differentLevelCrestStructureNotClosingMean), false) + .SetName(nameof(differentLevelCrestStructureNotClosingMean)); + + ClosingStructure.ConstructionProperties differentLevelCrestStructureNotClosingStandardDeviation = CreateFullyConfiguredConstructionProperties(); + differentLevelCrestStructureNotClosingStandardDeviation.LevelCrestStructureNotClosing.StandardDeviation = (RoundedDouble) 0.1; + yield return new TestCaseData(structure, new ClosingStructure(differentLevelCrestStructureNotClosingStandardDeviation), false) + .SetName(nameof(differentLevelCrestStructureNotClosingStandardDeviation)); + + ClosingStructure.ConstructionProperties differentProbabilityOrFrequencyOpenStructureBeforeFlooding = CreateFullyConfiguredConstructionProperties(); + differentProbabilityOrFrequencyOpenStructureBeforeFlooding.ProbabilityOrFrequencyOpenStructureBeforeFlooding = 987; + yield return new TestCaseData(structure, new ClosingStructure(differentProbabilityOrFrequencyOpenStructureBeforeFlooding), false) + .SetName(nameof(differentProbabilityOrFrequencyOpenStructureBeforeFlooding)); + + ClosingStructure.ConstructionProperties differentStorageStructureAreaMean = CreateFullyConfiguredConstructionProperties(); + differentStorageStructureAreaMean.StorageStructureArea.Mean = (RoundedDouble) 10.1; + yield return new TestCaseData(structure, new ClosingStructure(differentStorageStructureAreaMean), false) + .SetName(nameof(differentStorageStructureAreaMean)); + + ClosingStructure.ConstructionProperties differentStorageStructureAreaCoefficientOfVariation = CreateFullyConfiguredConstructionProperties(); + differentStorageStructureAreaCoefficientOfVariation.StorageStructureArea.CoefficientOfVariation = (RoundedDouble) 0.1; + yield return new TestCaseData(structure, new ClosingStructure(differentStorageStructureAreaCoefficientOfVariation), false) + .SetName(nameof(differentStorageStructureAreaCoefficientOfVariation)); + + ClosingStructure.ConstructionProperties differentThresholdHeightOpenWeirMean = CreateFullyConfiguredConstructionProperties(); + differentThresholdHeightOpenWeirMean.ThresholdHeightOpenWeir.Mean = (RoundedDouble) 10.1; + yield return new TestCaseData(structure, new ClosingStructure(differentThresholdHeightOpenWeirMean), false) + .SetName(nameof(differentThresholdHeightOpenWeirMean)); + + ClosingStructure.ConstructionProperties differentThresholdHeightOpenWeirStandardDeviation = CreateFullyConfiguredConstructionProperties(); + differentThresholdHeightOpenWeirStandardDeviation.ThresholdHeightOpenWeir.StandardDeviation = (RoundedDouble) 0.1; + yield return new TestCaseData(structure, new ClosingStructure(differentThresholdHeightOpenWeirStandardDeviation), false) + .SetName(nameof(differentThresholdHeightOpenWeirStandardDeviation)); + + ClosingStructure.ConstructionProperties differentWidthFlowAperturesMean = CreateFullyConfiguredConstructionProperties(); + differentWidthFlowAperturesMean.WidthFlowApertures.Mean = (RoundedDouble) 10.1; + yield return new TestCaseData(structure, new ClosingStructure(differentWidthFlowAperturesMean), false) + .SetName(nameof(differentWidthFlowAperturesMean)); + + ClosingStructure.ConstructionProperties differentWidthFlowAperturesStandardDeviation = CreateFullyConfiguredConstructionProperties(); + differentWidthFlowAperturesStandardDeviation.WidthFlowApertures.StandardDeviation = (RoundedDouble) 0.1; + yield return new TestCaseData(structure, new ClosingStructure(differentWidthFlowAperturesStandardDeviation), false) + .SetName(nameof(differentWidthFlowAperturesStandardDeviation)); + } + } + [Test] public void Constructor_ValidData_ExpectedValues() { @@ -254,5 +419,73 @@ Assert.AreEqual(ClosingStructureInflowModelType.VerticalWall, structure.InflowModelType); } + + private static ClosingStructure CreateFullyDefinedStructure() + { + return new ClosingStructure(CreateFullyConfiguredConstructionProperties()); + } + + private static ClosingStructure.ConstructionProperties CreateFullyConfiguredConstructionProperties() + { + const string id = "structure id"; + const string name = "Structure name"; + return new ClosingStructure.ConstructionProperties + { + Id = id, + Name = name, + Location = new Point2D(1, 1), + StructureNormalOrientation = (RoundedDouble) 25, + AllowedLevelIncreaseStorage = + { + Mean = (RoundedDouble) 1, + StandardDeviation = (RoundedDouble) 0.51 + }, + AreaFlowApertures = + { + Mean = (RoundedDouble) 2, + StandardDeviation = (RoundedDouble) 0.52 + }, + CriticalOvertoppingDischarge = + { + Mean = (RoundedDouble) 3, + CoefficientOfVariation = (RoundedDouble) 0.53 + }, + FlowWidthAtBottomProtection = + { + Mean = (RoundedDouble) 4, + StandardDeviation = (RoundedDouble) 0.54 + }, + InsideWaterLevel = + { + Mean = (RoundedDouble) 5, + StandardDeviation = (RoundedDouble) 0.55 + }, + LevelCrestStructureNotClosing = + { + Mean = (RoundedDouble) 6, + StandardDeviation = (RoundedDouble) 0.56 + }, + StorageStructureArea = + { + Mean = (RoundedDouble) 7, + CoefficientOfVariation = (RoundedDouble) 0.57 + }, + ThresholdHeightOpenWeir = + { + Mean = (RoundedDouble) 8, + StandardDeviation = (RoundedDouble) 0.58 + }, + WidthFlowApertures = + { + Mean = (RoundedDouble) 9, + StandardDeviation = (RoundedDouble) 0.59 + }, + FailureProbabilityOpenStructure = 9, + FailureProbabilityReparation = 10, + InflowModelType = ClosingStructureInflowModelType.FloodedCulvert, + IdenticalApertures = 11, + ProbabilityOrFrequencyOpenStructureBeforeFlooding = 12 + }; + } } } \ No newline at end of file