Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsCalculation.cs
===================================================================
diff -u -rd619624819b7200ac55b357b0a0c54d198fc20e4 -r2bdb4415eafe18b5780dbc32408a7317d7b537e6
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsCalculation.cs (.../MacroStabilityInwardsCalculation.cs) (revision d619624819b7200ac55b357b0a0c54d198fc20e4)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsCalculation.cs (.../MacroStabilityInwardsCalculation.cs) (revision 2bdb4415eafe18b5780dbc32408a7317d7b537e6)
@@ -19,7 +19,6 @@
// 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;
@@ -30,7 +29,7 @@
///
/// This class holds information about a calculation for the .
///
- public class MacroStabilityInwardsCalculation : Observable, ICalculation
+ public class MacroStabilityInwardsCalculation : CloneableObservable, ICalculation
{
///
/// Creates a new instance of with default values set for some of the parameters.
@@ -45,7 +44,7 @@
///
/// Gets the input parameters to perform a macro stability inwards calculation with.
///
- public MacroStabilityInwardsInput InputParameters { get; }
+ public MacroStabilityInwardsInput InputParameters { get; private set; }
///
/// Gets or sets , which contains the results of a macro stability inwards calculation.
@@ -67,17 +66,31 @@
}
}
- public Comment Comments { get; }
+ public Comment Comments { get; private set; }
public void ClearOutput()
{
Output = null;
SemiProbabilisticOutput = null;
}
- public object Clone()
+ public override object Clone()
{
- throw new NotImplementedException();
+ var clone = (MacroStabilityInwardsCalculation) base.Clone();
+ clone.Comments = (Comment) Comments.Clone();
+ clone.InputParameters = (MacroStabilityInwardsInput) InputParameters.Clone();
+
+ if (Output != null)
+ {
+ clone.Output = (MacroStabilityInwardsOutput) Output.Clone();
+ }
+
+ if (SemiProbabilisticOutput != null)
+ {
+ clone.SemiProbabilisticOutput = (MacroStabilityInwardsSemiProbabilisticOutput) SemiProbabilisticOutput.Clone();
+ }
+
+ return clone;
}
}
}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsCalculationScenarioTest.cs
===================================================================
diff -u -rb2f4b307c254c747a5cf01d2fb94970e5e954c36 -r2bdb4415eafe18b5780dbc32408a7317d7b537e6
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsCalculationScenarioTest.cs (.../MacroStabilityInwardsCalculationScenarioTest.cs) (revision b2f4b307c254c747a5cf01d2fb94970e5e954c36)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsCalculationScenarioTest.cs (.../MacroStabilityInwardsCalculationScenarioTest.cs) (revision 2bdb4415eafe18b5780dbc32408a7317d7b537e6)
@@ -21,6 +21,8 @@
using System;
using Core.Common.Base.Data;
+using Core.Common.Data.TestUtil;
+using Core.Common.TestUtil;
using NUnit.Framework;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.MacroStabilityInwards.Data.TestUtil;
@@ -175,5 +177,29 @@
// Assert
Assert.AreEqual(CalculationScenarioStatus.Done, status);
}
+
+ [Test]
+ public void Clone_WithRandomValues_ReturnsCopiedInstanceWithPropertiesSet()
+ {
+ // Setup
+ MacroStabilityInwardsCalculationScenario original = CreateRandomCalculationScenarioWithoutOutput();
+
+ // Call
+ object clone = original.Clone();
+
+ // Assert
+ CoreCloneAssert.AreObjectClones(original, clone, MacroStabilityInwardsCloneAssert.AreClones);
+ }
+
+ private static MacroStabilityInwardsCalculationScenario CreateRandomCalculationScenarioWithoutOutput()
+ {
+ var random = new Random(21);
+
+ return new MacroStabilityInwardsCalculationScenario
+ {
+ IsRelevant = random.NextBoolean(),
+ Contribution = random.NextRoundedDouble()
+ };
+ }
}
}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsCalculationTest.cs
===================================================================
diff -u -rb2f4b307c254c747a5cf01d2fb94970e5e954c36 -r2bdb4415eafe18b5780dbc32408a7317d7b537e6
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsCalculationTest.cs (.../MacroStabilityInwardsCalculationTest.cs) (revision b2f4b307c254c747a5cf01d2fb94970e5e954c36)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsCalculationTest.cs (.../MacroStabilityInwardsCalculationTest.cs) (revision 2bdb4415eafe18b5780dbc32408a7317d7b537e6)
@@ -19,7 +19,10 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using Core.Common.Base;
+using Core.Common.Data.TestUtil;
+using Core.Common.TestUtil;
using NUnit.Framework;
using Rhino.Mocks;
using Ringtoets.Common.Data.Calculation;
@@ -46,6 +49,7 @@
// Assert
Assert.IsInstanceOf(calculation);
+ Assert.IsInstanceOf(calculation);
Assert.AreEqual("Nieuwe berekening", calculation.Name);
@@ -215,5 +219,54 @@
// Assert
Assert.IsTrue(calculationHasOutput);
}
+
+ [Test]
+ public void Clone_NoOutput_ReturnNewInstanceWithCopiedValues()
+ {
+ // Setup
+ MacroStabilityInwardsCalculation original = CreateRandomCalculationWithoutOutput();
+
+ // Call
+ object clone = original.Clone();
+
+ // Assert
+ CoreCloneAssert.AreObjectClones(original, clone, MacroStabilityInwardsCloneAssert.AreClones);
+ }
+
+ [Test]
+ public void Clone_WithOutput_ReturnNewInstanceWithCopiedValues()
+ {
+ // Setup
+ MacroStabilityInwardsCalculation original = CreateRandomCalculationWithoutOutput();
+ original.SemiProbabilisticOutput = MacroStabilityInwardsSemiProbabilisticOutputTestFactory.CreateOutput();
+ original.Output = MacroStabilityInwardsOutputTestFactory.CreateOutput();
+
+ // Call
+ object clone = original.Clone();
+
+ // Assert
+ CoreCloneAssert.AreObjectClones(original, clone, MacroStabilityInwardsCloneAssert.AreClones);
+ }
+
+ private static MacroStabilityInwardsCalculation CreateRandomCalculationWithoutOutput()
+ {
+ var random = new Random(21);
+
+ return new MacroStabilityInwardsCalculation
+ {
+ Name = "A Name",
+ Comments =
+ {
+ Body = "A comment"
+ },
+ InputParameters =
+ {
+ SlipPlaneMinimumDepth = random.NextRoundedDouble(),
+ SlipPlaneMinimumLength = random.NextRoundedDouble(),
+ MaximumSliceWidth = random.NextRoundedDouble(),
+ MoveGrid = random.NextBoolean()
+ }
+ };
+ }
}
}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/MacroStabilityInwardsSemiProbabilisticTestFactoryTest.cs
===================================================================
diff -u -rc4c3d9ffd55bea465d56419d1e6ddbfe35fe355a -r2bdb4415eafe18b5780dbc32408a7317d7b537e6
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/MacroStabilityInwardsSemiProbabilisticTestFactoryTest.cs (.../MacroStabilityInwardsSemiProbabilisticTestFactoryTest.cs) (revision c4c3d9ffd55bea465d56419d1e6ddbfe35fe355a)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/MacroStabilityInwardsSemiProbabilisticTestFactoryTest.cs (.../MacroStabilityInwardsSemiProbabilisticTestFactoryTest.cs) (revision 2bdb4415eafe18b5780dbc32408a7317d7b537e6)
@@ -52,7 +52,7 @@
{
// Setup
var random = new Random(21);
- var probability = random.NextDouble();
+ double probability = random.NextDouble();
// Call
MacroStabilityInwardsSemiProbabilisticOutput output = MacroStabilityInwardsSemiProbabilisticOutputTestFactory.CreateOutput(probability);
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/MacroStabilityInwardsCloneAssert.cs
===================================================================
diff -u -r6c09ce8d05935f9056bfd3a811da825326135472 -r2bdb4415eafe18b5780dbc32408a7317d7b537e6
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/MacroStabilityInwardsCloneAssert.cs (.../MacroStabilityInwardsCloneAssert.cs) (revision 6c09ce8d05935f9056bfd3a811da825326135472)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/MacroStabilityInwardsCloneAssert.cs (.../MacroStabilityInwardsCloneAssert.cs) (revision 2bdb4415eafe18b5780dbc32408a7317d7b537e6)
@@ -39,6 +39,22 @@
/// The cloned object.
/// Thrown when and
/// are not clones.
+ public static void AreClones(MacroStabilityInwardsCalculationScenario original,
+ MacroStabilityInwardsCalculationScenario clone)
+ {
+ Assert.AreEqual(original.Contribution, clone.Contribution);
+ Assert.AreEqual(original.IsRelevant, clone.IsRelevant);
+ AreClones((MacroStabilityInwardsCalculation) original, clone);
+ }
+
+ ///
+ /// Method that asserts whether and
+ /// are clones.
+ ///
+ /// The original object.
+ /// The cloned object.
+ /// Thrown when and
+ /// are not clones.
public static void AreClones(MacroStabilityInwardsCalculation original,
MacroStabilityInwardsCalculation clone)
{