Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/GeneralPipingInput.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/GeneralPipingInput.cs (.../GeneralPipingInput.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/GeneralPipingInput.cs (.../GeneralPipingInput.cs) (revision 3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742) @@ -56,7 +56,7 @@ /// /// Gets the critical exit gradient for heave. /// - public double CriticalHeaveGradient { get; private set; } + public double CriticalHeaveGradient { get; } #endregion @@ -98,12 +98,12 @@ /// /// Gets the calculation value used to account for uncertainty in the model for uplift. /// - public double UpliftModelFactor { get; private set; } + public double UpliftModelFactor { get; } /// /// Gets the calculation value used to account for uncertainty in the model for Sellmeijer. /// - public double SellmeijerModelFactor { get; private set; } + public double SellmeijerModelFactor { get; } #endregion @@ -125,38 +125,38 @@ /// /// Gets the White's drag coefficient. /// - public double WhitesDragCoefficient { get; private set; } + public double WhitesDragCoefficient { get; } /// /// Gets the angle of the force balance representing the amount in which sand /// grains resist rolling. /// [°] /// - public double BeddingAngle { get; private set; } + public double BeddingAngle { get; } /// /// Gets the kinematic viscosity of water at 10 °C. /// [m²/s] /// - public double WaterKinematicViscosity { get; private set; } + public double WaterKinematicViscosity { get; } /// /// Gets the gravitational acceleration. /// [m/s²] /// - public double Gravity { get; private set; } + public double Gravity { get; } /// /// Gets the mean diameter of small scale tests applied to different kinds of sand, /// on which the formula of Sellmeijer has been fit. /// [m] /// - public double MeanDiameter70 { get; private set; } + public double MeanDiameter70 { get; } /// /// Gets the reduction factor Sellmeijer. /// - public double SellmeijerReductionFactor { get; private set; } + public double SellmeijerReductionFactor { get; } #endregion } Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingCalculation.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingCalculation.cs (.../PipingCalculation.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingCalculation.cs (.../PipingCalculation.cs) (revision 3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742) @@ -30,7 +30,7 @@ /// /// This class holds information about a calculation for the . /// - public class PipingCalculation : Observable, ICalculation + public class PipingCalculation : Observable, ICalculation, ICloneable { /// /// Creates a new instance of with default values set for some of the parameters. @@ -70,12 +70,32 @@ } } - public Comment Comments { get; } + public Comment Comments { get; private set; } public void ClearOutput() { Output = null; SemiProbabilisticOutput = null; } + + public object Clone() + { + var clone = (PipingCalculation) MemberwiseClone(); + + clone.Comments = (Comment) Comments.Clone(); + clone.InputParameters = (PipingInput) InputParameters.Clone(); + + if (Output != null) + { + clone.Output = (PipingOutput) Output.Clone(); + } + + if (SemiProbabilisticOutput != null) + { + clone.SemiProbabilisticOutput = (PipingSemiProbabilisticOutput) SemiProbabilisticOutput.Clone(); + } + + return clone; + } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingInput.cs =================================================================== diff -u -r26f527fb809a2325c8f883ece9da01a8f8040eb3 -r3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingInput.cs (.../PipingInput.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingInput.cs (.../PipingInput.cs) (revision 3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742) @@ -38,7 +38,7 @@ /// Class that holds all piping calculation specific input parameters, i.e. the values /// that can differ across various calculations. /// - public class PipingInput : Observable, ICalculationInput + public class PipingInput : Observable, ICalculationInput, ICloneable { private readonly GeneralPipingInput generalInputParameters; private readonly NormalDistribution phreaticLevelExit; @@ -266,6 +266,11 @@ } } + public object Clone() + { + return MemberwiseClone(); + } + private void GetEntryExitPointFromSurfaceLine(out double tempEntryPointL, out double tempExitPointL) { int entryPointIndex = Array.IndexOf(SurfaceLine.Points, SurfaceLine.DikeToeAtRiver); Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingOutput.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingOutput.cs (.../PipingOutput.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingOutput.cs (.../PipingOutput.cs) (revision 3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742) @@ -29,7 +29,7 @@ /// /// Simple class containing the results of a Piping calculation. /// - public class PipingOutput : Observable, ICalculationOutput + public class PipingOutput : Observable, ICalculationOutput, ICloneable { /// /// Creates a new instance of . @@ -60,58 +60,63 @@ /// /// Gets the calculated z-value for the uplift sub calculation. /// - public double UpliftZValue { get; private set; } + public double UpliftZValue { get; } /// /// Gets the factor of safety for the uplift sub calculation. /// - public double UpliftFactorOfSafety { get; private set; } + public double UpliftFactorOfSafety { get; } /// /// Gets the calculated z-value for the heave sub calculation. /// - public double HeaveZValue { get; private set; } + public double HeaveZValue { get; } /// /// Gets the factor of safety for the heave sub calculation. /// - public double HeaveFactorOfSafety { get; private set; } + public double HeaveFactorOfSafety { get; } /// /// Gets the calculated z-value for the Sellmeijer sub calculation. /// - public double SellmeijerZValue { get; private set; } + public double SellmeijerZValue { get; } /// /// Gets the factor of safety for the Sellmeijer sub calculation. /// - public double SellmeijerFactorOfSafety { get; private set; } + public double SellmeijerFactorOfSafety { get; } /// /// Gets the effective stress that was calculated for the uplift sub calculation. /// - public RoundedDouble UpliftEffectiveStress { get; private set; } + public RoundedDouble UpliftEffectiveStress { get; } /// /// Gets the gradient that was calculated for the heave sub calculation. /// - public RoundedDouble HeaveGradient { get; private set; } + public RoundedDouble HeaveGradient { get; } /// /// Gets the creep coefficient that was calculated for the Sellmeijer sub calculation. /// - public RoundedDouble SellmeijerCreepCoefficient { get; private set; } + public RoundedDouble SellmeijerCreepCoefficient { get; } /// /// Gets the critical fall that was calculated for the Sellmeijer sub calculation. /// - public RoundedDouble SellmeijerCriticalFall { get; private set; } + public RoundedDouble SellmeijerCriticalFall { get; } /// /// Gets the reduced fall that was calculated for the Sellmeijer sub calculation. /// - public RoundedDouble SellmeijerReducedFall { get; private set; } + public RoundedDouble SellmeijerReducedFall { get; } + public object Clone() + { + return MemberwiseClone(); + } + /// /// Container for properties for constructing a . /// Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingSemiProbabilisticOutput.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingSemiProbabilisticOutput.cs (.../PipingSemiProbabilisticOutput.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingSemiProbabilisticOutput.cs (.../PipingSemiProbabilisticOutput.cs) (revision 3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742) @@ -29,7 +29,7 @@ /// This class contains the results of a semi-probabilistic assessment of the piping /// failure mechanism. /// - public class PipingSemiProbabilisticOutput + public class PipingSemiProbabilisticOutput : ICloneable { private double requiredProbability; private double pipingProbability; @@ -102,19 +102,19 @@ /// Get the required reliability of the piping failure mechanism, /// which is a value greater than 0. /// - public RoundedDouble RequiredReliability { get; private set; } + public RoundedDouble RequiredReliability { get; } /// /// Gets the factor of safety of the piping failure mechanism, /// which is a value greater than 0. /// - public RoundedDouble PipingFactorOfSafety { get; private set; } + public RoundedDouble PipingFactorOfSafety { get; } /// /// Gets the reliability of the piping failure mechanism, /// which is a value greater than 0. /// - public RoundedDouble PipingReliability { get; private set; } + public RoundedDouble PipingReliability { get; } /// /// Gets the probability of failing due to the piping failure mechanism, @@ -139,13 +139,13 @@ /// Gets the factor of safety for the uplift sub-mechanism, /// which is a value greater than 0. /// - public RoundedDouble UpliftFactorOfSafety { get; private set; } + public RoundedDouble UpliftFactorOfSafety { get; } /// /// Gets the reliability for the uplift sub-mechanism, /// which is a value greater than 0. /// - public RoundedDouble UpliftReliability { get; private set; } + public RoundedDouble UpliftReliability { get; } /// /// Gets the probability of failing due to the uplift failure sub-mechanism, @@ -170,13 +170,13 @@ /// Gets the factor of safety for the heave sub-mechanism, /// which is a value greater than 0. /// - public RoundedDouble HeaveFactorOfSafety { get; private set; } + public RoundedDouble HeaveFactorOfSafety { get; } /// /// Gets the reliability for the heave sub-mechanism, /// which is a value greater than 0. /// - public RoundedDouble HeaveReliability { get; private set; } + public RoundedDouble HeaveReliability { get; } /// /// Gets the probability of failing due to the heave failure sub-mechanism, @@ -201,13 +201,13 @@ /// Gets the factor of safety for the Sellmeijer sub-mechanism, /// which is a value greater than 0. /// - public RoundedDouble SellmeijerFactorOfSafety { get; private set; } + public RoundedDouble SellmeijerFactorOfSafety { get; } /// /// Gets the reliability for the Sellmeijer sub-mechanism, /// which is a value greater than 0. /// - public RoundedDouble SellmeijerReliability { get; private set; } + public RoundedDouble SellmeijerReliability { get; } /// /// Gets the probability of failing due to the Sellmeijer failure sub-mechanism, @@ -227,5 +227,10 @@ sellmeijerProbability = value; } } + + public object Clone() + { + return MemberwiseClone(); + } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs =================================================================== diff -u -r26f527fb809a2325c8f883ece9da01a8f8040eb3 -r3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742) @@ -716,6 +716,8 @@ return builder.AddExportItem() .AddSeparator() + .AddDuplicateCalculationItem(calculation, nodeData) + .AddSeparator() .AddRenameItem() .AddCustomItem(updateEntryAndExitPoint) .AddSeparator() Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingCalculationTest.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingCalculationTest.cs (.../PipingCalculationTest.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingCalculationTest.cs (.../PipingCalculationTest.cs) (revision 3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742) @@ -21,11 +21,20 @@ using System; using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.KernelWrapper.TestUtil; +using Ringtoets.Piping.Primitives; +using CoreCloneAssert = Core.Common.Data.TestUtil.CloneAssert; +using PipingCloneAssert = Ringtoets.Piping.Data.TestUtil.CloneAssert; namespace Ringtoets.Piping.Data.Test { @@ -51,6 +60,7 @@ // Assert Assert.IsInstanceOf(calculation); + Assert.IsInstanceOf(calculation); Assert.AreEqual("Nieuwe berekening", calculation.Name); @@ -230,5 +240,51 @@ // Assert Assert.IsTrue(calculationHasOutput); } + + [Test] + public void Clone_AllPropertiesSet_ReturnNewInstanceWithCopiedValues() + { + // Setup + PipingCalculation original = CreateRandomCalculationWithoutOutput(); + + original.Output = new TestPipingOutput(); + + // Call + object clone = original.Clone(); + + // Assert + CoreCloneAssert.AreObjectClones(original, clone, PipingCloneAssert.AreClones); + } + + [Test] + public void Clone_NotAllPropertiesSet_ReturnNewInstanceWithCopiedValues() + { + // Setup + PipingCalculation original = CreateRandomCalculationWithoutOutput(); + + original.InputParameters.HydraulicBoundaryLocation = null; + original.InputParameters.StochasticSoilModel = null; + + // Call + object clone = original.Clone(); + + // Assert + CoreCloneAssert.AreObjectClones(original, clone, PipingCloneAssert.AreClones); + } + + private static PipingCalculation CreateRandomCalculationWithoutOutput() + { + var calculation = new PipingCalculation(new GeneralPipingInput()) + { + Comments = + { + Body = "Random body" + } + }; + + PipingTestDataGenerator.SetRandomDataToGrassCoverErosionInwardsInput(calculation.InputParameters); + + return calculation; + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs =================================================================== diff -u -rad0f4a7a0f8b9f065da77eda1a450ac3696b8f7f -r3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs (.../PipingInputTest.cs) (revision ad0f4a7a0f8b9f065da77eda1a450ac3696b8f7f) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs (.../PipingInputTest.cs) (revision 3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742) @@ -35,6 +35,8 @@ using Ringtoets.Piping.KernelWrapper.SubCalculator; using Ringtoets.Piping.KernelWrapper.TestUtil.SubCalculator; using Ringtoets.Piping.Primitives; +using CoreCloneAssert = Core.Common.Data.TestUtil.CloneAssert; +using PipingCloneAssert = Ringtoets.Piping.Data.TestUtil.CloneAssert; namespace Ringtoets.Piping.Data.Test { @@ -119,6 +121,7 @@ // Assert Assert.IsInstanceOf(inputParameters); Assert.IsInstanceOf(inputParameters); + Assert.IsInstanceOf(inputParameters); DistributionAssert.AreEqual(phreaticLevelExit, inputParameters.PhreaticLevelExit); DistributionAssert.AreEqual(dampingFactorExit, inputParameters.DampingFactorExit); @@ -1266,6 +1269,39 @@ Assert.AreEqual(0.1, seepageLength.CoefficientOfVariation); } + [Test] + public void Clone_AllPropertiesSet_ReturnNewInstanceWithCopiedValues() + { + // Setup + var original = new PipingInput(new GeneralPipingInput()); + + PipingTestDataGenerator.SetRandomDataToGrassCoverErosionInwardsInput(original); + + // Call + object clone = original.Clone(); + + // Assert + CoreCloneAssert.AreObjectClones(original, clone, PipingCloneAssert.AreClones); + } + + [Test] + public void Clone_NotAllPropertiesSet_ReturnNewInstanceWithCopiedValues() + { + // Setup + var original = new PipingInput(new GeneralPipingInput()); + + PipingTestDataGenerator.SetRandomDataToGrassCoverErosionInwardsInput(original); + + original.StochasticSoilModel = null; + original.HydraulicBoundaryLocation = null; + + // Call + object clone = original.Clone(); + + // Assert + CoreCloneAssert.AreObjectClones(original, clone, PipingCloneAssert.AreClones); + } + private static PipingSurfaceLine CreateSurfaceLine() { var surfaceLine = new PipingSurfaceLine(); Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingOutputTest.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingOutputTest.cs (.../PipingOutputTest.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingOutputTest.cs (.../PipingOutputTest.cs) (revision 3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742) @@ -24,6 +24,8 @@ using NUnit.Framework; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.TestUtil; +using CoreCloneAssert = Core.Common.Data.TestUtil.CloneAssert; +using PipingCloneAssert = Ringtoets.Piping.Data.TestUtil.CloneAssert; namespace Ringtoets.Piping.Data.Test { @@ -94,6 +96,7 @@ Assert.IsInstanceOf(output); Assert.IsInstanceOf(output); + Assert.IsInstanceOf(output); Assert.AreEqual(zuValue, output.UpliftZValue); Assert.AreEqual(foSuValue, output.UpliftFactorOfSafety); @@ -113,5 +116,43 @@ Assert.AreEqual(2, output.SellmeijerReducedFall.NumberOfDecimalPlaces); Assert.AreEqual(sellmeijerReducedFall, output.SellmeijerReducedFall, output.SellmeijerReducedFall.GetAccuracy()); } + + [Test] + public void Clone_AllPropertiesSet_ReturnNewInstanceWithCopiedValues() + { + // Setup + var original = GetRandomPipingOutput(); + + // Call + object clone = original.Clone(); + + // Assert + CoreCloneAssert.AreObjectClones(original, clone, PipingCloneAssert.AreClones); + } + + private PipingOutput GetRandomPipingOutput() + { + var random = new Random(22); + double zuValue = random.NextDouble(); + double foSuValue = random.NextDouble(); + double zhValue = random.NextDouble(); + double foShValue = random.NextDouble(); + double zsValue = random.NextDouble(); + double foSsValue = random.NextDouble(); + double upliftEffectiveStress = random.NextDouble(); + double heaveGradient = random.NextDouble(); + + return new PipingOutput(new PipingOutput.ConstructionProperties + { + UpliftZValue = zuValue, + UpliftFactorOfSafety = foSuValue, + HeaveZValue = zhValue, + HeaveFactorOfSafety = foShValue, + SellmeijerZValue = zsValue, + SellmeijerFactorOfSafety = foSsValue, + UpliftEffectiveStress = upliftEffectiveStress, + HeaveGradient = heaveGradient + }); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSemiProbabilisticOutputTest.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSemiProbabilisticOutputTest.cs (.../PipingSemiProbabilisticOutputTest.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSemiProbabilisticOutputTest.cs (.../PipingSemiProbabilisticOutputTest.cs) (revision 3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742) @@ -23,6 +23,8 @@ using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.TestUtil; +using CoreCloneAssert = Core.Common.Data.TestUtil.CloneAssert; +using PipingCloneAssert = Ringtoets.Piping.Data.TestUtil.CloneAssert; namespace Ringtoets.Piping.Data.Test { @@ -67,6 +69,8 @@ pipingFactorOfSafety); // Assert + Assert.IsInstanceOf(output); + Assert.AreEqual(3, output.HeaveFactorOfSafety.NumberOfDecimalPlaces); Assert.AreEqual(upliftFactorOfSafety, output.UpliftFactorOfSafety, output.UpliftFactorOfSafety.GetAccuracy()); Assert.AreEqual(5, output.UpliftReliability.NumberOfDecimalPlaces); @@ -551,5 +555,53 @@ const string expectedMessage = "Kans moet in het bereik [0,0, 1,0] liggen."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); } + + [Test] + public void Clone_AllPropertiesSet_ReturnNewInstanceWithCopiedValues() + { + // Setup + PipingSemiProbabilisticOutput original = GetRandomPipingSemiProbabilisticOutput(); + + // Call + object clone = original.Clone(); + + // Assert + CoreCloneAssert.AreObjectClones(original, clone, PipingCloneAssert.AreClones); + } + + private PipingSemiProbabilisticOutput GetRandomPipingSemiProbabilisticOutput() + { + var random = new Random(21); + double upliftFactorOfSafety = random.NextDouble(); + double upliftReliability = random.NextDouble(); + double upliftProbability = random.NextDouble(); + double heaveFactorOfSafety = random.NextDouble(); + double heaveReliability = random.NextDouble(); + double heaveProbability = random.NextDouble(); + double sellmeijerFactorOfSafety = random.NextDouble(); + double sellmeijerReliability = random.NextDouble(); + double sellmeijerProbability = random.NextDouble(); + double requiredProbability = random.NextDouble(); + double requiredReliability = random.NextDouble(); + double pipingProbability = random.NextDouble(); + double pipingReliability = random.NextDouble(); + double pipingFactorOfSafety = random.NextDouble(); + + return new PipingSemiProbabilisticOutput( + upliftFactorOfSafety, + upliftReliability, + upliftProbability, + heaveFactorOfSafety, + heaveReliability, + heaveProbability, + sellmeijerFactorOfSafety, + sellmeijerReliability, + sellmeijerProbability, + requiredProbability, + requiredReliability, + pipingProbability, + pipingReliability, + pipingFactorOfSafety); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj =================================================================== diff -u -r7b7bd75dc1c1327386c9be96b5d480565bb8ecd6 -r3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj (.../Ringtoets.Piping.Data.Test.csproj) (revision 7b7bd75dc1c1327386c9be96b5d480565bb8ecd6) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj (.../Ringtoets.Piping.Data.Test.csproj) (revision 3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742) @@ -83,6 +83,10 @@ {3bbfd65b-b277-4e50-ae6d-bd24c3434609} Core.Common.Base + + {0b0d2dff-7e7e-4bb0-a007-61800c85809a} + Core.Common.Data.TestUtil + {D749EE4C-CE50-4C17-BF01-9A953028C126} Core.Common.TestUtil Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/CloneAssert.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/CloneAssert.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/CloneAssert.cs (revision 3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742) @@ -0,0 +1,123 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using NUnit.Framework; +using Ringtoets.Common.Data.TestUtil; +using CoreCloneAssert = Core.Common.Data.TestUtil.CloneAssert; +using CommonCloneAssert = Ringtoets.Common.Data.TestUtil.CloneAssert; + +namespace Ringtoets.Piping.Data.TestUtil +{ + /// + /// Class that defines methods for asserting whether two objects are clones. + /// + public static class CloneAssert + { + /// + /// Method that asserts whether and + /// are clones. + /// + /// The original object. + /// The cloned object. + /// Thrown when and + /// are not clones. + public static void AreClones(PipingOutput original, PipingOutput clone) + { + Assert.AreEqual(original.UpliftZValue, clone.UpliftZValue); + Assert.AreEqual(original.UpliftFactorOfSafety, clone.UpliftFactorOfSafety); + Assert.AreEqual(original.HeaveZValue, clone.HeaveZValue); + Assert.AreEqual(original.HeaveFactorOfSafety, clone.HeaveFactorOfSafety); + Assert.AreEqual(original.SellmeijerZValue, clone.SellmeijerZValue); + Assert.AreEqual(original.UpliftEffectiveStress, clone.UpliftEffectiveStress); + Assert.AreEqual(original.HeaveGradient, clone.HeaveGradient); + Assert.AreEqual(original.SellmeijerCreepCoefficient, clone.SellmeijerCreepCoefficient); + Assert.AreEqual(original.SellmeijerCriticalFall, clone.SellmeijerCriticalFall); + Assert.AreEqual(original.SellmeijerReducedFall, clone.SellmeijerReducedFall); + } + + /// + /// Method that asserts whether and + /// are clones. + /// + /// The original object. + /// The cloned object. + /// Thrown when and + /// are not clones. + public static void AreClones(PipingSemiProbabilisticOutput original, PipingSemiProbabilisticOutput clone) + { + Assert.AreEqual(original.UpliftProbability, clone.UpliftProbability); + Assert.AreEqual(original.UpliftReliability, clone.UpliftReliability); + Assert.AreEqual(original.UpliftFactorOfSafety, clone.UpliftFactorOfSafety); + Assert.AreEqual(original.HeaveProbability, clone.HeaveProbability); + Assert.AreEqual(original.HeaveReliability, clone.HeaveReliability); + Assert.AreEqual(original.HeaveFactorOfSafety, clone.HeaveFactorOfSafety); + Assert.AreEqual(original.SellmeijerFactorOfSafety, clone.SellmeijerFactorOfSafety); + Assert.AreEqual(original.SellmeijerProbability, clone.SellmeijerProbability); + Assert.AreEqual(original.SellmeijerReliability, clone.SellmeijerReliability); + Assert.AreEqual(original.RequiredProbability, clone.RequiredProbability); + Assert.AreEqual(original.RequiredReliability, clone.RequiredReliability); + Assert.AreEqual(original.PipingProbability, clone.PipingProbability); + Assert.AreEqual(original.PipingReliability, clone.PipingReliability); + Assert.AreEqual(original.PipingFactorOfSafety, clone.PipingFactorOfSafety); + } + + /// + /// Method that asserts whether and + /// are clones. + /// + /// The original object. + /// The cloned object. + /// Thrown when and + /// are not clones. + public static void AreClones(PipingInput original, PipingInput clone) + { + Assert.AreEqual(original.EntryPointL, clone.EntryPointL); + Assert.AreEqual(original.ExitPointL, clone.ExitPointL); + Assert.AreEqual(original.PhreaticLevelExit, clone.PhreaticLevelExit); + Assert.AreEqual(original.DampingFactorExit, clone.DampingFactorExit); + Assert.AreEqual(original.AssessmentLevel, clone.AssessmentLevel); + Assert.AreEqual(original.UseAssessmentLevelManualInput, clone.UseAssessmentLevelManualInput); + Assert.AreSame(original.SurfaceLine, clone.SurfaceLine); + Assert.AreSame(original.StochasticSoilModel, clone.StochasticSoilModel); + Assert.AreSame(original.StochasticSoilProfile, clone.StochasticSoilProfile); + Assert.AreSame(original.HydraulicBoundaryLocation, clone.HydraulicBoundaryLocation); + + } + + /// + /// Method that asserts whether and + /// are clones. + /// + /// The original object. + /// The cloned object. + /// Thrown when and + /// are not clones. + public static void AreClones(PipingCalculation original, PipingCalculation clone) + { + Assert.AreEqual(original.Name, clone.Name); + CoreCloneAssert.AreObjectClones(original.Comments, clone.Comments, CommonCloneAssert.AreClones); + CoreCloneAssert.AreObjectClones(original.InputParameters, clone.InputParameters, AreClones); + CoreCloneAssert.AreObjectClones(original.Output, clone.Output, AreClones); + CoreCloneAssert.AreObjectClones(original.SemiProbabilisticOutput, clone.SemiProbabilisticOutput, AreClones); + + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingTestDataGenerator.cs =================================================================== diff -u -rad0f4a7a0f8b9f065da77eda1a450ac3696b8f7f -r3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingTestDataGenerator.cs (.../PipingTestDataGenerator.cs) (revision ad0f4a7a0f8b9f065da77eda1a450ac3696b8f7f) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingTestDataGenerator.cs (.../PipingTestDataGenerator.cs) (revision 3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742) @@ -19,11 +19,14 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Core.Common.Base.Data; using Core.Common.Base.Geometry; +using Core.Common.TestUtil; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Primitives; @@ -407,5 +410,32 @@ } }); } + + /// + /// This method sets random data values to all properties of . + /// + /// The input to set the random data values to. + public static void SetRandomDataToGrassCoverErosionInwardsInput(PipingInput input) + { + var random = new Random(21); + + var surfaceLine = new PipingSurfaceLine(); + surfaceLine.SetGeometry(new[] + { + new Point3D(random.Next(0, 5), random.Next(0, 5), random.Next(0, 5)), + new Point3D(random.Next(5, 10), random.Next(5, 10), random.Next(5, 10)) + }); + + input.EntryPointL = random.NextRoundedDouble(); + input.ExitPointL = random.NextRoundedDouble(); + input.SurfaceLine = surfaceLine; + input.StochasticSoilModel = new PipingStochasticSoilModel("model"); + input.StochasticSoilProfile = new PipingStochasticSoilProfile(random.NextDouble(), new TestPipingSoilProfile()); + input.HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + input.UseAssessmentLevelManualInput = true; + input.AssessmentLevel = random.NextRoundedDouble(); + input.PhreaticLevelExit = new NormalDistribution(); + input.DampingFactorExit = new LogNormalDistribution(); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/Ringtoets.Piping.Data.TestUtil.csproj =================================================================== diff -u -r7b7bd75dc1c1327386c9be96b5d480565bb8ecd6 -r3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/Ringtoets.Piping.Data.TestUtil.csproj (.../Ringtoets.Piping.Data.TestUtil.csproj) (revision 7b7bd75dc1c1327386c9be96b5d480565bb8ecd6) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/Ringtoets.Piping.Data.TestUtil.csproj (.../Ringtoets.Piping.Data.TestUtil.csproj) (revision 3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742) @@ -50,6 +50,7 @@ Properties\GlobalAssembly.cs + @@ -65,6 +66,14 @@ {3bbfd65b-b277-4e50-ae6d-bd24c3434609} Core.Common.Base + + {0b0d2dff-7e7e-4bb0-a007-61800c85809a} + Core.Common.Data.TestUtil + + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + {d4200f43-3f72-4f42-af0a-8ced416a38ec} Ringtoets.Common.Data Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs =================================================================== diff -u -r26f527fb809a2325c8f883ece9da01a8f8040eb3 -r3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs (.../PipingCalculationScenarioContextTreeNodeInfoTest.cs) (revision 26f527fb809a2325c8f883ece9da01a8f8040eb3) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs (.../PipingCalculationScenarioContextTreeNodeInfoTest.cs) (revision 3cf4d4c65cf2ce285bdeb71162cf3b0a79cb3742) @@ -55,31 +55,16 @@ [TestFixture] public class PipingCalculationScenarioContextTreeNodeInfoTest : NUnitFormTest { - private const int contextMenuUpdateEntryAndExitPointIndex = 3; + private const int contextMenuDuplicateIndex = 2; + private const int contextMenuUpdateEntryAndExitPointIndex = 5; + private const int contextMenuValidateIndex = 7; + private const int contextMenuCalculateIndex = 8; + private const int contextMenuClearIndex = 10; - private const int contextMenuValidateIndex = 5; - private const int contextMenuCalculateIndex = 6; - private const int contextMenuClearIndex = 8; - private MockRepository mocks; private PipingPlugin plugin; private TreeNodeInfo info; - public override void Setup() - { - mocks = new MockRepository(); - plugin = new PipingPlugin(); - info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(PipingCalculationScenarioContext)); - } - - public override void TearDown() - { - plugin.Dispose(); - mocks.VerifyAll(); - - base.TearDown(); - } - [Test] public void Initialized_Always_ExpectedPropertiesSet() { @@ -357,6 +342,68 @@ } [Test] + public void ContextMenuStrip_Always_AddsCustomitems() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var pipingFailureMechanism = new TestPipingFailureMechanism(); + var assessmentSection = mocks.Stub(); + var nodeData = new PipingCalculationScenarioContext(new PipingCalculationScenario(new GeneralPipingInput()), + new CalculationGroup(), + Enumerable.Empty(), + Enumerable.Empty(), + pipingFailureMechanism, + assessmentSection); + + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + Assert.AreEqual(17, contextMenu.Items.Count); + + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + contextMenuDuplicateIndex, + "&Dupliceren", + "Dupliceer deze berekening.", + RingtoetsCommonFormsResources.CopyHS); + + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + contextMenuUpdateEntryAndExitPointIndex, + "&Bijwerken intrede- en uittredepunt...", + "Er moet een profielschematisatie geselecteerd zijn.", + RingtoetsCommonFormsResources.UpdateItemIcon, + false); + + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + contextMenuValidateIndex, + "&Valideren", + "Valideer de invoer voor deze berekening.", + RingtoetsCommonFormsResources.ValidateIcon); + + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + contextMenuCalculateIndex, + "Be&rekenen", + "Voer deze berekening uit.", + RingtoetsCommonFormsResources.CalculateIcon); + + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + contextMenuClearIndex, + "&Wis uitvoer...", + "Deze berekening heeft geen uitvoer om te wissen.", + RingtoetsCommonFormsResources.ClearIcon, + false); + } + } + } + + [Test] public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() { // Setup @@ -376,6 +423,8 @@ { menuBuilder.Expect(mb => mb.AddExportItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddRenameItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); @@ -1067,6 +1116,21 @@ } } + public override void Setup() + { + mocks = new MockRepository(); + plugin = new PipingPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(PipingCalculationScenarioContext)); + } + + public override void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + + base.TearDown(); + } + private static void ChangeSurfaceLine(PipingSurfaceLine surfaceLine) { surfaceLine.SetGeometry(new[]