Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismAssemblyCategoriesContext.cs
===================================================================
diff -u -rc12db10749246f8e848dd63293eb46311924c7c9 -r3a1e1ede91f3bf55c491522285ff35c20b5dcf0f
--- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismAssemblyCategoriesContext.cs (.../FailureMechanismAssemblyCategoriesContext.cs) (revision c12db10749246f8e848dd63293eb46311924c7c9)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismAssemblyCategoriesContext.cs (.../FailureMechanismAssemblyCategoriesContext.cs) (revision 3a1e1ede91f3bf55c491522285ff35c20b5dcf0f)
@@ -20,7 +20,9 @@
// All rights reserved.
using System;
-using Core.Common.Controls.PresentationObjects;
+using System.Collections.Generic;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.Common.Data.AssemblyTool;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.FailureMechanism;
@@ -29,7 +31,7 @@
///
/// This class is a presentation object for failure mechanism category boundaries for a instance.
///
- public class FailureMechanismAssemblyCategoriesContext : ObservableWrappedObjectContextBase
+ public class FailureMechanismAssemblyCategoriesContext : FailureMechanismAssemblyCategoriesContextBase
{
///
/// Creates a new instance of .
@@ -41,26 +43,18 @@
public FailureMechanismAssemblyCategoriesContext(IFailureMechanism wrappedData,
IAssessmentSection assessmentSection,
Func getNFunc)
- : base(wrappedData)
+ : base(wrappedData, assessmentSection, getNFunc)
{
- if (assessmentSection == null)
- {
- throw new ArgumentNullException(nameof(assessmentSection));
- }
-
- if (getNFunc == null)
- {
- throw new ArgumentNullException(nameof(getNFunc));
- }
-
- AssessmentSection = assessmentSection;
GetNFunc = getNFunc;
+
+ GetFailureMechanismSectionAssemblyCategoriesFunc = () =>
+ AssemblyToolCategoriesFactory.CreateFailureMechanismSectionAssemblyCategories(FailureMechanismContribution.SignalingNorm,
+ FailureMechanismContribution.LowerLimitNorm,
+ wrappedData.Contribution,
+ getNFunc());
}
- ///
- /// Gets the assessment section the belongs to.
- ///
- public IAssessmentSection AssessmentSection { get; }
+ public override Func> GetFailureMechanismSectionAssemblyCategoriesFunc { get; }
///
/// Gets the function to get the 'N' parameter used to factor in the 'length effect'.
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismAssemblyCategoriesContextBase.cs
===================================================================
diff -u -rbed9a78467c584c41edfdeadd4dce27b9e23d1ae -r3a1e1ede91f3bf55c491522285ff35c20b5dcf0f
--- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismAssemblyCategoriesContextBase.cs (.../FailureMechanismAssemblyCategoriesContextBase.cs) (revision bed9a78467c584c41edfdeadd4dce27b9e23d1ae)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismAssemblyCategoriesContextBase.cs (.../FailureMechanismAssemblyCategoriesContextBase.cs) (revision 3a1e1ede91f3bf55c491522285ff35c20b5dcf0f)
@@ -31,7 +31,7 @@
namespace Ringtoets.Common.Forms.PresentationObjects
{
///
- /// This class is a presentation object for failure mechanism category boundaries for a instance.
+ /// This class is a base presentation object for failure mechanism category boundaries for a instance.
///
public abstract class FailureMechanismAssemblyCategoriesContextBase : ObservableWrappedObjectContextBase
{
@@ -58,14 +58,24 @@
}
AssessmentSection = assessmentSection;
- FailureMechanismContribution failureMechanismContribution = AssessmentSection.FailureMechanismContribution;
- GetFailureMechanismCategoriesFunc = () => AssemblyToolCategoriesFactory.CreateFailureMechanismAssemblyCategories(failureMechanismContribution.SignalingNorm,
- failureMechanismContribution.LowerLimitNorm,
+ GetFailureMechanismCategoriesFunc = () => AssemblyToolCategoriesFactory.CreateFailureMechanismAssemblyCategories(FailureMechanismContribution.SignalingNorm,
+ FailureMechanismContribution.LowerLimitNorm,
wrappedData.Contribution,
getNFunc());
}
///
+ /// Gets the
+ ///
+ protected FailureMechanismContribution FailureMechanismContribution
+ {
+ get
+ {
+ return AssessmentSection.FailureMechanismContribution;
+ }
+ }
+
+ ///
/// Gets the assessment section that the context belongs to.
///
public IAssessmentSection AssessmentSection { get; }
@@ -74,5 +84,10 @@
/// Gets the function to retrieve a collection of .
///
public Func> GetFailureMechanismCategoriesFunc { get; }
+
+ ///
+ /// Gets the function to retrieve a collection of .
+ ///
+ public abstract Func> GetFailureMechanismSectionAssemblyCategoriesFunc { get; }
}
}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismAssemblyCategoriesContextBaseTest.cs
===================================================================
diff -u -rbed9a78467c584c41edfdeadd4dce27b9e23d1ae -r3a1e1ede91f3bf55c491522285ff35c20b5dcf0f
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismAssemblyCategoriesContextBaseTest.cs (.../FailureMechanismAssemblyCategoriesContextBaseTest.cs) (revision bed9a78467c584c41edfdeadd4dce27b9e23d1ae)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismAssemblyCategoriesContextBaseTest.cs (.../FailureMechanismAssemblyCategoriesContextBaseTest.cs) (revision 3a1e1ede91f3bf55c491522285ff35c20b5dcf0f)
@@ -136,6 +136,8 @@
IAssessmentSection assessmentSection,
Func getNFunc)
: base(wrappedData, assessmentSection, getNFunc) {}
+
+ public override Func> GetFailureMechanismSectionAssemblyCategoriesFunc { get; }
}
}
}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismAssemblyCategoriesContextTest.cs
===================================================================
diff -u -rc12db10749246f8e848dd63293eb46311924c7c9 -r3a1e1ede91f3bf55c491522285ff35c20b5dcf0f
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismAssemblyCategoriesContextTest.cs (.../FailureMechanismAssemblyCategoriesContextTest.cs) (revision c12db10749246f8e848dd63293eb46311924c7c9)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismAssemblyCategoriesContextTest.cs (.../FailureMechanismAssemblyCategoriesContextTest.cs) (revision 3a1e1ede91f3bf55c491522285ff35c20b5dcf0f)
@@ -20,81 +20,71 @@
// All rights reserved.
using System;
-using Core.Common.Controls.PresentationObjects;
+using System.Collections.Generic;
+using System.Linq;
using NUnit.Framework;
using Rhino.Mocks;
-using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.AssemblyTool.KernelWrapper.Calculators;
+using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators;
+using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Categories;
+using Ringtoets.Common.Data.Contribution;
using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.TestUtil;
using Ringtoets.Common.Forms.PresentationObjects;
namespace Ringtoets.Common.Forms.Test.PresentationObjects
{
[TestFixture]
public class FailureMechanismAssemblyCategoriesContextTest
{
+ private const double tolerance = 1e-5;
+
[Test]
public void Constructor_ExpectedValues()
{
// Setup
+ var random = new Random(21);
+ double n = random.NextDouble();
+
var mocks = new MockRepository();
- var assessmentSection = mocks.Stub();
var failureMechanism = mocks.Stub();
+ failureMechanism.Contribution = random.NextDouble();
mocks.ReplayAll();
- var random = new Random(21);
- Func getNFunc = () => random.NextDouble();
+ var assessmentSection = new AssessmentSectionStub();
- // Call
- var context = new FailureMechanismAssemblyCategoriesContext(failureMechanism,
- assessmentSection,
- getNFunc);
+ using (new AssemblyToolCalculatorFactoryConfig())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ AssemblyCategoriesCalculatorStub calculator = calculatorFactory.LastCreatedAssemblyCategoriesCalculator;
- // Assert
- Assert.IsInstanceOf>(context);
- Assert.AreSame(failureMechanism, context.WrappedData);
- Assert.AreSame(assessmentSection, context.AssessmentSection);
- Assert.AreSame(getNFunc, context.GetNFunc);
+ // Call
+ var context = new FailureMechanismAssemblyCategoriesContext(failureMechanism,
+ assessmentSection,
+ () => n);
- mocks.VerifyAll();
- }
+ // Assert
+ Assert.IsInstanceOf(context);
+ Assert.AreSame(failureMechanism, context.WrappedData);
+ Assert.AreSame(assessmentSection, context.AssessmentSection);
- [Test]
- public void Constructor_AssessementSectionNull_ThrowsArgumentNullException()
- {
- // Setup
- var mocks = new MockRepository();
- var failureMechanism = mocks.Stub();
- mocks.ReplayAll();
+ IEnumerable output = context.GetFailureMechanismSectionAssemblyCategoriesFunc();
+ IEnumerable calculatorOutput = calculator.FailureMechanismSectionCategoriesOutput;
+ Assert.AreEqual(calculatorOutput.Count(), output.Count());
+ CollectionAssert.AreEqual(calculatorOutput.Select(co => co.LowerBoundary), output.Select(o => o.LowerBoundary));
+ CollectionAssert.AreEqual(calculatorOutput.Select(co => co.UpperBoundary), output.Select(o => o.UpperBoundary));
+ CollectionAssert.AreEqual(calculatorOutput.Select(co => co.Group), output.Select(o => o.Group));
- // Call
- TestDelegate call = () => new FailureMechanismAssemblyCategoriesContext(failureMechanism,
- null,
- () => 0);
+ AssemblyCategoriesInput actualCalculatorInput = calculator.AssemblyCategoriesInput;
+ FailureMechanismContribution expectedContribution = assessmentSection.FailureMechanismContribution;
+ Assert.AreEqual(failureMechanism.Contribution / 100, actualCalculatorInput.FailureMechanismContribution, tolerance);
+ Assert.AreEqual(expectedContribution.LowerLimitNorm, actualCalculatorInput.LowerLimitNorm, tolerance);
+ Assert.AreEqual(expectedContribution.SignalingNorm, actualCalculatorInput.SignalingNorm, tolerance);
+ Assert.AreEqual(n, actualCalculatorInput.N);
+ }
- // Assert
- var exception = Assert.Throws(call);
- Assert.AreEqual("assessmentSection", exception.ParamName);
-
mocks.VerifyAll();
}
-
- [Test]
- public void Constructor_GetNFuncNull_ThrowsArgumentNullException()
- {
- // Setup
- var mocks = new MockRepository();
- var assessmentSection = mocks.Stub();
- var failureMechanism = mocks.Stub();
- mocks.ReplayAll();
-
- // Call
- TestDelegate call = () => new FailureMechanismAssemblyCategoriesContext(failureMechanism,
- assessmentSection,
- null);
-
- // Assert
- var exception = Assert.Throws(call);
- Assert.AreEqual("getNFunc", exception.ParamName);
- }
}
}
\ No newline at end of file