Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresInputBaseTest.cs =================================================================== diff -u -radbf2699810c35ead18e88e52127546aab78c23c -rfaa685cb8293f1cc01d24fedb75fa260ecc58817 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresInputBaseTest.cs (.../StructuresInputBaseTest.cs) (revision adbf2699810c35ead18e88e52127546aab78c23c) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresInputBaseTest.cs (.../StructuresInputBaseTest.cs) (revision faa685cb8293f1cc01d24fedb75fa260ecc58817) @@ -32,6 +32,8 @@ using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Data.TestUtil; +using CoreCloneAssert = Core.Common.Data.TestUtil.CloneAssert; +using CommonCloneAssert = Ringtoets.Common.Data.TestUtil.CloneAssert; namespace Ringtoets.Common.Data.Test.Structures { @@ -279,6 +281,68 @@ #endregion + [Test] + 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() + }; + + // Call + object clone = original.Clone(); + + // Assert + CoreCloneAssert.AreObjectClones(original, clone, CommonCloneAssert.AreClones); + } + private class SimpleStructuresInput : StructuresInputBase { public override bool IsStructureInputSynchronized Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/CloneAssert.cs =================================================================== diff -u -r3a9d99a08904f51923c5dfbbeb3f4133e95f6f3a -rfaa685cb8293f1cc01d24fedb75fa260ecc58817 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/CloneAssert.cs (.../CloneAssert.cs) (revision 3a9d99a08904f51923c5dfbbeb3f4133e95f6f3a) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/CloneAssert.cs (.../CloneAssert.cs) (revision faa685cb8293f1cc01d24fedb75fa260ecc58817) @@ -23,6 +23,7 @@ using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.IllustrationPoints; using Ringtoets.Common.Data.Probability; +using Ringtoets.Common.Data.Structures; using CoreCloneAssert = Core.Common.Data.TestUtil.CloneAssert; namespace Ringtoets.Common.Data.TestUtil @@ -143,7 +144,7 @@ /// are not clones. public static void AreClones(TopLevelSubMechanismIllustrationPoint original, TopLevelSubMechanismIllustrationPoint clone) { - AreClones((TopLevelIllustrationPointBase)original, clone); + AreClones((TopLevelIllustrationPointBase) original, clone); CoreCloneAssert.AreObjectClones(original.SubMechanismIllustrationPoint, clone.SubMechanismIllustrationPoint, AreClones); } @@ -262,5 +263,33 @@ CoreCloneAssert.AreEnumerationClones(original.Stochasts, clone.Stochasts, AreClones); CoreCloneAssert.AreEnumerationClones(original.TopLevelIllustrationPoints, clone.TopLevelIllustrationPoints, AreClones); } + + /// + /// Method that asserts whether and + /// are clones. + /// + /// The original object. + /// The cloned object. + /// Thrown when and + /// are not clones. + public static void AreClones(StructuresInputBase original, StructuresInputBase clone) where T : StructureBase + { + CoreCloneAssert.AreObjectClones(original.ModelFactorSuperCriticalFlow, clone.ModelFactorSuperCriticalFlow, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.AllowedLevelIncreaseStorage, clone.AllowedLevelIncreaseStorage, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.StorageStructureArea, clone.StorageStructureArea, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.FlowWidthAtBottomProtection, clone.FlowWidthAtBottomProtection, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.CriticalOvertoppingDischarge, clone.CriticalOvertoppingDischarge, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.WidthFlowApertures, clone.WidthFlowApertures, DistributionAssert.AreEqual); + CoreCloneAssert.AreObjectClones(original.StormDuration, clone.StormDuration, DistributionAssert.AreEqual); + Assert.AreSame(original.Structure, clone.Structure); + Assert.AreEqual(original.StructureNormalOrientation, clone.StructureNormalOrientation); + Assert.AreEqual(original.FailureProbabilityStructureWithErosion, clone.FailureProbabilityStructureWithErosion); + Assert.AreSame(original.ForeshoreProfile, clone.ForeshoreProfile); + Assert.AreEqual(original.ShouldIllustrationPointsBeCalculated, clone.ShouldIllustrationPointsBeCalculated); + Assert.AreSame(original.HydraulicBoundaryLocation, clone.HydraulicBoundaryLocation); + Assert.AreEqual(original.UseBreakWater, clone.UseBreakWater); + CoreCloneAssert.AreObjectClones(original.BreakWater, clone.BreakWater, AreClones); + Assert.AreEqual(original.UseForeshore, clone.UseForeshore); + } } } \ No newline at end of file