Index: Riskeer/Piping/src/Riskeer.Piping.Forms/PresentationObjects/ProbabilisticPipingCalculationContext.cs
===================================================================
diff -u
--- Riskeer/Piping/src/Riskeer.Piping.Forms/PresentationObjects/ProbabilisticPipingCalculationContext.cs (revision 0)
+++ Riskeer/Piping/src/Riskeer.Piping.Forms/PresentationObjects/ProbabilisticPipingCalculationContext.cs (revision 238a999ed337563f20d3e09d6743d61ebeb45051)
@@ -0,0 +1,86 @@
+// Copyright (C) Stichting Deltares 2019. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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 System;
+using System.Collections.Generic;
+using Core.Common.Controls.PresentationObjects;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.Calculation;
+using Riskeer.Common.Forms.PresentationObjects;
+using Riskeer.Piping.Data;
+using Riskeer.Piping.Data.SoilProfile;
+using Riskeer.Piping.Primitives;
+
+namespace Riskeer.Piping.Forms.PresentationObjects
+{
+ ///
+ /// Presentation object for all data required to configure an instance of
+ /// in order to prepare it for performing a calculation.
+ ///
+ public class ProbabilisticPipingCalculationContext : PipingContext,
+ ICalculationContext
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The instance wrapped by this context object.
+ /// The that owns the wrapped calculation.
+ /// The surface lines available within the piping context.
+ /// The stochastic soil models available within the piping context.
+ /// The piping failure mechanism which the piping context belongs to.
+ /// The assessment section which the piping context belongs to.
+ /// Thrown when any input argument is null.
+ public ProbabilisticPipingCalculationContext(ProbabilisticPipingCalculation calculation,
+ CalculationGroup parent,
+ IEnumerable surfaceLines,
+ IEnumerable stochasticSoilModels,
+ PipingFailureMechanism pipingFailureMechanism,
+ IAssessmentSection assessmentSection)
+ : base(calculation, surfaceLines, stochasticSoilModels, pipingFailureMechanism, assessmentSection)
+ {
+ if (parent == null)
+ {
+ throw new ArgumentNullException(nameof(parent));
+ }
+
+ Parent = parent;
+ }
+
+ public CalculationGroup Parent { get; }
+
+ public override bool Equals(WrappedObjectContextBase other)
+ {
+ return base.Equals(other)
+ && other is ProbabilisticPipingCalculationContext context
+ && ReferenceEquals(Parent, context.Parent);
+ }
+
+ public override bool Equals(object obj)
+ {
+ return Equals(obj as ProbabilisticPipingCalculationContext);
+ }
+
+ public override int GetHashCode()
+ {
+ return base.GetHashCode() ^ Parent.GetHashCode();
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PresentationObjects/ProbabilisticPipingCalculationContextTest.cs
===================================================================
diff -u
--- Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PresentationObjects/ProbabilisticPipingCalculationContextTest.cs (revision 0)
+++ Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PresentationObjects/ProbabilisticPipingCalculationContextTest.cs (revision 238a999ed337563f20d3e09d6743d61ebeb45051)
@@ -0,0 +1,183 @@
+// Copyright (C) Stichting Deltares 2019. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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 System;
+using System.Collections.Generic;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.Calculation;
+using Riskeer.Common.Forms.PresentationObjects;
+using Riskeer.Piping.Data;
+using Riskeer.Piping.Data.SoilProfile;
+using Riskeer.Piping.Data.TestUtil;
+using Riskeer.Piping.Forms.PresentationObjects;
+using Riskeer.Piping.Primitives;
+
+namespace Riskeer.Piping.Forms.Test.PresentationObjects
+{
+ [TestFixture]
+ public class ProbabilisticPipingCalculationContextTest
+ {
+ [Test]
+ public void ConstructorWithData_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var surfaceLines = new[]
+ {
+ new PipingSurfaceLine(string.Empty)
+ };
+ PipingStochasticSoilModel[] soilModels =
+ {
+ PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel()
+ };
+ var calculation = new ProbabilisticPipingCalculation(new GeneralPipingInput());
+ var failureMechanism = new PipingFailureMechanism();
+ var parent = new CalculationGroup();
+
+ // Call
+ var presentationObject = new ProbabilisticPipingCalculationContext(calculation,
+ parent,
+ surfaceLines,
+ soilModels,
+ failureMechanism,
+ assessmentSection);
+
+ // Assert
+ Assert.IsInstanceOf>(presentationObject);
+ Assert.IsInstanceOf>(presentationObject);
+ Assert.AreSame(calculation, presentationObject.WrappedData);
+ Assert.AreSame(parent, presentationObject.Parent);
+ Assert.AreSame(surfaceLines, presentationObject.AvailablePipingSurfaceLines);
+ Assert.AreSame(soilModels, presentationObject.AvailableStochasticSoilModels);
+ Assert.AreSame(failureMechanism, presentationObject.FailureMechanism);
+ Assert.AreSame(assessmentSection, presentationObject.AssessmentSection);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_ParentNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var surfaceLines = new[]
+ {
+ new PipingSurfaceLine(string.Empty)
+ };
+ PipingStochasticSoilModel[] soilModels =
+ {
+ PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel()
+ };
+ var calculation = new ProbabilisticPipingCalculation(new GeneralPipingInput());
+ var failureMechanism = new PipingFailureMechanism();
+
+ // Call
+ void Call() => new ProbabilisticPipingCalculationContext(calculation, null, surfaceLines, soilModels, failureMechanism, assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("parent", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [TestFixture]
+ private class PipingCalculationScenarioContextEqualsTest
+ : EqualsTestFixture
+ {
+ private static readonly MockRepository mocks = new MockRepository();
+
+ private static readonly IAssessmentSection assessmentSection = mocks.Stub();
+ private static readonly ProbabilisticPipingCalculation calculation = new ProbabilisticPipingCalculation(new GeneralPipingInput());
+ private static readonly IEnumerable surfaceLines = new PipingSurfaceLine[0];
+ private static readonly IEnumerable stochasticSoilModels = new PipingStochasticSoilModel[0];
+ private static readonly PipingFailureMechanism failureMechanism = new PipingFailureMechanism();
+ private static readonly CalculationGroup parent = new CalculationGroup();
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks.ReplayAll();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ mocks.VerifyAll();
+ }
+
+ protected override ProbabilisticPipingCalculationContext CreateObject()
+ {
+ return new ProbabilisticPipingCalculationContext(calculation,
+ parent,
+ surfaceLines,
+ stochasticSoilModels,
+ failureMechanism,
+ assessmentSection);
+ }
+
+ protected override DerivedProbabilisticPipingCalculationScenarioContext CreateDerivedObject()
+ {
+ return new DerivedProbabilisticPipingCalculationScenarioContext(calculation,
+ parent,
+ surfaceLines,
+ stochasticSoilModels,
+ failureMechanism,
+ assessmentSection);
+ }
+
+ private static IEnumerable GetUnequalTestCases()
+ {
+ yield return new TestCaseData(new ProbabilisticPipingCalculationContext(new ProbabilisticPipingCalculation(new GeneralPipingInput()),
+ parent,
+ surfaceLines,
+ stochasticSoilModels,
+ failureMechanism,
+ assessmentSection))
+ .SetName("Calculation");
+ yield return new TestCaseData(new ProbabilisticPipingCalculationContext(calculation,
+ new CalculationGroup(),
+ surfaceLines,
+ stochasticSoilModels,
+ failureMechanism,
+ assessmentSection))
+ .SetName("Parent");
+ }
+ }
+
+ private class DerivedProbabilisticPipingCalculationScenarioContext : ProbabilisticPipingCalculationContext
+ {
+ public DerivedProbabilisticPipingCalculationScenarioContext(ProbabilisticPipingCalculation calculation,
+ CalculationGroup parent,
+ IEnumerable surfaceLines,
+ IEnumerable stochasticSoilModels,
+ PipingFailureMechanism pipingFailureMechanism, IAssessmentSection assessmentSection)
+ : base(calculation, parent, surfaceLines, stochasticSoilModels, pipingFailureMechanism, assessmentSection) {}
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/Piping/test/Riskeer.Piping.Forms.Test/Riskeer.Piping.Forms.Test.csproj
===================================================================
diff -u -r08e8d26a0715f0f3db57c1d3e86256aa06934db4 -r238a999ed337563f20d3e09d6743d61ebeb45051
--- Riskeer/Piping/test/Riskeer.Piping.Forms.Test/Riskeer.Piping.Forms.Test.csproj (.../Riskeer.Piping.Forms.Test.csproj) (revision 08e8d26a0715f0f3db57c1d3e86256aa06934db4)
+++ Riskeer/Piping/test/Riskeer.Piping.Forms.Test/Riskeer.Piping.Forms.Test.csproj (.../Riskeer.Piping.Forms.Test.csproj) (revision 238a999ed337563f20d3e09d6743d61ebeb45051)
@@ -10,28 +10,28 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+