Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsOutput.cs =================================================================== diff -u -ra64e778ac45d89e0bc35900b5c5b4a85e1f24089 -re7f6578ada32ed199d2b028ebb5eaeb691344592 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsOutput.cs (.../GrassCoverErosionInwardsOutput.cs) (revision a64e778ac45d89e0bc35900b5c5b4a85e1f24089) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsOutput.cs (.../GrassCoverErosionInwardsOutput.cs) (revision e7f6578ada32ed199d2b028ebb5eaeb691344592) @@ -28,7 +28,7 @@ /// /// The overall result of a grass cover erosion inwards assessment. /// - public class GrassCoverErosionInwardsOutput : Observable, ICalculationOutput + public class GrassCoverErosionInwardsOutput : Observable, ICalculationOutput, ICloneable { /// /// Creates a new instance of . @@ -54,16 +54,27 @@ /// /// Gets the overtopping output. /// - public OvertoppingOutput OvertoppingOutput { get; } + public OvertoppingOutput OvertoppingOutput { get; private set; } /// /// Gets the dike height output. /// - public DikeHeightOutput DikeHeightOutput { get; } + public DikeHeightOutput DikeHeightOutput { get; private set; } /// /// Gets the overtopping rate output. /// - public OvertoppingRateOutput OvertoppingRateOutput { get; } + public OvertoppingRateOutput OvertoppingRateOutput { get; private set; } + + public object Clone() + { + var clone = (GrassCoverErosionInwardsOutput) MemberwiseClone(); + + clone.OvertoppingOutput = (OvertoppingOutput) OvertoppingOutput.Clone(); + clone.DikeHeightOutput = (DikeHeightOutput) DikeHeightOutput.Clone(); + clone.OvertoppingRateOutput = (OvertoppingRateOutput) OvertoppingRateOutput.Clone(); + + return clone; + } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/DikeHeightOutputTest.cs =================================================================== diff -u -r129a499de1e263e11a64ce31b0da70431120e264 -re7f6578ada32ed199d2b028ebb5eaeb691344592 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/DikeHeightOutputTest.cs (.../DikeHeightOutputTest.cs) (revision 129a499de1e263e11a64ce31b0da70431120e264) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/DikeHeightOutputTest.cs (.../DikeHeightOutputTest.cs) (revision e7f6578ada32ed199d2b028ebb5eaeb691344592) @@ -117,11 +117,7 @@ object clone = original.Clone(); // Assert - CloneAssert.AreClones(original, clone, (o, c) => - { - CustomCloneAssert.AreClones(o, c); - Assert.AreEqual(o.DikeHeight, c.DikeHeight); - }); + CloneAssert.AreClones(original, clone, CustomCloneAssert.AreClones); } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsOutputTest.cs =================================================================== diff -u -r3c5eb8dc63626571ddee036cac675707bd0b0ff0 -re7f6578ada32ed199d2b028ebb5eaeb691344592 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsOutputTest.cs (.../GrassCoverErosionInwardsOutputTest.cs) (revision 3c5eb8dc63626571ddee036cac675707bd0b0ff0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsOutputTest.cs (.../GrassCoverErosionInwardsOutputTest.cs) (revision e7f6578ada32ed199d2b028ebb5eaeb691344592) @@ -24,6 +24,8 @@ using NUnit.Framework; using Ringtoets.Common.Data.Calculation; using Ringtoets.GrassCoverErosionInwards.Data.TestUtil; +using CloneAssert = Core.Common.Data.TestUtil.CloneAssert; +using CustomCloneAssert = Ringtoets.GrassCoverErosionInwards.Data.TestUtil.CloneAssert; namespace Ringtoets.GrassCoverErosionInwards.Data.Test { @@ -63,5 +65,26 @@ Assert.AreSame(dikeHeightOutput, output.DikeHeightOutput); Assert.AreSame(overtoppingRateOutput, output.OvertoppingRateOutput); } + + [Test] + public void Clone_Always_ReturnNewInstanceWithCopiedValues() + { + // Setup + var random = new Random(21); + var original = new GrassCoverErosionInwardsOutput(new TestOvertoppingOutput(random.NextDouble()), + new TestDikeHeightOutput(random.NextDouble()), + new TestOvertoppingRateOutput(random.NextDouble())); + + // Call + 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); + }); + } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/OvertoppingOutputTest.cs =================================================================== diff -u -rac1f0a30b87d9fa5dccb288115189b032035acde -re7f6578ada32ed199d2b028ebb5eaeb691344592 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/OvertoppingOutputTest.cs (.../OvertoppingOutputTest.cs) (revision ac1f0a30b87d9fa5dccb288115189b032035acde) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/OvertoppingOutputTest.cs (.../OvertoppingOutputTest.cs) (revision e7f6578ada32ed199d2b028ebb5eaeb691344592) @@ -27,7 +27,7 @@ using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Data.TestUtil.IllustrationPoints; 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 { @@ -111,12 +111,7 @@ object clone = original.Clone(); // Assert - CloneAssert.AreClones(original, clone, (o, c) => - { - Assert.AreEqual(o.WaveHeight, c.WaveHeight); - Assert.AreEqual(o.IsOvertoppingDominant, c.IsOvertoppingDominant); - CloneAssert.AreClones(o.ProbabilityAssessmentOutput, c.ProbabilityAssessmentOutput, CustomCloneAssert.AreClones); - }); + CloneAssert.AreClones(original, clone, CustomCloneAssert.AreClones); } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/OvertoppingRateOutputTest.cs =================================================================== diff -u -r129a499de1e263e11a64ce31b0da70431120e264 -re7f6578ada32ed199d2b028ebb5eaeb691344592 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/OvertoppingRateOutputTest.cs (.../OvertoppingRateOutputTest.cs) (revision 129a499de1e263e11a64ce31b0da70431120e264) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/OvertoppingRateOutputTest.cs (.../OvertoppingRateOutputTest.cs) (revision e7f6578ada32ed199d2b028ebb5eaeb691344592) @@ -121,11 +121,7 @@ object clone = original.Clone(); // Assert - CloneAssert.AreClones(original, clone, (o, c) => - { - CustomCloneAssert.AreClones(o, c); - Assert.AreEqual(o.OvertoppingRate, c.OvertoppingRate); - }); + CloneAssert.AreClones(original, clone, CustomCloneAssert.AreClones); } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.TestUtil/CloneAssert.cs =================================================================== diff -u -r129a499de1e263e11a64ce31b0da70431120e264 -re7f6578ada32ed199d2b028ebb5eaeb691344592 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.TestUtil/CloneAssert.cs (.../CloneAssert.cs) (revision 129a499de1e263e11a64ce31b0da70431120e264) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.TestUtil/CloneAssert.cs (.../CloneAssert.cs) (revision e7f6578ada32ed199d2b028ebb5eaeb691344592) @@ -20,6 +20,8 @@ // All rights reserved. using NUnit.Framework; +using BaseCloneAssert = Core.Common.Data.TestUtil.CloneAssert; +using CommonCloneAssert = Ringtoets.Common.Data.TestUtil.CloneAssert; namespace Ringtoets.GrassCoverErosionInwards.Data.TestUtil { @@ -36,6 +38,21 @@ /// The cloned object. /// Thrown when and /// are not clones. + public static void AreClones(OvertoppingOutput original, OvertoppingOutput clone) + { + Assert.AreEqual(original.WaveHeight, clone.WaveHeight); + Assert.AreEqual(original.IsOvertoppingDominant, clone.IsOvertoppingDominant); + BaseCloneAssert.AreClones(original.ProbabilityAssessmentOutput, clone.ProbabilityAssessmentOutput, CommonCloneAssert.AreClones); + } + + /// + /// Method that asserts whether and + /// are clones. + /// + /// The original object. + /// The cloned object. + /// Thrown when and + /// are not clones. public static void AreClones(HydraulicLoadsOutput original, HydraulicLoadsOutput clone) { Assert.AreEqual(original.TargetProbability, clone.TargetProbability); @@ -44,5 +61,33 @@ Assert.AreEqual(original.CalculatedReliability, clone.CalculatedReliability); Assert.AreEqual(original.CalculationConvergence, clone.CalculationConvergence); } + + /// + /// Method that asserts whether and + /// are clones. + /// + /// The original object. + /// The cloned object. + /// Thrown when and + /// are not clones. + public static void AreClones(DikeHeightOutput original, DikeHeightOutput clone) + { + AreClones((HydraulicLoadsOutput) original, clone); + Assert.AreEqual(original.DikeHeight, clone.DikeHeight); + } + + /// + /// Method that asserts whether and + /// are clones. + /// + /// The original object. + /// The cloned object. + /// Thrown when and + /// are not clones. + public static void AreClones(OvertoppingRateOutput original, OvertoppingRateOutput clone) + { + AreClones((HydraulicLoadsOutput) original, clone); + Assert.AreEqual(original.OvertoppingRate, clone.OvertoppingRate); + } } -} +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.TestUtil/Ringtoets.GrassCoverErosionInwards.Data.TestUtil.csproj =================================================================== diff -u -r129a499de1e263e11a64ce31b0da70431120e264 -re7f6578ada32ed199d2b028ebb5eaeb691344592 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.TestUtil/Ringtoets.GrassCoverErosionInwards.Data.TestUtil.csproj (.../Ringtoets.GrassCoverErosionInwards.Data.TestUtil.csproj) (revision 129a499de1e263e11a64ce31b0da70431120e264) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.TestUtil/Ringtoets.GrassCoverErosionInwards.Data.TestUtil.csproj (.../Ringtoets.GrassCoverErosionInwards.Data.TestUtil.csproj) (revision e7f6578ada32ed199d2b028ebb5eaeb691344592) @@ -63,12 +63,20 @@ {3BBFD65B-B277-4E50-AE6D-BD24C3434609} Core.Common.Base + + {0b0d2dff-7e7e-4bb0-a007-61800c85809a} + Core.Common.Data.TestUtil + {d4200f43-3f72-4f42-af0a-8ced416a38ec} Ringtoets.Common.Data + + {4843d6e5-066f-4795-94f5-1d53932dd03c} + Ringtoets.Common.Data.TestUtil + - {90de728e-48ef-4665-ab38-3d88e41d9f4d} + {90DE728E-48EF-4665-AB38-3D88E41D9F4D} Ringtoets.GrassCoverErosionInwards.Data