Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.cs (revision 9871a2374e0f08658f7bec58412958b35f8a849b)
@@ -0,0 +1,131 @@
+// 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 System;
+using System.Collections.Generic;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.AssemblyTool.KernelWrapper.Calculators;
+using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly;
+using Ringtoets.AssemblyTool.KernelWrapper.Kernels;
+using Ringtoets.Common.Data.AssemblyTool;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Exceptions;
+using Ringtoets.Common.Data.Probability;
+
+namespace Ringtoets.MacroStabilityInwards.Data
+{
+ ///
+ /// Factory for assembling the assembly tool results for macro stability inwards failure mechanism section results.
+ ///
+ public static class MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory
+ {
+ ///
+ /// Assembles the simple assessment results.
+ ///
+ /// The failure mechanism section result to assemble the
+ /// simple assembly results for.
+ /// A based on the .
+ /// Thrown when
+ /// is null.
+ /// Thrown when
+ /// cannot be assembled.
+ public static FailureMechanismSectionAssembly AssembleSimpleAssessment(
+ MacroStabilityInwardsFailureMechanismSectionResult failureMechanismSectionResult)
+ {
+ if (failureMechanismSectionResult == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanismSectionResult));
+ }
+
+ IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance;
+ IFailureMechanismSectionAssemblyCalculator calculator =
+ calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance);
+
+ try
+ {
+ return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult);
+ }
+ catch (FailureMechanismSectionAssemblyCalculatorException e)
+ {
+ throw new AssemblyFactoryException(e.Message, e);
+ }
+ }
+
+ ///
+ /// Assembles the detailed assessment result.
+ ///
+ /// The failure mechanism section result to
+ /// assemble the detailed assembly for.
+ /// The calculations belonging to this section.
+ /// The failure mechanism.
+ /// The .
+ /// A .
+ /// Thrown when any parameter is null.
+ /// Thrown when
+ /// cannot be assembled.
+ public static FailureMechanismSectionAssembly AssembleDetailedAssembly(
+ MacroStabilityInwardsFailureMechanismSectionResult failureMechanismSectionResult,
+ IEnumerable calculationScenarios,
+ MacroStabilityInwardsFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection)
+ {
+ if (failureMechanismSectionResult == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanismSectionResult));
+ }
+
+ if (calculationScenarios == null)
+ {
+ throw new ArgumentNullException(nameof(calculationScenarios));
+ }
+
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance;
+ IFailureMechanismSectionAssemblyCalculator calculator = calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactory.Instance);
+
+ try
+ {
+ IEnumerable categories = AssemblyToolCategoriesFactory.CreateFailureMechanismSectionAssemblyCategories(
+ assessmentSection.FailureMechanismContribution.SignalingNorm,
+ assessmentSection.FailureMechanismContribution.LowerLimitNorm,
+ failureMechanism.Contribution,
+ failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.GetN(failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.SectionLength));
+
+ return calculator.AssembleDetailedAssessment(failureMechanismSectionResult.GetDetailedAssessmentProbability(calculationScenarios, failureMechanism, assessmentSection),
+ categories,
+ failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.GetN(failureMechanismSectionResult.Section.Length));
+ }
+ catch (FailureMechanismSectionAssemblyCalculatorException e)
+ {
+ throw new AssemblyFactoryException(e.Message, e);
+ }
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 9871a2374e0f08658f7bec58412958b35f8a849b refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsFailureMechanismSectionResultsAssemblyFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj
===================================================================
diff -u -re5aeb6eac84e0b295dd48c7b356d0d132e344e1b -r9871a2374e0f08658f7bec58412958b35f8a849b
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj (.../Ringtoets.MacroStabilityInwards.Data.csproj) (revision e5aeb6eac84e0b295dd48c7b356d0d132e344e1b)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj (.../Ringtoets.MacroStabilityInwards.Data.csproj) (revision 9871a2374e0f08658f7bec58412958b35f8a849b)
@@ -14,7 +14,7 @@
-
+
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismSectionResultRow.cs
===================================================================
diff -u -re5aeb6eac84e0b295dd48c7b356d0d132e344e1b -r9871a2374e0f08658f7bec58412958b35f8a849b
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismSectionResultRow.cs (.../MacroStabilityInwardsFailureMechanismSectionResultRow.cs) (revision e5aeb6eac84e0b295dd48c7b356d0d132e344e1b)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismSectionResultRow.cs (.../MacroStabilityInwardsFailureMechanismSectionResultRow.cs) (revision 9871a2374e0f08658f7bec58412958b35f8a849b)
@@ -22,9 +22,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
-using System.Linq;
using Ringtoets.Common.Data.AssessmentSection;
-using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Forms.TypeConverters;
using Ringtoets.Common.Forms.Views;
using Ringtoets.Common.Primitives;
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsFailureMechanismSectionDetailedAssessmentResultExtensionsTest.cs
===================================================================
diff -u -re5aeb6eac84e0b295dd48c7b356d0d132e344e1b -r9871a2374e0f08658f7bec58412958b35f8a849b
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsFailureMechanismSectionDetailedAssessmentResultExtensionsTest.cs (.../MacroStabilityInwardsFailureMechanismSectionDetailedAssessmentResultExtensionsTest.cs) (revision e5aeb6eac84e0b295dd48c7b356d0d132e344e1b)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsFailureMechanismSectionDetailedAssessmentResultExtensionsTest.cs (.../MacroStabilityInwardsFailureMechanismSectionDetailedAssessmentResultExtensionsTest.cs) (revision 9871a2374e0f08658f7bec58412958b35f8a849b)
@@ -66,8 +66,7 @@
var failureMechanismSectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(section);
// Call
- TestDelegate call = () => failureMechanismSectionResult.GetDetailedAssessmentProbability(null, new MacroStabilityInwardsFailureMechanism(),
- assessmentSection);
+ TestDelegate call = () => failureMechanismSectionResult.GetDetailedAssessmentProbability(null, new MacroStabilityInwardsFailureMechanism(), assessmentSection);
// Assert
var exception = Assert.Throws(call);
@@ -88,7 +87,8 @@
// Call
TestDelegate call = () => failureMechanismSectionResult.GetDetailedAssessmentProbability(Enumerable.Empty(),
- null, assessmentSection);
+ null,
+ assessmentSection);
// Assert
var exception = Assert.Throws(call);
@@ -105,15 +105,16 @@
// Call
TestDelegate call = () => failureMechanismSectionResult.GetDetailedAssessmentProbability(Enumerable.Empty(),
- new MacroStabilityInwardsFailureMechanism(), null);
+ new MacroStabilityInwardsFailureMechanism(),
+ null);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("assessmentSection", exception.ParamName);
}
[Test]
- public void GetDetailedAssessmentProbability_MultipleScenarios_ReturnsValueBasedOnRelevantAndDoneScenarios()
+ public void GetDetailedAssessmentProbability_MultipleScenarios_ReturnsValueBasedOnRelevantScenarios()
{
// Setup
var failureMechanism = new MacroStabilityInwardsFailureMechanism();
@@ -125,32 +126,26 @@
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var failureMechanismSectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(section);
- const double contribution1 = 0.2;
- const double contribution2 = 0.8;
const double factorOfStability1 = 1.0 / 1000000.0;
const double factorOfStability2 = 1.0 / 2000000.0;
MacroStabilityInwardsCalculationScenario macroStabilityInwardsCalculationScenario1 = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenario(factorOfStability1, section);
MacroStabilityInwardsCalculationScenario macroStabilityInwardsCalculationScenario2 = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenario(factorOfStability2, section);
MacroStabilityInwardsCalculationScenario macroStabilityInwardsCalculationScenario3 = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenario(0.0, section);
- MacroStabilityInwardsCalculationScenario macroStabilityInwardsCalculationScenario4 = MacroStabilityInwardsCalculationScenarioTestFactory.CreateNotCalculatedMacroStabilityInwardsCalculationScenario(section);
macroStabilityInwardsCalculationScenario1.IsRelevant = true;
- macroStabilityInwardsCalculationScenario1.Contribution = (RoundedDouble) contribution1;
+ macroStabilityInwardsCalculationScenario1.Contribution = (RoundedDouble) 0.2;
macroStabilityInwardsCalculationScenario2.IsRelevant = true;
- macroStabilityInwardsCalculationScenario2.Contribution = (RoundedDouble) contribution2;
+ macroStabilityInwardsCalculationScenario2.Contribution = (RoundedDouble) 0.8;
macroStabilityInwardsCalculationScenario3.IsRelevant = false;
- macroStabilityInwardsCalculationScenario4.IsRelevant = true;
-
var calculations = new[]
{
macroStabilityInwardsCalculationScenario1,
macroStabilityInwardsCalculationScenario2,
- macroStabilityInwardsCalculationScenario3,
- macroStabilityInwardsCalculationScenario4
+ macroStabilityInwardsCalculationScenario3
};
// Call
@@ -176,7 +171,8 @@
// Call
double detailedAssessmentProbability = failureMechanismSectionResult.GetDetailedAssessmentProbability(Enumerable.Empty(),
- failureMechanism, assessmentSection);
+ failureMechanism,
+ assessmentSection);
// Assert
Assert.IsNaN(detailedAssessmentProbability);
@@ -282,6 +278,40 @@
}
[Test]
+ [TestCase(0.2, 0.8 - 1e5)]
+ [TestCase(0.0, 0.5)]
+ [TestCase(0.3, 0.7 + 1e-5)]
+ [TestCase(-5, -8)]
+ [TestCase(13, 2)]
+ public void GetDetailedAssessmentProbability_RelevantScenarioContributionDontAddUpTo1_ReturnNaN(double contributionA, double contributionB)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
+ MacroStabilityInwardsCalculationScenario scenarioA = MacroStabilityInwardsCalculationScenarioTestFactory.CreateNotCalculatedMacroStabilityInwardsCalculationScenario(section);
+ MacroStabilityInwardsCalculationScenario scenarioB = MacroStabilityInwardsCalculationScenarioTestFactory.CreateNotCalculatedMacroStabilityInwardsCalculationScenario(section);
+ scenarioA.Contribution = (RoundedDouble) contributionA;
+ scenarioB.Contribution = (RoundedDouble) contributionB;
+
+ var result = new MacroStabilityInwardsFailureMechanismSectionResult(section);
+
+ // Call
+ double detailedAssessmentProbability = result.GetDetailedAssessmentProbability(new[]
+ {
+ scenarioA,
+ scenarioB
+ }, failureMechanism, assessmentSection);
+
+ // Assert
+ Assert.IsNaN(detailedAssessmentProbability);
+ mocks.VerifyAll();
+ }
+
+ [Test]
public void GetTotalContribution_Always_ReturnsTotalRelevantScenarioContribution()
{
// Setup
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactoryTest.cs
===================================================================
diff -u -r92f7ae00ef4387f36a2a5638fc182d9a2dbb5cf1 -r9871a2374e0f08658f7bec58412958b35f8a849b
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactoryTest.cs (.../MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactoryTest.cs) (revision 92f7ae00ef4387f36a2a5638fc182d9a2dbb5cf1)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactoryTest.cs (.../MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactoryTest.cs) (revision 9871a2374e0f08658f7bec58412958b35f8a849b)
@@ -20,28 +20,36 @@
// All rights reserved.
using System;
+using System.Linq;
using Core.Common.TestUtil;
using NUnit.Framework;
+using Rhino.Mocks;
using Ringtoets.AssemblyTool.Data;
using Ringtoets.AssemblyTool.KernelWrapper.Calculators;
using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly;
using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators;
using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Contribution;
using Ringtoets.Common.Data.Exceptions;
using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.Probability;
using Ringtoets.Common.Data.TestUtil;
using Ringtoets.Common.Primitives;
+using Ringtoets.MacroStabilityInwards.Data.TestUtil;
namespace Ringtoets.MacroStabilityInwards.Data.Test
{
[TestFixture]
public class MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactoryTest
{
+ #region Simple Assessment
+
[Test]
public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException()
{
// Call
- TestDelegate call = () => MacroStabilityInwardsFailureMechanismSectionResultsAssemblyFactory.AssembleSimpleAssessment(null);
+ TestDelegate call = () => MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(null);
// Assert
var exception = Assert.Throws(call);
@@ -65,7 +73,7 @@
FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
// Call
- MacroStabilityInwardsFailureMechanismSectionResultsAssemblyFactory.AssembleSimpleAssessment(sectionResult);
+ MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(sectionResult);
// Assert
Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentInput);
@@ -85,7 +93,7 @@
FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
// Call
- FailureMechanismSectionAssembly actualOutput = MacroStabilityInwardsFailureMechanismSectionResultsAssemblyFactory.AssembleSimpleAssessment(sectionResult);
+ FailureMechanismSectionAssembly actualOutput = MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(sectionResult);
// Assert
FailureMechanismSectionAssembly calculatorOutput = calculator.SimpleAssessmentAssemblyOutput;
@@ -107,7 +115,7 @@
calculator.ThrowExceptionOnCalculate = true;
// Call
- TestDelegate call = () => MacroStabilityInwardsFailureMechanismSectionResultsAssemblyFactory.AssembleSimpleAssessment(sectionResult);
+ TestDelegate call = () => MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(sectionResult);
// Assert
var exception = Assert.Throws(call);
@@ -116,5 +124,223 @@
Assert.AreEqual(innerException.Message, exception.Message);
}
}
+
+ #endregion
+
+ #region Detailed Assessment
+
+ [Test]
+ public void AssembleDetailedAssembly_FailureMechanismSectionResultNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssembly(
+ null,
+ Enumerable.Empty(),
+ new MacroStabilityInwardsFailureMechanism(),
+ assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanismSectionResult", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AssembleDetailedAssembly_CalculationScenariosNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssembly(
+ new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()),
+ null,
+ new MacroStabilityInwardsFailureMechanism(),
+ assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("calculationScenarios", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AssembleDetailedAssembly_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssembly(
+ new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()),
+ Enumerable.Empty(),
+ null,
+ assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AssembleDetailedAssembly_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssembly(
+ new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()),
+ Enumerable.Empty(),
+ new MacroStabilityInwardsFailureMechanism(),
+ null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
+ public void AssembleDetailedAssembly_WithInput_SetsInputOnCalculator()
+ {
+ // Setup
+ var random = new Random(21);
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ assessmentSection.Stub(a => a.FailureMechanismContribution).Return(new FailureMechanismContribution(
+ Enumerable.Empty(),
+ random.Next(0, 100),
+ random.NextRoundedDouble(0.06, 0.1),
+ random.NextRoundedDouble(0.00001, 0.05)));
+ mocks.ReplayAll();
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ SimpleAssessmentResult = random.NextEnumValue()
+ };
+
+ using (new AssemblyToolCalculatorFactoryConfig())
+ {
+ var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssembly(
+ sectionResult,
+ new[]
+ {
+ MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput()
+ },
+ failureMechanism,
+ assessmentSection);
+
+ // Assert
+ Assert.AreEqual(sectionResult.GetDetailedAssessmentProbability(
+ new[]
+ {
+ MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput()
+ },
+ failureMechanism,
+ assessmentSection),
+ calculator.DetailedAssessmentProbabilityInput);
+ Assert.AreEqual(failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.GetN(sectionResult.Section.Length), calculator.DetailedAssessmentNInput);
+ Assert.IsNotNull(calculator.DetailedAssessmentCategoriesInput);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void AssembleDetailedAssembly_AssemblyRan_ReturnsOutput()
+ {
+ // Setup
+ var random = new Random(21);
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ assessmentSection.Stub(a => a.FailureMechanismContribution).Return(new FailureMechanismContribution(
+ Enumerable.Empty(),
+ random.Next(0, 100),
+ random.NextRoundedDouble(0.06, 0.1),
+ random.NextRoundedDouble(0.00001, 0.05)));
+ mocks.ReplayAll();
+
+ var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ SimpleAssessmentResult = random.NextEnumValue()
+ };
+
+ using (new AssemblyToolCalculatorFactoryConfig())
+ {
+ var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ FailureMechanismSectionAssembly actualOutput =
+ MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssembly(
+ sectionResult,
+ new[]
+ {
+ MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput()
+ },
+ new MacroStabilityInwardsFailureMechanism(),
+ assessmentSection);
+
+ // Assert
+ FailureMechanismSectionAssembly calculatorOutput = calculator.DetailedAssessmentAssemblyOutput;
+ Assert.AreSame(calculatorOutput, actualOutput);
+ }
+ }
+
+ [Test]
+ public void AssembleDetailedAssembly_CalculatorThrowsExceptions_ThrowsAssemblyFactoryException()
+ {
+ // Setup
+ var random = new Random(21);
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ assessmentSection.Stub(a => a.FailureMechanismContribution).Return(new FailureMechanismContribution(
+ Enumerable.Empty(),
+ random.Next(0, 100),
+ random.NextRoundedDouble(0.06, 0.1),
+ random.NextRoundedDouble(0.00001, 0.05)));
+ mocks.ReplayAll();
+
+ var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ SimpleAssessmentResult = random.NextEnumValue()
+ };
+
+ using (new AssemblyToolCalculatorFactoryConfig())
+ {
+ var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+ calculator.ThrowExceptionOnCalculate = true;
+
+ // Call
+ TestDelegate call = () => MacroStabilityInwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssembly(
+ sectionResult,
+ new[]
+ {
+ MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput()
+ },
+ new MacroStabilityInwardsFailureMechanism(),
+ assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ Assert.AreEqual(innerException.Message, exception.Message);
+ }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/MacroStabilityInwardsCalculationScenarioTestFactoryTest.cs
===================================================================
diff -u -reb4e08c0608aa4d157d50dba3fa4a85976eece20 -r9871a2374e0f08658f7bec58412958b35f8a849b
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/MacroStabilityInwardsCalculationScenarioTestFactoryTest.cs (.../MacroStabilityInwardsCalculationScenarioTestFactoryTest.cs) (revision eb4e08c0608aa4d157d50dba3fa4a85976eece20)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/MacroStabilityInwardsCalculationScenarioTestFactoryTest.cs (.../MacroStabilityInwardsCalculationScenarioTestFactoryTest.cs) (revision 9871a2374e0f08658f7bec58412958b35f8a849b)
@@ -376,6 +376,7 @@
expectedSurfaceLine.SetDikeTopAtPolderAt(fourthCharacteristicPointLocation);
expectedSurfaceLine.SetDikeToeAtPolderAt(fifthCharacteristicPointLocation);
expectedSurfaceLine.SetSurfaceLevelInsideAt(sixthCharacteristicPointLocation);
+ expectedSurfaceLine.ReferenceLineIntersectionWorldPoint = new Point2D(0.0, 0.0);
Assert.AreEqual(expectedSurfaceLine, inputParameters.SurfaceLine);
}
}
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/MacroStabilityInwardsCalculationScenarioTestFactory.cs
===================================================================
diff -u -r5c7faf8283e49113a2c7b9e17086148a99f13d2e -r9871a2374e0f08658f7bec58412958b35f8a849b
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/MacroStabilityInwardsCalculationScenarioTestFactory.cs (.../MacroStabilityInwardsCalculationScenarioTestFactory.cs) (revision 5c7faf8283e49113a2c7b9e17086148a99f13d2e)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/MacroStabilityInwardsCalculationScenarioTestFactory.cs (.../MacroStabilityInwardsCalculationScenarioTestFactory.cs) (revision 9871a2374e0f08658f7bec58412958b35f8a849b)
@@ -226,6 +226,7 @@
surfaceLine.SetDikeTopAtPolderAt(fourthCharacteristicPointLocation);
surfaceLine.SetDikeToeAtPolderAt(fifthCharacteristicPointLocation);
surfaceLine.SetSurfaceLevelInsideAt(sixthCharacteristicPointLocation);
+ surfaceLine.ReferenceLineIntersectionWorldPoint = new Point2D(0.0, 0.0);
HydraulicBoundaryLocation hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation
{
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismSectionResultRowTest.cs
===================================================================
diff -u -re5aeb6eac84e0b295dd48c7b356d0d132e344e1b -r9871a2374e0f08658f7bec58412958b35f8a849b
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismSectionResultRowTest.cs (.../MacroStabilityInwardsFailureMechanismSectionResultRowTest.cs) (revision e5aeb6eac84e0b295dd48c7b356d0d132e344e1b)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismSectionResultRowTest.cs (.../MacroStabilityInwardsFailureMechanismSectionResultRowTest.cs) (revision 9871a2374e0f08658f7bec58412958b35f8a849b)
@@ -62,7 +62,7 @@
Assert.IsInstanceOf>(row);
Assert.AreEqual(row.SimpleAssessmentResult, result.SimpleAssessmentResult);
Assert.AreEqual(result.GetDetailedAssessmentProbability(Enumerable.Empty(),
- failureMechanism, assessmentSection),
+ failureMechanism, assessmentSection),
row.DetailedAssessmentProbability);
Assert.AreEqual(row.AssessmentLayerThree, result.AssessmentLayerThree);
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingFailureMechanismSectionResultAssemblyFactoryTest.cs
===================================================================
diff -u -r7cccb012b51218b8989007633d8338eaf435d6f4 -r9871a2374e0f08658f7bec58412958b35f8a849b
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingFailureMechanismSectionResultAssemblyFactoryTest.cs (.../PipingFailureMechanismSectionResultAssemblyFactoryTest.cs) (revision 7cccb012b51218b8989007633d8338eaf435d6f4)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingFailureMechanismSectionResultAssemblyFactoryTest.cs (.../PipingFailureMechanismSectionResultAssemblyFactoryTest.cs) (revision 9871a2374e0f08658f7bec58412958b35f8a849b)
@@ -33,6 +33,7 @@
using Ringtoets.Common.Data.Contribution;
using Ringtoets.Common.Data.Exceptions;
using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.Probability;
using Ringtoets.Common.Data.TestUtil;
using Ringtoets.Common.Primitives;
using Ringtoets.Piping.Data.TestUtil;
@@ -221,6 +222,7 @@
random.NextRoundedDouble(0.00001, 0.05)));
mocks.ReplayAll();
+ var failureMechanism = new PipingFailureMechanism();
var sectionResult = new PipingFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
{
SimpleAssessmentResult = random.NextEnumValue()
@@ -238,7 +240,7 @@
{
PipingCalculationScenarioTestFactory.CreatePipingCalculationScenarioWithValidInput()
},
- new PipingFailureMechanism(),
+ failureMechanism,
assessmentSection);
// Assert
@@ -247,9 +249,11 @@
{
PipingCalculationScenarioTestFactory.CreatePipingCalculationScenarioWithValidInput()
},
- new PipingFailureMechanism(),
+ failureMechanism,
assessmentSection),
calculator.DetailedAssessmentProbabilityInput);
+ Assert.AreEqual(failureMechanism.PipingProbabilityAssessmentInput.GetN(sectionResult.Section.Length), calculator.DetailedAssessmentNInput);
+ Assert.IsNotNull(calculator.DetailedAssessmentCategoriesInput);
mocks.VerifyAll();
}
}