Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresInput.cs =================================================================== diff -u -rcf60de33a75f1d729639a4ba7f30e3b319f9ed6d -rca6ec12fb540f0a56a12e363dc1eb3cff066d6cd --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresInput.cs (.../ClosingStructuresInput.cs) (revision cf60de33a75f1d729639a4ba7f30e3b319f9ed6d) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructuresInput.cs (.../ClosingStructuresInput.cs) (revision ca6ec12fb540f0a56a12e363dc1eb3cff066d6cd) @@ -38,11 +38,11 @@ private static readonly Range deviationWaveDirectionValidityRange = new Range(new RoundedDouble(deviationWaveDirectionNumberOfDecimals, -360), new RoundedDouble(deviationWaveDirectionNumberOfDecimals, 360)); - private readonly NormalDistribution thresholdHeightOpenWeir; - private readonly NormalDistribution drainCoefficient; - private readonly LogNormalDistribution areaFlowApertures; - private readonly NormalDistribution levelCrestStructureNotClosing; - private readonly NormalDistribution insideWaterLevel; + private NormalDistribution thresholdHeightOpenWeir; + private NormalDistribution drainCoefficient; + private LogNormalDistribution areaFlowApertures; + private NormalDistribution levelCrestStructureNotClosing; + private NormalDistribution insideWaterLevel; private RoundedDouble factorStormDurationOpenStructure; private double failureProbabilityOpenStructure; private double failureProbabilityReparation; @@ -71,15 +71,6 @@ SetDefaultSchematizationProperties(); } - #region Structure - - /// - /// Gets or sets the type of closing structure inflow model. - /// - public ClosingStructureInflowModelType InflowModelType { get; set; } - - #endregion - public override bool IsStructureInputSynchronized { get @@ -103,6 +94,15 @@ } } + #region Structure + + /// + /// Gets or sets the type of closing structure inflow model. + /// + public ClosingStructureInflowModelType InflowModelType { get; set; } + + #endregion + public override void SynchronizeStructureInput() { if (Structure != null) @@ -129,6 +129,19 @@ } } + public override object Clone() + { + var clone = (ClosingStructuresInput) base.Clone(); + + clone.thresholdHeightOpenWeir = (NormalDistribution) ThresholdHeightOpenWeir.Clone(); + clone.drainCoefficient = (NormalDistribution) DrainCoefficient.Clone(); + clone.areaFlowApertures = (LogNormalDistribution) AreaFlowApertures.Clone(); + clone.levelCrestStructureNotClosing = (NormalDistribution) LevelCrestStructureNotClosing.Clone(); + clone.insideWaterLevel = (NormalDistribution) InsideWaterLevel.Clone(); + + return clone; + } + private void SetDefaultSchematizationProperties() { FailureProbabilityOpenStructure = 0; Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs =================================================================== diff -u -rbf3379d1adf449816e6fe5f941604ce2e6d0b707 -rca6ec12fb540f0a56a12e363dc1eb3cff066d6cd --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs (.../ClosingStructuresInputTest.cs) (revision bf3379d1adf449816e6fe5f941604ce2e6d0b707) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs (.../ClosingStructuresInputTest.cs) (revision ca6ec12fb540f0a56a12e363dc1eb3cff066d6cd) @@ -28,6 +28,8 @@ using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Data.TestUtil; +using CoreCloneAssert = Core.Common.Data.TestUtil.CloneAssert; +using ClosingStructuresCloneAssert = Ringtoets.ClosingStructures.Data.TestUtil.CloneAssert; namespace Ringtoets.ClosingStructures.Data.Test { @@ -286,6 +288,21 @@ AssertClosingStructureInput(differentStructure, input); } + [Test] + public void Clone_Always_ReturnNewInstanceWithCopiedValues() + { + // Setup + var original = new ClosingStructuresInput(); + + ClosingStructuresTestDataGenerator.SetRandomDataToClosingStructuresInput(original); + + // Call + object clone = original.Clone(); + + // Assert + CoreCloneAssert.AreObjectClones(original, clone, ClosingStructuresCloneAssert.AreClones); + } + #region Hydraulic data [Test] Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/Ringtoets.ClosingStructures.Data.Test.csproj =================================================================== diff -u -r7b7bd75dc1c1327386c9be96b5d480565bb8ecd6 -rca6ec12fb540f0a56a12e363dc1eb3cff066d6cd --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/Ringtoets.ClosingStructures.Data.Test.csproj (.../Ringtoets.ClosingStructures.Data.Test.csproj) (revision 7b7bd75dc1c1327386c9be96b5d480565bb8ecd6) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/Ringtoets.ClosingStructures.Data.Test.csproj (.../Ringtoets.ClosingStructures.Data.Test.csproj) (revision ca6ec12fb540f0a56a12e363dc1eb3cff066d6cd) @@ -71,6 +71,10 @@ {3BBFD65B-B277-4E50-AE6D-BD24C3434609} Core.Common.Base + + {0b0d2dff-7e7e-4bb0-a007-61800c85809a} + Core.Common.Data.TestUtil + {D749EE4C-CE50-4C17-BF01-9A953028C126} Core.Common.TestUtil Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/CloneAssert.cs =================================================================== diff -u --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/CloneAssert.cs (revision 0) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/CloneAssert.cs (revision ca6ec12fb540f0a56a12e363dc1eb3cff066d6cd) @@ -0,0 +1,60 @@ +// 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 NUnit.Framework; +using Ringtoets.Common.Data.TestUtil; +using CoreCloneAssert = Core.Common.Data.TestUtil.CloneAssert; +using CommonCloneAssert = Ringtoets.Common.Data.TestUtil.CloneAssert; + +namespace Ringtoets.ClosingStructures.Data.TestUtil +{ + /// + /// Class that defines methods for asserting whether two objects are clones. + /// + public static class CloneAssert + { + /// + /// Method that asserts whether and + /// are clones. + /// + /// The original object. + /// The cloned object. + /// Thrown when and + /// are not clones. + public static void AreClones(ClosingStructuresInput original, ClosingStructuresInput clone) + { + CommonCloneAssert.AreClones(original, clone); + + CoreCloneAssert.AreObjectClones(original.ThresholdHeightOpenWeir, clone.ThresholdHeightOpenWeir, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.DrainCoefficient, clone.DrainCoefficient, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.AreaFlowApertures, clone.AreaFlowApertures, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.LevelCrestStructureNotClosing, clone.LevelCrestStructureNotClosing, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.InsideWaterLevel, clone.InsideWaterLevel, DistributionAssert.AreEqual); + Assert.AreEqual(original.FactorStormDurationOpenStructure, clone.FactorStormDurationOpenStructure); + Assert.AreEqual(original.FailureProbabilityOpenStructure, clone.FailureProbabilityOpenStructure); + Assert.AreEqual(original.FailureProbabilityReparation, clone.FailureProbabilityReparation); + Assert.AreEqual(original.ProbabilityOrFrequencyOpenStructureBeforeFlooding, clone.ProbabilityOrFrequencyOpenStructureBeforeFlooding); + Assert.AreEqual(original.DeviationWaveDirection, clone.DeviationWaveDirection); + Assert.AreEqual(original.InflowModelType, clone.InflowModelType); + Assert.AreEqual(original.IdenticalApertures, clone.IdenticalApertures); + } + } +} \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/ClosingStructuresTestDataGenerator.cs =================================================================== diff -u --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/ClosingStructuresTestDataGenerator.cs (revision 0) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/ClosingStructuresTestDataGenerator.cs (revision ca6ec12fb540f0a56a12e363dc1eb3cff066d6cd) @@ -0,0 +1,84 @@ +// 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 Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Common.Data.TestUtil; + +namespace Ringtoets.ClosingStructures.Data.TestUtil +{ + /// + /// Class responsible for generating test data configurations. + /// + public static class ClosingStructuresTestDataGenerator + { + /// + /// This method sets random data values to all properties of . + /// + /// The input to set the random data values to. + public static void SetRandomDataToClosingStructuresInput(ClosingStructuresInput input) + { + var random = new Random(21); + + input.Structure = new TestClosingStructure(); + + input.ThresholdHeightOpenWeir = new NormalDistribution + { + Mean = random.NextRoundedDouble(), + StandardDeviation = random.NextRoundedDouble() + }; + + input.DrainCoefficient = new NormalDistribution + { + Mean = random.NextRoundedDouble() + }; + + input.AreaFlowApertures = new LogNormalDistribution + { + Mean = random.NextRoundedDouble(), + StandardDeviation = random.NextRoundedDouble() + }; + + input.LevelCrestStructureNotClosing = new NormalDistribution + { + Mean = random.NextRoundedDouble(), + StandardDeviation = random.NextRoundedDouble() + }; + + input.InsideWaterLevel = new NormalDistribution + { + Mean = random.NextRoundedDouble(), + StandardDeviation = random.NextRoundedDouble() + }; + + input.FactorStormDurationOpenStructure = random.NextRoundedDouble(); + input.FailureProbabilityOpenStructure = random.NextDouble(); + input.FailureProbabilityReparation = random.NextDouble(); + input.ProbabilityOrFrequencyOpenStructureBeforeFlooding = random.NextDouble(); + input.DeviationWaveDirection = random.NextRoundedDouble(); + input.InflowModelType = random.NextEnumValue(); + input.IdenticalApertures = random.Next(); + + CommonTestDataGenerator.SetRandomDataToStructuresInput(input); + } + } +} \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/Ringtoets.ClosingStructures.Data.TestUtil.csproj =================================================================== diff -u -r7b7bd75dc1c1327386c9be96b5d480565bb8ecd6 -rca6ec12fb540f0a56a12e363dc1eb3cff066d6cd --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/Ringtoets.ClosingStructures.Data.TestUtil.csproj (.../Ringtoets.ClosingStructures.Data.TestUtil.csproj) (revision 7b7bd75dc1c1327386c9be96b5d480565bb8ecd6) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/Ringtoets.ClosingStructures.Data.TestUtil.csproj (.../Ringtoets.ClosingStructures.Data.TestUtil.csproj) (revision ca6ec12fb540f0a56a12e363dc1eb3cff066d6cd) @@ -49,7 +49,9 @@ Properties\GlobalAssembly.cs + + @@ -66,6 +68,10 @@ {3bbfd65b-b277-4e50-ae6d-bd24c3434609} Core.Common.Base + + {0b0d2dff-7e7e-4bb0-a007-61800c85809a} + Core.Common.Data.TestUtil + {D749EE4C-CE50-4C17-BF01-9A953028C126} Core.Common.TestUtil @@ -74,6 +80,10 @@ {d4200f43-3f72-4f42-af0a-8ced416a38ec} Ringtoets.Common.Data + + {4843D6E5-066F-4795-94F5-1D53932DD03C} + Ringtoets.Common.Data.TestUtil + {c6309704-d67b-434c-bc98-9f8910bc1d10} Ringtoets.ClosingStructures.Data