Index: Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresInputBase.cs
===================================================================
diff -u -r6ebe864bf0138360fbba9a2772e9faf763287e8a -r898d42ca6354285169751f4de231f96f40b1f6f9
--- Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresInputBase.cs (.../StructuresInputBase.cs) (revision 6ebe864bf0138360fbba9a2772e9faf763287e8a)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresInputBase.cs (.../StructuresInputBase.cs) (revision 898d42ca6354285169751f4de231f96f40b1f6f9)
@@ -35,6 +35,7 @@
///
/// Base class that holds generic structures calculation input parameters.
///
+ /// The type of structure contained by the input.
public abstract class StructuresInputBase : Observable, IStructuresCalculationInput, IUseBreakWater, IUseForeshore, IHasForeshoreProfile
where T : StructureBase
{
@@ -148,7 +149,7 @@
/// When no structure is present, the input parameters are set to default values.
public abstract void SynchronizeStructureInput();
- public object Clone()
+ public virtual object Clone()
{
var clone = (StructuresInputBase) MemberwiseClone();
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresInputBaseTest.cs
===================================================================
diff -u -rfaa685cb8293f1cc01d24fedb75fa260ecc58817 -r898d42ca6354285169751f4de231f96f40b1f6f9
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresInputBaseTest.cs (.../StructuresInputBaseTest.cs) (revision faa685cb8293f1cc01d24fedb75fa260ecc58817)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresInputBaseTest.cs (.../StructuresInputBaseTest.cs) (revision 898d42ca6354285169751f4de231f96f40b1f6f9)
@@ -285,57 +285,13 @@
public void Clone_Always_ReturnNewInstanceWithCopiedValues()
{
// Setup
- var random = new Random(21);
var original = new SimpleStructuresInput
{
- ModelFactorSuperCriticalFlow = new NormalDistribution
- {
- Mean = random.NextRoundedDouble()
- },
- AllowedLevelIncreaseStorage = new LogNormalDistribution
- {
- Mean = random.NextRoundedDouble(),
- StandardDeviation = random.NextRoundedDouble()
- },
- StorageStructureArea = new VariationCoefficientLogNormalDistribution
- {
- Mean = random.NextRoundedDouble(),
- CoefficientOfVariation = random.NextRoundedDouble()
- },
- FlowWidthAtBottomProtection = new LogNormalDistribution
- {
- Mean = random.NextRoundedDouble(),
- StandardDeviation = random.NextRoundedDouble()
- },
- CriticalOvertoppingDischarge = new VariationCoefficientLogNormalDistribution
- {
- Mean = random.NextRoundedDouble(),
- CoefficientOfVariation = random.NextRoundedDouble()
- },
- WidthFlowApertures = new NormalDistribution
- {
- Mean = random.NextRoundedDouble(),
- StandardDeviation = random.NextRoundedDouble()
- },
- StormDuration = new VariationCoefficientLogNormalDistribution
- {
- Mean = random.NextRoundedDouble()
- },
- Structure = new TestStructure(),
- StructureNormalOrientation = random.NextRoundedDouble(),
- FailureProbabilityStructureWithErosion = random.NextDouble(),
- ForeshoreProfile = new TestForeshoreProfile(),
- ShouldIllustrationPointsBeCalculated = random.NextBoolean(),
- HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(),
- UseBreakWater = random.NextBoolean(),
- BreakWater =
- {
- Type = random.NextEnumValue(),
- Height = random.NextRoundedDouble()
- },
- UseForeshore = random.NextBoolean()
+ Structure = new TestStructure()
};
+ CloneTestHelper.SetRandomDataToStructuresInput(original);
+
// Call
object clone = original.Clone();
Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/CloneTestHelper.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/CloneTestHelper.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/CloneTestHelper.cs (revision 898d42ca6354285169751f4de231f96f40b1f6f9)
@@ -0,0 +1,95 @@
+// 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.DikeProfiles;
+using Ringtoets.Common.Data.Probabilistics;
+using Ringtoets.Common.Data.Structures;
+
+namespace Ringtoets.Common.Data.TestUtil
+{
+ ///
+ /// Class that defines helper methods that can be used for clone testing.
+ ///
+ public static class CloneTestHelper
+ {
+ ///
+ /// This method adds some random data values to .
+ ///
+ /// The type of structure contained by the input.
+ /// The input object to set the random data values to.
+ public static void SetRandomDataToStructuresInput(StructuresInputBase input) where T : StructureBase
+ {
+ var random = new Random(21);
+
+ input.ModelFactorSuperCriticalFlow = new NormalDistribution
+ {
+ Mean = random.NextRoundedDouble()
+ };
+
+ input.AllowedLevelIncreaseStorage = new LogNormalDistribution
+ {
+ Mean = random.NextRoundedDouble(),
+ StandardDeviation = random.NextRoundedDouble()
+ };
+
+ input.StorageStructureArea = new VariationCoefficientLogNormalDistribution
+ {
+ Mean = random.NextRoundedDouble(),
+ CoefficientOfVariation = random.NextRoundedDouble()
+ };
+
+ input.FlowWidthAtBottomProtection = new LogNormalDistribution
+ {
+ Mean = random.NextRoundedDouble(),
+ StandardDeviation = random.NextRoundedDouble()
+ };
+
+ input.CriticalOvertoppingDischarge = new VariationCoefficientLogNormalDistribution
+ {
+ Mean = random.NextRoundedDouble(),
+ CoefficientOfVariation = random.NextRoundedDouble()
+ };
+
+ input.WidthFlowApertures = new NormalDistribution
+ {
+ Mean = random.NextRoundedDouble(),
+ StandardDeviation = random.NextRoundedDouble()
+ };
+
+ input.StormDuration = new VariationCoefficientLogNormalDistribution
+ {
+ Mean = random.NextRoundedDouble()
+ };
+
+ input.StructureNormalOrientation = random.NextRoundedDouble();
+ input.FailureProbabilityStructureWithErosion = random.NextDouble();
+ input.ForeshoreProfile = new TestForeshoreProfile();
+ input.ShouldIllustrationPointsBeCalculated = random.NextBoolean();
+ input.HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
+ input.UseBreakWater = random.NextBoolean();
+ input.BreakWater.Type = random.NextEnumValue();
+ input.BreakWater.Height = random.NextRoundedDouble();
+ input.UseForeshore = random.NextBoolean();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/Ringtoets.Common.Data.TestUtil.csproj
===================================================================
diff -u -rf935f1251aa545c93e116c9ec0c16a3587f882e2 -r898d42ca6354285169751f4de231f96f40b1f6f9
--- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/Ringtoets.Common.Data.TestUtil.csproj (.../Ringtoets.Common.Data.TestUtil.csproj) (revision f935f1251aa545c93e116c9ec0c16a3587f882e2)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/Ringtoets.Common.Data.TestUtil.csproj (.../Ringtoets.Common.Data.TestUtil.csproj) (revision 898d42ca6354285169751f4de231f96f40b1f6f9)
@@ -57,6 +57,7 @@
+
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresInput.cs
===================================================================
diff -u -rcf60de33a75f1d729639a4ba7f30e3b319f9ed6d -r898d42ca6354285169751f4de231f96f40b1f6f9
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresInput.cs (.../HeightStructuresInput.cs) (revision cf60de33a75f1d729639a4ba7f30e3b319f9ed6d)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresInput.cs (.../HeightStructuresInput.cs) (revision 898d42ca6354285169751f4de231f96f40b1f6f9)
@@ -37,7 +37,7 @@
private static readonly Range deviationWaveDirectionValidityRage = new Range(new RoundedDouble(deviationWaveDirectionNumberOfDecimals, -360),
new RoundedDouble(deviationWaveDirectionNumberOfDecimals, 360));
- private readonly NormalDistribution levelCrestStructure;
+ private NormalDistribution levelCrestStructure;
private RoundedDouble deviationWaveDirection;
///
@@ -98,6 +98,15 @@
#endregion
+ public override object Clone()
+ {
+ var clone = (HeightStructuresInput) base.Clone();
+
+ clone.levelCrestStructure = (NormalDistribution) LevelCrestStructure.Clone();
+
+ return clone;
+ }
+
public override bool IsStructureInputSynchronized
{
get
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresInputTest.cs
===================================================================
diff -u -rbf3379d1adf449816e6fe5f941604ce2e6d0b707 -r898d42ca6354285169751f4de231f96f40b1f6f9
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresInputTest.cs (.../HeightStructuresInputTest.cs) (revision bf3379d1adf449816e6fe5f941604ce2e6d0b707)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresInputTest.cs (.../HeightStructuresInputTest.cs) (revision 898d42ca6354285169751f4de231f96f40b1f6f9)
@@ -28,6 +28,8 @@
using Ringtoets.Common.Data.Structures;
using Ringtoets.Common.Data.TestUtil;
using Ringtoets.HeightStructures.Data.TestUtil;
+using CoreCloneAssert = Core.Common.Data.TestUtil.CloneAssert;
+using HeightStructuresCloneAssert = Ringtoets.HeightStructures.Data.TestUtil.CloneAssert;
namespace Ringtoets.HeightStructures.Data.Test
{
@@ -239,6 +241,31 @@
#endregion
+ [Test]
+ public void Clone_Always_ReturnNewInstanceWithCopiedValues()
+ {
+ // Setup
+ var random = new Random(21);
+ var original = new HeightStructuresInput
+ {
+ Structure = new TestHeightStructure(),
+ LevelCrestStructure = new NormalDistribution
+ {
+ Mean = random.NextRoundedDouble(),
+ StandardDeviation = random.NextRoundedDouble()
+ },
+ DeviationWaveDirection = random.NextRoundedDouble()
+ };
+
+ CloneTestHelper.SetRandomDataToStructuresInput(original);
+
+ // Call
+ object clone = original.Clone();
+
+ // Assert
+ CoreCloneAssert.AreObjectClones(original, clone, HeightStructuresCloneAssert.AreClones);
+ }
+
#region Hydraulic data
[Test]
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/Ringtoets.HeightStructures.Data.Test.csproj
===================================================================
diff -u -r6a5d7b40b7ba4dcb73e393075338352d194e97c2 -r898d42ca6354285169751f4de231f96f40b1f6f9
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/Ringtoets.HeightStructures.Data.Test.csproj (.../Ringtoets.HeightStructures.Data.Test.csproj) (revision 6a5d7b40b7ba4dcb73e393075338352d194e97c2)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/Ringtoets.HeightStructures.Data.Test.csproj (.../Ringtoets.HeightStructures.Data.Test.csproj) (revision 898d42ca6354285169751f4de231f96f40b1f6f9)
@@ -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/HeightStructures/test/Ringtoets.HeightStructures.Data.TestUtil/CloneAssert.cs
===================================================================
diff -u
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.TestUtil/CloneAssert.cs (revision 0)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.TestUtil/CloneAssert.cs (revision 898d42ca6354285169751f4de231f96f40b1f6f9)
@@ -0,0 +1,50 @@
+// 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.HeightStructures.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(HeightStructuresInput original, HeightStructuresInput clone)
+ {
+ CommonCloneAssert.AreClones(original, clone);
+
+ CoreCloneAssert.AreObjectClones(original.LevelCrestStructure, clone.LevelCrestStructure, DistributionAssert.AreEqual);
+ Assert.AreEqual(original.DeviationWaveDirection, clone.DeviationWaveDirection);
+ }
+ }
+}
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.TestUtil/Ringtoets.HeightStructures.Data.TestUtil.csproj
===================================================================
diff -u -r2e722835ebb7a4bc7a7bbcc07b6cfa9f5776e3d9 -r898d42ca6354285169751f4de231f96f40b1f6f9
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.TestUtil/Ringtoets.HeightStructures.Data.TestUtil.csproj (.../Ringtoets.HeightStructures.Data.TestUtil.csproj) (revision 2e722835ebb7a4bc7a7bbcc07b6cfa9f5776e3d9)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.TestUtil/Ringtoets.HeightStructures.Data.TestUtil.csproj (.../Ringtoets.HeightStructures.Data.TestUtil.csproj) (revision 898d42ca6354285169751f4de231f96f40b1f6f9)
@@ -49,6 +49,7 @@
Properties\GlobalAssembly.cs
+
@@ -60,6 +61,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
@@ -68,6 +73,10 @@
{d4200f43-3f72-4f42-af0a-8ced416a38ec}Ringtoets.Common.Data
+
+ {4843d6e5-066f-4795-94f5-1d53932dd03c}
+ Ringtoets.Common.Data.TestUtil
+ {1C0017D8-35B5-4CA0-8FC7-A83F46DBDC99}Ringtoets.HeightStructures.Data