Index: Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/TopLevelIllustrationPointBase.cs
===================================================================
diff -u -rf935f1251aa545c93e116c9ec0c16a3587f882e2 -r2a88a3e4469b6b59db4ca9ff874cf69804c9393e
--- Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/TopLevelIllustrationPointBase.cs (.../TopLevelIllustrationPointBase.cs) (revision f935f1251aa545c93e116c9ec0c16a3587f882e2)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/TopLevelIllustrationPointBase.cs (.../TopLevelIllustrationPointBase.cs) (revision 2a88a3e4469b6b59db4ca9ff874cf69804c9393e)
@@ -61,7 +61,7 @@
///
public string ClosingSituation { get; }
- public object Clone()
+ public virtual object Clone()
{
var clone = (TopLevelIllustrationPointBase) MemberwiseClone();
Index: Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/TopLevelSubMechanismIllustrationPoint.cs
===================================================================
diff -u -rd16d146d545cf86ad58c5e2c73cb5bc1b784ce67 -r2a88a3e4469b6b59db4ca9ff874cf69804c9393e
--- Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/TopLevelSubMechanismIllustrationPoint.cs (.../TopLevelSubMechanismIllustrationPoint.cs) (revision d16d146d545cf86ad58c5e2c73cb5bc1b784ce67)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/TopLevelSubMechanismIllustrationPoint.cs (.../TopLevelSubMechanismIllustrationPoint.cs) (revision 2a88a3e4469b6b59db4ca9ff874cf69804c9393e)
@@ -52,6 +52,15 @@
///
/// Gets the sub mechanism illustration point.
///
- public SubMechanismIllustrationPoint SubMechanismIllustrationPoint { get; }
+ public SubMechanismIllustrationPoint SubMechanismIllustrationPoint { get; private set; }
+
+ public override object Clone()
+ {
+ var clone = (TopLevelSubMechanismIllustrationPoint) base.Clone();
+
+ clone.SubMechanismIllustrationPoint = (SubMechanismIllustrationPoint) SubMechanismIllustrationPoint.Clone();
+
+ return clone;
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/TopLevelSubMechanismIllustrationPointTest.cs
===================================================================
diff -u -r0913b25b262329fc46c40cc84e4c127dae21b85f -r2a88a3e4469b6b59db4ca9ff874cf69804c9393e
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/TopLevelSubMechanismIllustrationPointTest.cs (.../TopLevelSubMechanismIllustrationPointTest.cs) (revision 0913b25b262329fc46c40cc84e4c127dae21b85f)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/TopLevelSubMechanismIllustrationPointTest.cs (.../TopLevelSubMechanismIllustrationPointTest.cs) (revision 2a88a3e4469b6b59db4ca9ff874cf69804c9393e)
@@ -23,6 +23,8 @@
using NUnit.Framework;
using Ringtoets.Common.Data.IllustrationPoints;
using Ringtoets.Common.Data.TestUtil.IllustrationPoints;
+using CoreCloneAssert = Core.Common.Data.TestUtil.CloneAssert;
+using CommonCloneAssert = Ringtoets.Common.Data.TestUtil.CloneAssert;
namespace Ringtoets.Common.Data.Test.IllustrationPoints
{
@@ -89,10 +91,24 @@
// Assert
Assert.IsInstanceOf(windDirectionClosingScenarioIllustrationPoint);
-
Assert.AreEqual(closingScenario, windDirectionClosingScenarioIllustrationPoint.ClosingSituation);
Assert.AreSame(windDirection, windDirectionClosingScenarioIllustrationPoint.WindDirection);
Assert.AreSame(submechanismIllustrationPoint, windDirectionClosingScenarioIllustrationPoint.SubMechanismIllustrationPoint);
}
+
+ [Test]
+ public void Clone_Always_ReturnNewInstanceWithCopiedValues()
+ {
+ // Setup
+ var original = new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(),
+ "Random closing situation",
+ new TestSubMechanismIllustrationPoint());
+
+ // Call
+ object clone = original.Clone();
+
+ // Assert
+ CoreCloneAssert.AreClones(original, clone, CommonCloneAssert.AreClones);
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/CloneAssert.cs
===================================================================
diff -u -r08c14e6427740dd913ec90e67b39b90eae396f8d -r2a88a3e4469b6b59db4ca9ff874cf69804c9393e
--- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/CloneAssert.cs (.../CloneAssert.cs) (revision 08c14e6427740dd913ec90e67b39b90eae396f8d)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/CloneAssert.cs (.../CloneAssert.cs) (revision 2a88a3e4469b6b59db4ca9ff874cf69804c9393e)
@@ -141,6 +141,20 @@
/// The cloned object.
/// Thrown when and
/// are not clones.
+ public static void AreClones(TopLevelSubMechanismIllustrationPoint original, TopLevelSubMechanismIllustrationPoint clone)
+ {
+ AreClones((TopLevelIllustrationPointBase)original, clone);
+ CoreCloneAssert.AreClones(original.SubMechanismIllustrationPoint, clone.SubMechanismIllustrationPoint, AreClones);
+ }
+
+ ///
+ /// Method that asserts whether and
+ /// are clones.
+ ///
+ /// The original object.
+ /// The cloned object.
+ /// Thrown when and
+ /// are not clones.
public static void AreClones(IllustrationPointResult original, IllustrationPointResult clone)
{
Assert.AreEqual(original.Description, clone.Description);