Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsSlipPlaneUpliftVan.cs =================================================================== diff -u -r0f736d81afe800a482dff027fe93128a5e967114 -r4cbf31a1ae47d22c811e4a8d8f8e6d0f89ddc202 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsSlipPlaneUpliftVan.cs (.../MacroStabilityInwardsSlipPlaneUpliftVan.cs) (revision 0f736d81afe800a482dff027fe93128a5e967114) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsSlipPlaneUpliftVan.cs (.../MacroStabilityInwardsSlipPlaneUpliftVan.cs) (revision 4cbf31a1ae47d22c811e4a8d8f8e6d0f89ddc202) @@ -21,13 +21,14 @@ using System; using System.Collections.Generic; +using System.Linq; namespace Ringtoets.MacroStabilityInwards.Data { /// /// The Uplift Van calculation grid of a macro stability calculation. /// - public class MacroStabilityInwardsSlipPlaneUpliftVan + public class MacroStabilityInwardsSlipPlaneUpliftVan : ICloneable { /// /// Creates a new instance of . @@ -61,16 +62,26 @@ /// /// Gets the left grid result. /// - public MacroStabilityInwardsGrid LeftGrid { get; } + public MacroStabilityInwardsGrid LeftGrid { get; private set; } /// /// Gets the right grid result. /// - public MacroStabilityInwardsGrid RightGrid { get; } + public MacroStabilityInwardsGrid RightGrid { get; private set; } /// /// Gets the tangent lines result. /// - public IEnumerable TangentLines { get; } + public IEnumerable TangentLines { get; private set; } + + public object Clone() + { + var clone = (MacroStabilityInwardsSlipPlaneUpliftVan) MemberwiseClone(); + clone.LeftGrid = (MacroStabilityInwardsGrid) LeftGrid.Clone(); + clone.RightGrid = (MacroStabilityInwardsGrid) RightGrid.Clone(); + clone.TangentLines = TangentLines.ToArray(); + + return clone; + } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsSlipPlaneUpliftVanTest.cs =================================================================== diff -u -r0f736d81afe800a482dff027fe93128a5e967114 -r4cbf31a1ae47d22c811e4a8d8f8e6d0f89ddc202 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsSlipPlaneUpliftVanTest.cs (.../MacroStabilityInwardsSlipPlaneUpliftVanTest.cs) (revision 0f736d81afe800a482dff027fe93128a5e967114) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsSlipPlaneUpliftVanTest.cs (.../MacroStabilityInwardsSlipPlaneUpliftVanTest.cs) (revision 4cbf31a1ae47d22c811e4a8d8f8e6d0f89ddc202) @@ -20,7 +20,9 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Linq; +using Core.Common.Data.TestUtil; using NUnit.Framework; using Ringtoets.MacroStabilityInwards.Data.TestUtil; @@ -78,21 +80,36 @@ // Setup MacroStabilityInwardsGrid leftGrid = MacroStabilityInwardsGridTestFactory.Create(); MacroStabilityInwardsGrid rightGrid = MacroStabilityInwardsGridTestFactory.Create(); - var tangentLines = new[] - { - 0, - 1, - 1.5, - 2 - }; + IEnumerable tangentLines = Enumerable.Empty(); // Call var result = new MacroStabilityInwardsSlipPlaneUpliftVan(leftGrid, rightGrid, tangentLines); // Assert + Assert.IsInstanceOf(result); + Assert.AreSame(leftGrid, result.LeftGrid); Assert.AreSame(rightGrid, result.RightGrid); Assert.AreSame(tangentLines, result.TangentLines); } + + [Test] + public void Clone_Always_ReturnNewInstanceWithCopiedValues() + { + // Setup + var random = new Random(21); + var original = new MacroStabilityInwardsSlipPlaneUpliftVan(MacroStabilityInwardsGridTestFactory.Create(), + MacroStabilityInwardsGridTestFactory.Create(), + new[] + { + random.NextDouble() + }); + + // Call + object clone = original.Clone(); + + // Assert + CoreCloneAssert.AreObjectClones(original, clone, MacroStabilityInwardsCloneAssert.AreClones); + } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/MacroStabilityInwardsCloneAssert.cs =================================================================== diff -u -r47b2bbe8b9d15194a9641a2db098c25e5e775528 -r4cbf31a1ae47d22c811e4a8d8f8e6d0f89ddc202 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/MacroStabilityInwardsCloneAssert.cs (.../MacroStabilityInwardsCloneAssert.cs) (revision 47b2bbe8b9d15194a9641a2db098c25e5e775528) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/MacroStabilityInwardsCloneAssert.cs (.../MacroStabilityInwardsCloneAssert.cs) (revision 4cbf31a1ae47d22c811e4a8d8f8e6d0f89ddc202) @@ -57,6 +57,23 @@ /// The cloned object. /// Thrown when and /// are not clones. + public static void AreClones(MacroStabilityInwardsSlipPlaneUpliftVan original, + MacroStabilityInwardsSlipPlaneUpliftVan clone) + { + CoreCloneAssert.AreObjectClones(original.LeftGrid, clone.LeftGrid, AreClones); + CoreCloneAssert.AreObjectClones(original.RightGrid, clone.RightGrid, AreClones); + CoreCloneAssert.AreEnumerationClones(original.TangentLines, clone.TangentLines, + (originalTangentLine, clonedTangentLine) => Assert.AreEqual(originalTangentLine, clonedTangentLine)); + } + + /// + /// Method that asserts whether and + /// are clones. + /// + /// The original object. + /// The cloned object. + /// Thrown when and + /// are not clones. public static void AreClones(MacroStabilityInwardsSlidingCurve original, MacroStabilityInwardsSlidingCurve clone) {