Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/CommentTest.cs
===================================================================
diff -u -rbdc1d159661a25dba2ffbaefab2f03ce70fc56f7 -r4909d5c5d2883b3c6974f2f3840bd55797e8b0bd
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/CommentTest.cs (.../CommentTest.cs) (revision bdc1d159661a25dba2ffbaefab2f03ce70fc56f7)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/CommentTest.cs (.../CommentTest.cs) (revision 4909d5c5d2883b3c6974f2f3840bd55797e8b0bd)
@@ -20,8 +20,9 @@
// All rights reserved.
using System;
-using Core.Common.Data.TestUtil;
using NUnit.Framework;
+using CloneAssert = Core.Common.Data.TestUtil.CloneAssert;
+using CustomCloneAssert = Ringtoets.Common.Data.TestUtil.CloneAssert;
namespace Ringtoets.Common.Data.Test
{
@@ -52,10 +53,7 @@
object clone = original.Clone();
// Assert
- CloneAssert.AreClones(original, clone, (o, c) =>
- {
- Assert.AreEqual(o.Body, c.Body);
- });
+ CloneAssert.AreClones(original, clone, CustomCloneAssert.AreClones);
}
}
}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/DikeProfiles/BreakWaterTest.cs
===================================================================
diff -u -rfa4ee67e5a95992fd35d27a557850866d871cfba -r4909d5c5d2883b3c6974f2f3840bd55797e8b0bd
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/DikeProfiles/BreakWaterTest.cs (.../BreakWaterTest.cs) (revision fa4ee67e5a95992fd35d27a557850866d871cfba)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/DikeProfiles/BreakWaterTest.cs (.../BreakWaterTest.cs) (revision 4909d5c5d2883b3c6974f2f3840bd55797e8b0bd)
@@ -21,10 +21,11 @@
using System;
using Core.Common.Base.Data;
-using Core.Common.Data.TestUtil;
using Core.Common.TestUtil;
using NUnit.Framework;
using Ringtoets.Common.Data.DikeProfiles;
+using CloneAssert = Core.Common.Data.TestUtil.CloneAssert;
+using CustomCloneAssert = Ringtoets.Common.Data.TestUtil.CloneAssert;
namespace Ringtoets.Common.Data.Test.DikeProfiles
{
@@ -242,7 +243,7 @@
object clone = original.Clone();
// Assert
- CloneAssert.AreClones(original, clone, TestUtil.CloneAssert.AreClones);
+ CloneAssert.AreClones(original, clone, CustomCloneAssert.AreClones);
}
}
}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/CloneAssert.cs
===================================================================
diff -u -r5a04e92c56a507e440e86487d97fc731de005d88 -r4909d5c5d2883b3c6974f2f3840bd55797e8b0bd
--- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/CloneAssert.cs (.../CloneAssert.cs) (revision 5a04e92c56a507e440e86487d97fc731de005d88)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/CloneAssert.cs (.../CloneAssert.cs) (revision 4909d5c5d2883b3c6974f2f3840bd55797e8b0bd)
@@ -60,5 +60,18 @@
Assert.AreEqual(original.Reliability, clone.Reliability);
Assert.AreEqual(original.FactorOfSafety, clone.FactorOfSafety);
}
+
+ ///
+ /// Method that asserts whether and
+ /// are clones.
+ ///
+ /// The original object.
+ /// The cloned object.
+ /// Thrown when and
+ /// are not clones.
+ public static void AreClones(Comment original, Comment clone)
+ {
+ Assert.AreEqual(original.Body, clone.Body);
+ }
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsCalculation.cs
===================================================================
diff -u -rfd7cb4da4164284049a3627b1d85f92e722d1814 -r4909d5c5d2883b3c6974f2f3840bd55797e8b0bd
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsCalculation.cs (.../GrassCoverErosionInwardsCalculation.cs) (revision fd7cb4da4164284049a3627b1d85f92e722d1814)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsCalculation.cs (.../GrassCoverErosionInwardsCalculation.cs) (revision 4909d5c5d2883b3c6974f2f3840bd55797e8b0bd)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using Core.Common.Base;
using Ringtoets.Common.Data;
using Ringtoets.Common.Data.Calculation;
@@ -29,7 +30,7 @@
///
/// This class holds information about a calculation for the .
///
- public class GrassCoverErosionInwardsCalculation : Observable, ICalculation
+ public class GrassCoverErosionInwardsCalculation : Observable, ICalculation, ICloneable
{
///
/// Creates a new instance of .
@@ -44,14 +45,14 @@
///
/// Gets the input parameters to perform a grass cover erosion inwards calculation with.
///
- public GrassCoverErosionInwardsInput InputParameters { get; }
+ public GrassCoverErosionInwardsInput InputParameters { get; private set; }
///
/// Gets or sets , which contains the results of a probabilistic calculation.
///
public GrassCoverErosionInwardsOutput Output { get; set; }
- public Comment Comments { get; }
+ public Comment Comments { get; private set; }
public string Name { get; set; }
@@ -76,5 +77,16 @@
{
Output = null;
}
+
+ public object Clone()
+ {
+ var clone = (GrassCoverErosionInwardsCalculation) MemberwiseClone();
+
+ clone.Comments = (Comment) Comments.Clone();
+ clone.InputParameters = (GrassCoverErosionInwardsInput) InputParameters.Clone();
+ clone.Output = (GrassCoverErosionInwardsOutput) Output.Clone();
+
+ return clone;
+ }
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsCalculationTest.cs
===================================================================
diff -u -raeb6e1a439617630e7613b9ed5af152c345fa2c6 -r4909d5c5d2883b3c6974f2f3840bd55797e8b0bd
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsCalculationTest.cs (.../GrassCoverErosionInwardsCalculationTest.cs) (revision aeb6e1a439617630e7613b9ed5af152c345fa2c6)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsCalculationTest.cs (.../GrassCoverErosionInwardsCalculationTest.cs) (revision 4909d5c5d2883b3c6974f2f3840bd55797e8b0bd)
@@ -19,10 +19,18 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using Core.Common.Base;
+using Core.Common.TestUtil;
using NUnit.Framework;
using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.Probabilistics;
+using Ringtoets.Common.Data.TestUtil;
using Ringtoets.GrassCoverErosionInwards.Data.TestUtil;
+using CloneAssert = Core.Common.Data.TestUtil.CloneAssert;
+using CommonCloneAssert = Ringtoets.Common.Data.TestUtil.CloneAssert;
+using CustomCloneAssert = Ringtoets.GrassCoverErosionInwards.Data.TestUtil.CloneAssert;
namespace Ringtoets.GrassCoverErosionInwards.Data.Test
{
@@ -38,6 +46,7 @@
// Assert
Assert.IsInstanceOf(calculation);
Assert.IsInstanceOf(calculation);
+ Assert.IsInstanceOf(calculation);
Assert.AreEqual("Nieuwe berekening", calculation.Name);
Assert.IsNotNull(calculation.InputParameters);
@@ -126,5 +135,56 @@
// Assert
Assert.IsTrue(calculationHasOutput);
}
+
+ [Test]
+ public void Clone_Always_ReturnNewInstanceWithCopiedValues()
+ {
+ // Setup
+ var random = new Random(21);
+ var original = new GrassCoverErosionInwardsCalculation
+ {
+ InputParameters =
+ {
+ DikeProfile = new TestDikeProfile(),
+ Orientation = random.NextRoundedDouble(),
+ DikeHeight = random.NextRoundedDouble(),
+ CriticalFlowRate = new LogNormalDistribution
+ {
+ Mean = random.NextRoundedDouble(),
+ StandardDeviation = random.NextRoundedDouble()
+ },
+ HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(),
+ DikeHeightCalculationType = random.NextEnumValue(),
+ OvertoppingRateCalculationType = random.NextEnumValue(),
+ ShouldDikeHeightIllustrationPointsBeCalculated = random.NextBoolean(),
+ ShouldOvertoppingRateIllustrationPointsBeCalculated = random.NextBoolean(),
+ ShouldOvertoppingOutputIllustrationPointsBeCalculated = random.NextBoolean(),
+ UseBreakWater = random.NextBoolean(),
+ BreakWater =
+ {
+ Type = random.NextEnumValue(),
+ Height = random.NextRoundedDouble()
+ },
+ UseForeshore = random.NextBoolean()
+ },
+ Comments =
+ {
+ Body = "Random body"
+ },
+ Output = new TestGrassCoverErosionInwardsOutput()
+ };
+
+ // Call
+ object clone = original.Clone();
+
+ // Assert
+ CloneAssert.AreClones(original, clone, (o, c) =>
+ {
+ Assert.AreEqual(o.Name, c.Name);
+ CloneAssert.AreClones(o.Comments, c.Comments, CommonCloneAssert.AreClones);
+ CloneAssert.AreClones(o.InputParameters, c.InputParameters, CustomCloneAssert.AreClones);
+ CloneAssert.AreClones(o.Output, c.Output, CustomCloneAssert.AreClones);
+ });
+ }
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsInputTest.cs
===================================================================
diff -u -rfa4ee67e5a95992fd35d27a557850866d871cfba -r4909d5c5d2883b3c6974f2f3840bd55797e8b0bd
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsInputTest.cs (.../GrassCoverErosionInwardsInputTest.cs) (revision fa4ee67e5a95992fd35d27a557850866d871cfba)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsInputTest.cs (.../GrassCoverErosionInwardsInputTest.cs) (revision 4909d5c5d2883b3c6974f2f3840bd55797e8b0bd)
@@ -32,7 +32,7 @@
using Ringtoets.Common.Data.Probabilistics;
using Ringtoets.Common.Data.TestUtil;
using CloneAssert = Core.Common.Data.TestUtil.CloneAssert;
-using CustomCloneAssert = Ringtoets.Common.Data.TestUtil.CloneAssert;
+using CustomCloneAssert = Ringtoets.GrassCoverErosionInwards.Data.TestUtil.CloneAssert;
namespace Ringtoets.GrassCoverErosionInwards.Data.Test
{
@@ -397,22 +397,7 @@
object clone = original.Clone();
// Assert
- CloneAssert.AreClones(original, clone, (o, c) =>
- {
- Assert.AreSame(o.DikeProfile, c.DikeProfile);
- Assert.AreEqual(o.Orientation, c.Orientation);
- Assert.AreEqual(o.DikeHeight, c.DikeHeight);
- CloneAssert.AreClones(o.CriticalFlowRate, c.CriticalFlowRate, DistributionAssert.AreEqual);
- Assert.AreSame(o.HydraulicBoundaryLocation, c.HydraulicBoundaryLocation);
- Assert.AreEqual(o.DikeHeightCalculationType, c.DikeHeightCalculationType);
- Assert.AreEqual(o.OvertoppingRateCalculationType, c.OvertoppingRateCalculationType);
- Assert.AreEqual(o.ShouldDikeHeightIllustrationPointsBeCalculated, c.ShouldDikeHeightIllustrationPointsBeCalculated);
- Assert.AreEqual(o.ShouldOvertoppingRateIllustrationPointsBeCalculated, c.ShouldOvertoppingRateIllustrationPointsBeCalculated);
- Assert.AreEqual(o.ShouldOvertoppingOutputIllustrationPointsBeCalculated, c.ShouldOvertoppingOutputIllustrationPointsBeCalculated);
- Assert.AreEqual(o.UseBreakWater, c.UseBreakWater);
- CloneAssert.AreClones(o.BreakWater, c.BreakWater, CustomCloneAssert.AreClones);
- Assert.AreEqual(o.UseForeshore, c.UseForeshore);
- });
+ CloneAssert.AreClones(original, clone, CustomCloneAssert.AreClones);
}
private static void AssertDikeProfileInput(DikeProfile expectedDikeProfile, GrassCoverErosionInwardsInput input)
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsOutputTest.cs
===================================================================
diff -u -re7f6578ada32ed199d2b028ebb5eaeb691344592 -r4909d5c5d2883b3c6974f2f3840bd55797e8b0bd
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsOutputTest.cs (.../GrassCoverErosionInwardsOutputTest.cs) (revision e7f6578ada32ed199d2b028ebb5eaeb691344592)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsOutputTest.cs (.../GrassCoverErosionInwardsOutputTest.cs) (revision 4909d5c5d2883b3c6974f2f3840bd55797e8b0bd)
@@ -79,12 +79,7 @@
object clone = original.Clone();
// Assert
- CloneAssert.AreClones(original, clone, (o, c) =>
- {
- CloneAssert.AreClones(o.OvertoppingOutput, c.OvertoppingOutput, CustomCloneAssert.AreClones);
- CloneAssert.AreClones(o.DikeHeightOutput, c.DikeHeightOutput, CustomCloneAssert.AreClones);
- CloneAssert.AreClones(o.OvertoppingRateOutput, c.OvertoppingRateOutput, CustomCloneAssert.AreClones);
- });
+ CloneAssert.AreClones(original, clone, CustomCloneAssert.AreClones);
}
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.TestUtil/CloneAssert.cs
===================================================================
diff -u -re7f6578ada32ed199d2b028ebb5eaeb691344592 -r4909d5c5d2883b3c6974f2f3840bd55797e8b0bd
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.TestUtil/CloneAssert.cs (.../CloneAssert.cs) (revision e7f6578ada32ed199d2b028ebb5eaeb691344592)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.TestUtil/CloneAssert.cs (.../CloneAssert.cs) (revision 4909d5c5d2883b3c6974f2f3840bd55797e8b0bd)
@@ -20,6 +20,7 @@
// All rights reserved.
using NUnit.Framework;
+using Ringtoets.Common.Data.TestUtil;
using BaseCloneAssert = Core.Common.Data.TestUtil.CloneAssert;
using CommonCloneAssert = Ringtoets.Common.Data.TestUtil.CloneAssert;
@@ -89,5 +90,29 @@
AreClones((HydraulicLoadsOutput) original, clone);
Assert.AreEqual(original.OvertoppingRate, clone.OvertoppingRate);
}
+
+ public static void AreClones(GrassCoverErosionInwardsInput original, GrassCoverErosionInwardsInput clone)
+ {
+ Assert.AreSame(original.DikeProfile, clone.DikeProfile);
+ Assert.AreEqual(original.Orientation, clone.Orientation);
+ Assert.AreEqual(original.DikeHeight, clone.DikeHeight);
+ BaseCloneAssert.AreClones(original.CriticalFlowRate, clone.CriticalFlowRate, DistributionAssert.AreEqual);
+ Assert.AreSame(original.HydraulicBoundaryLocation, clone.HydraulicBoundaryLocation);
+ Assert.AreEqual(original.DikeHeightCalculationType, clone.DikeHeightCalculationType);
+ Assert.AreEqual(original.OvertoppingRateCalculationType, clone.OvertoppingRateCalculationType);
+ Assert.AreEqual(original.ShouldDikeHeightIllustrationPointsBeCalculated, clone.ShouldDikeHeightIllustrationPointsBeCalculated);
+ Assert.AreEqual(original.ShouldOvertoppingRateIllustrationPointsBeCalculated, clone.ShouldOvertoppingRateIllustrationPointsBeCalculated);
+ Assert.AreEqual(original.ShouldOvertoppingOutputIllustrationPointsBeCalculated, clone.ShouldOvertoppingOutputIllustrationPointsBeCalculated);
+ Assert.AreEqual(original.UseBreakWater, clone.UseBreakWater);
+ BaseCloneAssert.AreClones(original.BreakWater, clone.BreakWater, CommonCloneAssert.AreClones);
+ Assert.AreEqual(original.UseForeshore, clone.UseForeshore);
+ }
+
+ public static void AreClones(GrassCoverErosionInwardsOutput o, GrassCoverErosionInwardsOutput c)
+ {
+ BaseCloneAssert.AreClones(o.OvertoppingOutput, c.OvertoppingOutput, AreClones);
+ BaseCloneAssert.AreClones(o.DikeHeightOutput, c.DikeHeightOutput, AreClones);
+ BaseCloneAssert.AreClones(o.OvertoppingRateOutput, c.OvertoppingRateOutput, AreClones);
+ }
}
}
\ No newline at end of file