// 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 Core.Common.Base.Data; using Core.Common.Base.Geometry; using NUnit.Framework; using Ringtoets.Common.Data; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Data.TestUtil; namespace Ringtoets.ClosingStructures.Data.Test { [TestFixture] public class ClosingStructureTest { [Test] public void Constructor_ValidData_ExpectedValues() { // Setup var location = new Point2D(1.22, 2.333); // Call var structure = new ClosingStructure( new ClosingStructure.ConstructionProperties { Name = "aName", Id = "anId", Location = location, StorageStructureArea = { Mean = (RoundedDouble) 123.456, CoefficientOfVariation = (RoundedDouble) 0.123 }, AllowedLevelIncreaseStorage = { Mean = (RoundedDouble) 234.567, StandardDeviation = (RoundedDouble) 0.234 }, StructureNormalOrientation = 345.678, WidthFlowApertures = { Mean = (RoundedDouble) 456.789, CoefficientOfVariation = (RoundedDouble) 0.456 }, LevelCrestStructureNotClosing = { Mean = (RoundedDouble) 567.890, StandardDeviation = (RoundedDouble) 0.567 }, InsideWaterLevel = { Mean = (RoundedDouble) 678.901, StandardDeviation = (RoundedDouble) 0.678 }, ThresholdHeightOpenWeir = { Mean = (RoundedDouble) 789.012, StandardDeviation = (RoundedDouble) 0.789 }, AreaFlowApertures = { Mean = (RoundedDouble) 890.123, StandardDeviation = (RoundedDouble) 0.890 }, CriticalOvertoppingDischarge = { Mean = (RoundedDouble) 901.234, CoefficientOfVariation = (RoundedDouble) 0.901 }, FlowWidthAtBottomProtection = { Mean = (RoundedDouble) 111.222, StandardDeviation = (RoundedDouble) 0.111 }, ProbabilityOpenStructureBeforeFlooding = 321.987, FailureProbabilityOpenStructure = 654.321, IdenticalApertures = 42, FailureProbabilityReparation = 987.654, InflowModelType = ClosingStructureInflowModelType.LowSill }); // Assert Assert.IsInstanceOf(structure); Assert.AreEqual("aName", structure.Name); Assert.AreEqual("anId", structure.Id); Assert.AreEqual(location.X, structure.Location.X); Assert.AreEqual(location.Y, structure.Location.Y); Assert.AreEqual(2, structure.StructureNormalOrientation.NumberOfDecimalPlaces); Assert.AreEqual(345.68, structure.StructureNormalOrientation, structure.StructureNormalOrientation.GetAccuracy()); VariationCoefficientLogNormalDistribution storageStructureArea = structure.StorageStructureArea; Assert.AreEqual(2, storageStructureArea.Mean.NumberOfDecimalPlaces); Assert.AreEqual(123.46, storageStructureArea.Mean, storageStructureArea.Mean.GetAccuracy()); Assert.AreEqual(2, storageStructureArea.CoefficientOfVariation.NumberOfDecimalPlaces); Assert.AreEqual(0.12, storageStructureArea.CoefficientOfVariation, storageStructureArea.CoefficientOfVariation.GetAccuracy()); LogNormalDistribution allowedLevelIncreaseStorage = structure.AllowedLevelIncreaseStorage; Assert.AreEqual(2, allowedLevelIncreaseStorage.Mean.NumberOfDecimalPlaces); Assert.AreEqual(234.57, allowedLevelIncreaseStorage.Mean, allowedLevelIncreaseStorage.Mean.GetAccuracy()); Assert.AreEqual(2, allowedLevelIncreaseStorage.StandardDeviation.NumberOfDecimalPlaces); Assert.AreEqual(0.23, allowedLevelIncreaseStorage.StandardDeviation, allowedLevelIncreaseStorage.StandardDeviation.GetAccuracy()); VariationCoefficientNormalDistribution widthFlowApertures = structure.WidthFlowApertures; Assert.AreEqual(2, widthFlowApertures.Mean.NumberOfDecimalPlaces); Assert.AreEqual(456.79, widthFlowApertures.Mean, widthFlowApertures.Mean.GetAccuracy()); Assert.AreEqual(2, widthFlowApertures.CoefficientOfVariation.NumberOfDecimalPlaces); Assert.AreEqual(0.46, widthFlowApertures.CoefficientOfVariation, widthFlowApertures.CoefficientOfVariation.GetAccuracy()); NormalDistribution levelCrestStructureNotClosing = structure.LevelCrestStructureNotClosing; Assert.AreEqual(2, levelCrestStructureNotClosing.Mean.NumberOfDecimalPlaces); Assert.AreEqual(567.89, levelCrestStructureNotClosing.Mean, levelCrestStructureNotClosing.Mean.GetAccuracy()); Assert.AreEqual(2, levelCrestStructureNotClosing.StandardDeviation.NumberOfDecimalPlaces); Assert.AreEqual(0.57, levelCrestStructureNotClosing.StandardDeviation, levelCrestStructureNotClosing.StandardDeviation.GetAccuracy()); NormalDistribution insideWaterLevel = structure.InsideWaterLevel; Assert.AreEqual(2, insideWaterLevel.Mean.NumberOfDecimalPlaces); Assert.AreEqual(678.90, insideWaterLevel.Mean, insideWaterLevel.Mean.GetAccuracy()); Assert.AreEqual(2, insideWaterLevel.StandardDeviation.NumberOfDecimalPlaces); Assert.AreEqual(0.68, insideWaterLevel.StandardDeviation, insideWaterLevel.StandardDeviation.GetAccuracy()); NormalDistribution thresholdHeightOpenWeir = structure.ThresholdHeightOpenWeir; Assert.AreEqual(2, thresholdHeightOpenWeir.Mean.NumberOfDecimalPlaces); Assert.AreEqual(789.01, thresholdHeightOpenWeir.Mean, thresholdHeightOpenWeir.Mean.GetAccuracy()); Assert.AreEqual(2, thresholdHeightOpenWeir.StandardDeviation.NumberOfDecimalPlaces); Assert.AreEqual(0.79, thresholdHeightOpenWeir.StandardDeviation, thresholdHeightOpenWeir.StandardDeviation.GetAccuracy()); LogNormalDistribution areaFlowApertures = structure.AreaFlowApertures; Assert.AreEqual(2, areaFlowApertures.Mean.NumberOfDecimalPlaces); Assert.AreEqual(890.12, areaFlowApertures.Mean, areaFlowApertures.Mean.GetAccuracy()); Assert.AreEqual(2, areaFlowApertures.StandardDeviation.NumberOfDecimalPlaces); Assert.AreEqual(0.89, areaFlowApertures.StandardDeviation, areaFlowApertures.StandardDeviation.GetAccuracy()); VariationCoefficientLogNormalDistribution criticalOvertoppingDischarge = structure.CriticalOvertoppingDischarge; Assert.AreEqual(2, criticalOvertoppingDischarge.Mean.NumberOfDecimalPlaces); Assert.AreEqual(901.23, criticalOvertoppingDischarge.Mean, criticalOvertoppingDischarge.Mean.GetAccuracy()); Assert.AreEqual(2, criticalOvertoppingDischarge.CoefficientOfVariation.NumberOfDecimalPlaces); Assert.AreEqual(0.90, criticalOvertoppingDischarge.CoefficientOfVariation, criticalOvertoppingDischarge.CoefficientOfVariation.GetAccuracy()); LogNormalDistribution flowWidthAtBottomProtection = structure.FlowWidthAtBottomProtection; Assert.AreEqual(2, flowWidthAtBottomProtection.Mean.NumberOfDecimalPlaces); Assert.AreEqual(111.22, flowWidthAtBottomProtection.Mean, flowWidthAtBottomProtection.Mean.GetAccuracy()); Assert.AreEqual(2, flowWidthAtBottomProtection.StandardDeviation.NumberOfDecimalPlaces); Assert.AreEqual(0.11, flowWidthAtBottomProtection.StandardDeviation, flowWidthAtBottomProtection.StandardDeviation.GetAccuracy()); Assert.AreEqual(2, structure.ProbabilityOpenStructureBeforeFlooding.NumberOfDecimalPlaces); Assert.AreEqual(321.99, structure.ProbabilityOpenStructureBeforeFlooding, structure.ProbabilityOpenStructureBeforeFlooding.GetAccuracy()); Assert.AreEqual(2, structure.FailureProbabilityOpenStructure.NumberOfDecimalPlaces); Assert.AreEqual(654.32, structure.FailureProbabilityOpenStructure, structure.FailureProbabilityOpenStructure.GetAccuracy()); Assert.AreEqual(42, structure.IdenticalApertures); Assert.AreEqual(2, structure.FailureProbabilityReparation.NumberOfDecimalPlaces); Assert.AreEqual(987.65, structure.FailureProbabilityReparation, structure.FailureProbabilityReparation.GetAccuracy()); Assert.AreEqual(ClosingStructureInflowModelType.LowSill, structure.InflowModelType); } } }