Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/StabilityPointStructuresInput.cs =================================================================== diff -u -rcf60de33a75f1d729639a4ba7f30e3b319f9ed6d -r543d6e519f8fe4dabaf86586f0520983f15f85a7 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/StabilityPointStructuresInput.cs (.../StabilityPointStructuresInput.cs) (revision cf60de33a75f1d729639a4ba7f30e3b319f9ed6d) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/StabilityPointStructuresInput.cs (.../StabilityPointStructuresInput.cs) (revision 543d6e519f8fe4dabaf86586f0520983f15f85a7) @@ -33,21 +33,21 @@ /// public class StabilityPointStructuresInput : StructuresInputBase { - private readonly NormalDistribution insideWaterLevelFailureConstruction; - private readonly NormalDistribution insideWaterLevel; - private readonly NormalDistribution drainCoefficient; - private readonly NormalDistribution levelCrestStructure; - private readonly NormalDistribution thresholdHeightOpenWeir; - private readonly LogNormalDistribution areaFlowApertures; - private readonly VariationCoefficientLogNormalDistribution constructiveStrengthLinearLoadModel; - private readonly VariationCoefficientLogNormalDistribution constructiveStrengthQuadraticLoadModel; - private readonly VariationCoefficientLogNormalDistribution stabilityLinearLoadModel; - private readonly VariationCoefficientLogNormalDistribution stabilityQuadraticLoadModel; - private readonly VariationCoefficientLogNormalDistribution failureCollisionEnergy; - private readonly VariationCoefficientNormalDistribution shipMass; - private readonly VariationCoefficientNormalDistribution shipVelocity; - private readonly NormalDistribution bankWidth; - private readonly VariationCoefficientNormalDistribution flowVelocityStructureClosable; + private NormalDistribution insideWaterLevelFailureConstruction; + private NormalDistribution insideWaterLevel; + private NormalDistribution drainCoefficient; + private NormalDistribution levelCrestStructure; + private NormalDistribution thresholdHeightOpenWeir; + private LogNormalDistribution areaFlowApertures; + private VariationCoefficientLogNormalDistribution constructiveStrengthLinearLoadModel; + private VariationCoefficientLogNormalDistribution constructiveStrengthQuadraticLoadModel; + private VariationCoefficientLogNormalDistribution stabilityLinearLoadModel; + private VariationCoefficientLogNormalDistribution stabilityQuadraticLoadModel; + private VariationCoefficientLogNormalDistribution failureCollisionEnergy; + private VariationCoefficientNormalDistribution shipMass; + private VariationCoefficientNormalDistribution shipVelocity; + private NormalDistribution bankWidth; + private VariationCoefficientNormalDistribution flowVelocityStructureClosable; private RoundedDouble volumicWeightWater; private RoundedDouble factorStormDurationOpenStructure; private RoundedDouble evaluationLevel; @@ -163,6 +163,29 @@ } } + public override object Clone() + { + var clone = (StabilityPointStructuresInput) base.Clone(); + + clone.insideWaterLevelFailureConstruction = (NormalDistribution) InsideWaterLevelFailureConstruction.Clone(); + clone.insideWaterLevel = (NormalDistribution) InsideWaterLevel.Clone(); + clone.drainCoefficient = (NormalDistribution) DrainCoefficient.Clone(); + clone.levelCrestStructure = (NormalDistribution) LevelCrestStructure.Clone(); + clone.thresholdHeightOpenWeir = (NormalDistribution) ThresholdHeightOpenWeir.Clone(); + clone.areaFlowApertures = (LogNormalDistribution) AreaFlowApertures.Clone(); + clone.constructiveStrengthLinearLoadModel = (VariationCoefficientLogNormalDistribution) ConstructiveStrengthLinearLoadModel.Clone(); + clone.constructiveStrengthQuadraticLoadModel = (VariationCoefficientLogNormalDistribution) ConstructiveStrengthQuadraticLoadModel.Clone(); + clone.stabilityLinearLoadModel = (VariationCoefficientLogNormalDistribution) StabilityLinearLoadModel.Clone(); + clone.stabilityQuadraticLoadModel = (VariationCoefficientLogNormalDistribution) StabilityQuadraticLoadModel.Clone(); + clone.failureCollisionEnergy = (VariationCoefficientLogNormalDistribution) FailureCollisionEnergy.Clone(); + clone.shipMass = (VariationCoefficientNormalDistribution) ShipMass.Clone(); + clone.shipVelocity = (VariationCoefficientNormalDistribution) ShipVelocity.Clone(); + clone.bankWidth = (NormalDistribution) BankWidth.Clone(); + clone.flowVelocityStructureClosable = (VariationCoefficientNormalDistribution) FlowVelocityStructureClosable.Clone(); + + return clone; + } + private void SetDefaultSchematizationProperties() { EvaluationLevel = (RoundedDouble) double.NaN; Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/Ringtoets.StabilityPointStructures.Data.Test.csproj =================================================================== diff -u -r7b7bd75dc1c1327386c9be96b5d480565bb8ecd6 -r543d6e519f8fe4dabaf86586f0520983f15f85a7 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/Ringtoets.StabilityPointStructures.Data.Test.csproj (.../Ringtoets.StabilityPointStructures.Data.Test.csproj) (revision 7b7bd75dc1c1327386c9be96b5d480565bb8ecd6) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/Ringtoets.StabilityPointStructures.Data.Test.csproj (.../Ringtoets.StabilityPointStructures.Data.Test.csproj) (revision 543d6e519f8fe4dabaf86586f0520983f15f85a7) @@ -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/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/StabilityPointStructuresInputTest.cs =================================================================== diff -u -rbf3379d1adf449816e6fe5f941604ce2e6d0b707 -r543d6e519f8fe4dabaf86586f0520983f15f85a7 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/StabilityPointStructuresInputTest.cs (.../StabilityPointStructuresInputTest.cs) (revision bf3379d1adf449816e6fe5f941604ce2e6d0b707) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/StabilityPointStructuresInputTest.cs (.../StabilityPointStructuresInputTest.cs) (revision 543d6e519f8fe4dabaf86586f0520983f15f85a7) @@ -28,6 +28,8 @@ using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Data.TestUtil; using Ringtoets.StabilityPointStructures.Data.TestUtil; +using CoreCloneAssert = Core.Common.Data.TestUtil.CloneAssert; +using StabilityPointStructuresCloneAssert = Ringtoets.StabilityPointStructures.Data.TestUtil.CloneAssert; namespace Ringtoets.StabilityPointStructures.Data.Test { @@ -430,6 +432,21 @@ AssertStabilityPointStructureInput(differentStructure, input); } + [Test] + public void Clone_Always_ReturnNewInstanceWithCopiedValues() + { + // Setup + var original = new StabilityPointStructuresInput(); + + StabilityPointStructuresTestDataGenerator.SetRandomDataToStabilityPointStructuresInput(original); + + // Call + object clone = original.Clone(); + + // Assert + CoreCloneAssert.AreObjectClones(original, clone, StabilityPointStructuresCloneAssert.AreClones); + } + #region Hydraulic data [Test] Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil/CloneAssert.cs =================================================================== diff -u --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil/CloneAssert.cs (revision 0) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil/CloneAssert.cs (revision 543d6e519f8fe4dabaf86586f0520983f15f85a7) @@ -0,0 +1,72 @@ +// 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.StabilityPointStructures.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(StabilityPointStructuresInput original, StabilityPointStructuresInput clone) + { + CommonCloneAssert.AreClones(original, clone); + + CoreCloneAssert.AreObjectClones(original.InsideWaterLevelFailureConstruction, clone.InsideWaterLevelFailureConstruction, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.InsideWaterLevel, clone.InsideWaterLevel, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.DrainCoefficient, clone.DrainCoefficient, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.LevelCrestStructure, clone.LevelCrestStructure, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.ThresholdHeightOpenWeir, clone.ThresholdHeightOpenWeir, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.AreaFlowApertures, clone.AreaFlowApertures, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.ConstructiveStrengthLinearLoadModel, clone.ConstructiveStrengthLinearLoadModel, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.ConstructiveStrengthQuadraticLoadModel, clone.ConstructiveStrengthQuadraticLoadModel, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.StabilityLinearLoadModel, clone.StabilityLinearLoadModel, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.StabilityQuadraticLoadModel, clone.StabilityQuadraticLoadModel, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.FailureCollisionEnergy, clone.FailureCollisionEnergy, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.ShipMass, clone.ShipMass, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.ShipVelocity, clone.ShipVelocity, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.BankWidth, clone.BankWidth, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.FlowVelocityStructureClosable, clone.FlowVelocityStructureClosable, DistributionAssert.AreEqual); + Assert.AreEqual(original.VolumicWeightWater, clone.VolumicWeightWater); + Assert.AreEqual(original.FactorStormDurationOpenStructure, clone.FactorStormDurationOpenStructure); + Assert.AreEqual(original.EvaluationLevel, clone.EvaluationLevel); + Assert.AreEqual(original.VerticalDistance, clone.VerticalDistance); + Assert.AreEqual(original.FailureProbabilityRepairClosure, clone.FailureProbabilityRepairClosure); + Assert.AreEqual(original.ProbabilityCollisionSecondaryStructure, clone.ProbabilityCollisionSecondaryStructure); + Assert.AreEqual(original.InflowModelType, clone.InflowModelType); + Assert.AreEqual(original.LoadSchematizationType, clone.LoadSchematizationType); + Assert.AreEqual(original.LevellingCount, clone.LevellingCount); + } + } +} \ No newline at end of file Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil/Ringtoets.StabilityPointStructures.Data.TestUtil.csproj =================================================================== diff -u -r7b7bd75dc1c1327386c9be96b5d480565bb8ecd6 -r543d6e519f8fe4dabaf86586f0520983f15f85a7 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil/Ringtoets.StabilityPointStructures.Data.TestUtil.csproj (.../Ringtoets.StabilityPointStructures.Data.TestUtil.csproj) (revision 7b7bd75dc1c1327386c9be96b5d480565bb8ecd6) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil/Ringtoets.StabilityPointStructures.Data.TestUtil.csproj (.../Ringtoets.StabilityPointStructures.Data.TestUtil.csproj) (revision 543d6e519f8fe4dabaf86586f0520983f15f85a7) @@ -49,8 +49,10 @@ 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 + {3d4b9740-8348-4434-8d77-b611fc6ee57f} Ringtoets.StabilityPointStructures.Data Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil/StabilityPointStructuresTestDataGenerator.cs =================================================================== diff -u --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil/StabilityPointStructuresTestDataGenerator.cs (revision 0) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil/StabilityPointStructuresTestDataGenerator.cs (revision 543d6e519f8fe4dabaf86586f0520983f15f85a7) @@ -0,0 +1,145 @@ +// 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.StabilityPointStructures.Data.TestUtil +{ + /// + /// Class responsible for generating test data configurations. + /// + public static class StabilityPointStructuresTestDataGenerator + { + /// + /// This method sets random data values to all properties of . + /// + /// The input to set the random data values to. + public static void SetRandomDataToStabilityPointStructuresInput(StabilityPointStructuresInput input) + { + var random = new Random(21); + + input.Structure = new TestStabilityPointStructure(); + + input.InsideWaterLevelFailureConstruction = new NormalDistribution + { + Mean = random.NextRoundedDouble(), + StandardDeviation = random.NextRoundedDouble() + }; + + input.InsideWaterLevel = new NormalDistribution + { + Mean = random.NextRoundedDouble(), + StandardDeviation = random.NextRoundedDouble() + }; + + input.DrainCoefficient = new NormalDistribution + { + Mean = random.NextRoundedDouble() + }; + + input.LevelCrestStructure = new NormalDistribution + { + Mean = random.NextRoundedDouble(), + StandardDeviation = random.NextRoundedDouble() + }; + + input.ThresholdHeightOpenWeir = new NormalDistribution + { + Mean = random.NextRoundedDouble(), + StandardDeviation = random.NextRoundedDouble() + }; + + input.AreaFlowApertures = new LogNormalDistribution + { + Mean = random.NextRoundedDouble(), + StandardDeviation = random.NextRoundedDouble() + }; + + input.ConstructiveStrengthLinearLoadModel = new VariationCoefficientLogNormalDistribution + { + Mean = random.NextRoundedDouble(), + CoefficientOfVariation = random.NextRoundedDouble() + }; + + input.ConstructiveStrengthQuadraticLoadModel = new VariationCoefficientLogNormalDistribution + { + Mean = random.NextRoundedDouble(), + CoefficientOfVariation = random.NextRoundedDouble() + }; + + input.StabilityLinearLoadModel = new VariationCoefficientLogNormalDistribution + { + Mean = random.NextRoundedDouble(), + CoefficientOfVariation = random.NextRoundedDouble() + }; + + input.StabilityQuadraticLoadModel = new VariationCoefficientLogNormalDistribution + { + Mean = random.NextRoundedDouble(), + CoefficientOfVariation = random.NextRoundedDouble() + }; + + input.FailureCollisionEnergy = new VariationCoefficientLogNormalDistribution + { + Mean = random.NextRoundedDouble(), + CoefficientOfVariation = random.NextRoundedDouble() + }; + + input.ShipMass = new VariationCoefficientNormalDistribution + { + Mean = random.NextRoundedDouble(), + CoefficientOfVariation = random.NextRoundedDouble() + }; + + input.ShipVelocity = new VariationCoefficientNormalDistribution + { + Mean = random.NextRoundedDouble(), + CoefficientOfVariation = random.NextRoundedDouble() + }; + + input.BankWidth = new NormalDistribution + { + Mean = random.NextRoundedDouble(), + StandardDeviation = random.NextRoundedDouble() + }; + + input.FlowVelocityStructureClosable = new VariationCoefficientNormalDistribution + { + Mean = random.NextRoundedDouble() + }; + + input.VolumicWeightWater = random.NextRoundedDouble(); + input.FactorStormDurationOpenStructure = random.NextRoundedDouble(); + input.EvaluationLevel = random.NextRoundedDouble(); + input.VerticalDistance = random.NextRoundedDouble(); + input.FailureProbabilityRepairClosure = random.NextDouble(); + input.ProbabilityCollisionSecondaryStructure = random.NextDouble(); + input.InflowModelType = random.NextEnumValue(); + input.LoadSchematizationType = random.NextEnumValue(); + input.LevellingCount = random.Next(); + + CommonTestDataGenerator.SetRandomDataToStructuresInput(input); + } + } +} \ No newline at end of file