Fisheye: Tag eb0db539d74db9edf5a167a21807405812c6529b refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.cs
===================================================================
diff -u
--- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.cs (revision 0)
+++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.cs (revision eb0db539d74db9edf5a167a21807405812c6529b)
@@ -0,0 +1,251 @@
+// Copyright (C) Stichting Deltares 2021. 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 System.Linq;
+using Riskeer.AssemblyTool.Data;
+using Riskeer.AssemblyTool.KernelWrapper.Calculators;
+using Riskeer.AssemblyTool.KernelWrapper.Calculators.Assembly;
+using Riskeer.AssemblyTool.KernelWrapper.Kernels;
+using Riskeer.Common.Data.AssemblyTool;
+using Riskeer.Common.Data.Exceptions;
+using Riskeer.Common.Primitives;
+using RiskeerCommonDataResources = Riskeer.Common.Data.Properties.Resources;
+
+namespace Riskeer.GrassCoverErosionOutwards.Data
+{
+ ///
+ /// Factory for creating assembly results for a grass cover erosion outwards failure mechanism.
+ ///
+ public static class GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld
+ {
+ ///
+ /// 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 the
+ /// could not be created.
+ public static FailureMechanismSectionAssemblyCategoryGroup AssembleSimpleAssessment(
+ GrassCoverErosionOutwardsFailureMechanismSectionResultOld failureMechanismSectionResult)
+ {
+ if (failureMechanismSectionResult == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanismSectionResult));
+ }
+
+ IAssemblyToolCalculatorFactoryOld calculatorFactory = AssemblyToolCalculatorFactoryOld.Instance;
+ IFailureMechanismSectionAssemblyCalculatorOld calculator =
+ calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactoryOld.Instance);
+
+ try
+ {
+ return calculator.AssembleSimpleAssessment(failureMechanismSectionResult.SimpleAssessmentResult).Group;
+ }
+ catch (FailureMechanismSectionAssemblyCalculatorException e)
+ {
+ throw new AssemblyException(e.Message, e);
+ }
+ }
+
+ ///
+ /// Assembles the detailed assessment result.
+ ///
+ /// The failure mechanism section result to assemble the
+ /// detailed assembly results for.
+ /// A based on the .
+ /// Thrown when
+ /// is null.
+ /// Thrown when the
+ /// could not be created.
+ public static FailureMechanismSectionAssemblyCategoryGroup AssembleDetailedAssessment(
+ GrassCoverErosionOutwardsFailureMechanismSectionResultOld failureMechanismSectionResult)
+ {
+ if (failureMechanismSectionResult == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanismSectionResult));
+ }
+
+ IAssemblyToolCalculatorFactoryOld calculatorFactory = AssemblyToolCalculatorFactoryOld.Instance;
+ IFailureMechanismSectionAssemblyCalculatorOld calculator =
+ calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactoryOld.Instance);
+
+ try
+ {
+ return calculator.AssembleDetailedAssessment(failureMechanismSectionResult.DetailedAssessmentResultForFactorizedSignalingNorm,
+ failureMechanismSectionResult.DetailedAssessmentResultForSignalingNorm,
+ failureMechanismSectionResult.DetailedAssessmentResultForMechanismSpecificLowerLimitNorm,
+ failureMechanismSectionResult.DetailedAssessmentResultForLowerLimitNorm,
+ failureMechanismSectionResult.DetailedAssessmentResultForFactorizedLowerLimitNorm);
+ }
+ catch (FailureMechanismSectionAssemblyCalculatorException e)
+ {
+ throw new AssemblyException(e.Message, e);
+ }
+ }
+
+ ///
+ /// Assembles the tailor made assessment result.
+ ///
+ /// The failure mechanism section result to assemble the
+ /// tailor made assembly results for.
+ /// A based on the .
+ /// Thrown when
+ /// is null.
+ /// Thrown when the
+ /// could not be created.
+ public static FailureMechanismSectionAssemblyCategoryGroup AssembleTailorMadeAssessment(
+ GrassCoverErosionOutwardsFailureMechanismSectionResultOld failureMechanismSectionResult)
+ {
+ if (failureMechanismSectionResult == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanismSectionResult));
+ }
+
+ IAssemblyToolCalculatorFactoryOld calculatorFactory = AssemblyToolCalculatorFactoryOld.Instance;
+ IFailureMechanismSectionAssemblyCalculatorOld calculator =
+ calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactoryOld.Instance);
+
+ try
+ {
+ return calculator.AssembleTailorMadeAssessment(failureMechanismSectionResult.TailorMadeAssessmentResult);
+ }
+ catch (FailureMechanismSectionAssemblyCalculatorException e)
+ {
+ throw new AssemblyException(e.Message, e);
+ }
+ }
+
+ ///
+ /// Assembles the combined assembly.
+ ///
+ /// The failure mechanism section result to assemble the
+ /// combined assembly results for.
+ /// A based on the .
+ /// Thrown when
+ /// is null.
+ /// Thrown when the
+ /// could not be created.
+ public static FailureMechanismSectionAssemblyCategoryGroup AssembleCombinedAssessment(
+ GrassCoverErosionOutwardsFailureMechanismSectionResultOld failureMechanismSectionResult)
+ {
+ if (failureMechanismSectionResult == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanismSectionResult));
+ }
+
+ IAssemblyToolCalculatorFactoryOld calculatorFactory = AssemblyToolCalculatorFactoryOld.Instance;
+ IFailureMechanismSectionAssemblyCalculatorOld calculator =
+ calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactoryOld.Instance);
+
+ try
+ {
+ FailureMechanismSectionAssemblyCategoryGroup simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult);
+
+ if (failureMechanismSectionResult.SimpleAssessmentResult == SimpleAssessmentResultType.NotApplicable
+ || failureMechanismSectionResult.SimpleAssessmentResult == SimpleAssessmentResultType.ProbabilityNegligible)
+ {
+ return calculator.AssembleCombined(simpleAssembly);
+ }
+
+ return calculator.AssembleCombined(
+ simpleAssembly,
+ AssembleDetailedAssessment(failureMechanismSectionResult),
+ AssembleTailorMadeAssessment(failureMechanismSectionResult));
+ }
+ catch (FailureMechanismSectionAssemblyCalculatorException e)
+ {
+ throw new AssemblyException(e.Message, e);
+ }
+ }
+
+ ///
+ /// Gets the assembly category group of the given .
+ ///
+ /// The failure mechanism section result to get the assembly category group for.
+ /// Indicator that determines whether the manual assembly should be considered when assembling the result.
+ /// A .
+ /// Thrown when is null.
+ /// Thrown when the
+ /// could not be created.
+ public static FailureMechanismSectionAssemblyCategoryGroup GetSectionAssemblyCategoryGroup(
+ GrassCoverErosionOutwardsFailureMechanismSectionResultOld failureMechanismSectionResult,
+ bool useManual)
+ {
+ if (failureMechanismSectionResult == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanismSectionResult));
+ }
+
+ return failureMechanismSectionResult.UseManualAssembly && useManual
+ ? failureMechanismSectionResult.ManualAssemblyCategoryGroup
+ : AssembleCombinedAssessment(failureMechanismSectionResult);
+ }
+
+ ///
+ /// Assembles the failure mechanism assembly.
+ ///
+ /// The failure mechanism to assemble for.
+ /// Indicator that determines whether the manual assembly should be considered when assembling the result.
+ /// A .
+ /// Thrown when
+ /// is null.
+ /// Thrown when the
+ /// could not be created.
+ public static FailureMechanismAssemblyCategoryGroup AssembleFailureMechanism(GrassCoverErosionOutwardsFailureMechanism failureMechanism,
+ bool useManual)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (!failureMechanism.InAssembly)
+ {
+ return FailureMechanismAssemblyResultFactoryOld.CreateNotApplicableCategory();
+ }
+
+ try
+ {
+ IEnumerable sectionAssemblies =
+ failureMechanism.SectionResultsOld.Select(result => GetSectionAssemblyCategoryGroup(result, useManual)).ToArray();
+
+ IAssemblyToolCalculatorFactoryOld calculatorFactory = AssemblyToolCalculatorFactoryOld.Instance;
+ IFailureMechanismAssemblyCalculatorOld calculator =
+ calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactoryOld.Instance);
+
+ return calculator.Assemble(sectionAssemblies);
+ }
+ catch (FailureMechanismAssemblyCalculatorException e)
+ {
+ throw new AssemblyException(e.Message, e);
+ }
+ catch (AssemblyException e)
+ {
+ throw new AssemblyException(RiskeerCommonDataResources.FailureMechanismAssemblyFactory_Error_while_assembling_failureMechanism, e);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/Factories/GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory.cs
===================================================================
diff -u -rd07611d7e455e358e7255b2807447412ac56f9c6 -reb0db539d74db9edf5a167a21807405812c6529b
--- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/Factories/GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory.cs (.../GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory.cs) (revision d07611d7e455e358e7255b2807447412ac56f9c6)
+++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/Factories/GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory.cs (.../GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory.cs) (revision eb0db539d74db9edf5a167a21807405812c6529b)
@@ -48,7 +48,7 @@
return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures(
failureMechanism,
- GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment);
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleSimpleAssessment);
}
///
@@ -67,7 +67,7 @@
return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures(
failureMechanism,
- GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment);
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleDetailedAssessment);
}
///
@@ -86,7 +86,7 @@
return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures(
failureMechanism,
- GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment);
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleTailorMadeAssessment);
}
///
@@ -105,7 +105,7 @@
return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures(
failureMechanism,
- GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment);
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleCombinedAssessment);
}
}
}
\ No newline at end of file
Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOldTest.cs
===================================================================
diff -u
--- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOldTest.cs (revision 0)
+++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOldTest.cs (revision eb0db539d74db9edf5a167a21807405812c6529b)
@@ -0,0 +1,727 @@
+// Copyright (C) Stichting Deltares 2021. 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.Linq;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Riskeer.AssemblyTool.Data;
+using Riskeer.AssemblyTool.KernelWrapper.Calculators;
+using Riskeer.AssemblyTool.KernelWrapper.Calculators.Assembly;
+using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators;
+using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly;
+using Riskeer.Common.Data.AssemblyTool;
+using Riskeer.Common.Data.Exceptions;
+using Riskeer.Common.Data.FailureMechanism;
+using Riskeer.Common.Data.TestUtil;
+using Riskeer.Common.Primitives;
+
+namespace Riskeer.GrassCoverErosionOutwards.Data.Test
+{
+ [TestFixture]
+ public class GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOldTest
+ {
+ #region Simple Assembly
+
+ [Test]
+ public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleSimpleAssessment(null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanismSectionResult", exception.ParamName);
+ }
+
+ [Test]
+ public void AssembleSimpleAssessment_WithSectionResult_SetsInputOnCalculator()
+ {
+ // Setup
+ var random = new Random(21);
+ FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(failureMechanismSection)
+ {
+ SimpleAssessmentResult = random.NextEnumValue()
+ };
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleSimpleAssessment(sectionResult);
+
+ // Assert
+ Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentInput);
+ }
+ }
+
+ [Test]
+ public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput()
+ {
+ // Setup
+ FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(failureMechanismSection);
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ FailureMechanismSectionAssemblyCategoryGroup actualOutput =
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleSimpleAssessment(sectionResult);
+
+ // Assert
+ Assert.AreEqual(calculator.SimpleAssessmentAssemblyOutput.Group, actualOutput);
+ }
+ }
+
+ [Test]
+ public void AssembleSimpleAssessment_CalculatorThrowsException_ThrowsAssemblyException()
+ {
+ // Setup
+ FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(failureMechanismSection);
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+ calculator.ThrowExceptionOnCalculate = true;
+
+ // Call
+ TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleSimpleAssessment(sectionResult);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ Assert.AreEqual(innerException.Message, exception.Message);
+ }
+ }
+
+ #endregion
+
+ #region Detailed Assembly
+
+ [Test]
+ public void AssembleDetailedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleDetailedAssessment(null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanismSectionResult", exception.ParamName);
+ }
+
+ [Test]
+ public void AssembleDetailedAssessment_WithSectionResult_SetsInputOnCalculator()
+ {
+ // Setup
+ var random = new Random(21);
+ FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(failureMechanismSection)
+ {
+ DetailedAssessmentResultForFactorizedSignalingNorm = random.NextEnumValue(),
+ DetailedAssessmentResultForSignalingNorm = random.NextEnumValue(),
+ DetailedAssessmentResultForMechanismSpecificLowerLimitNorm = random.NextEnumValue(),
+ DetailedAssessmentResultForLowerLimitNorm = random.NextEnumValue(),
+ DetailedAssessmentResultForFactorizedLowerLimitNorm = random.NextEnumValue()
+ };
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleDetailedAssessment(sectionResult);
+
+ // Assert
+ Assert.AreEqual(sectionResult.DetailedAssessmentResultForFactorizedSignalingNorm, calculator.DetailedAssessmentResultForFactorizedSignalingNormInput);
+ Assert.AreEqual(sectionResult.DetailedAssessmentResultForSignalingNorm, calculator.DetailedAssessmentResultForSignalingNormInput);
+ Assert.AreEqual(sectionResult.DetailedAssessmentResultForMechanismSpecificLowerLimitNorm, calculator.DetailedAssessmentResultForMechanismSpecificLowerLimitNormInput);
+ Assert.AreEqual(sectionResult.DetailedAssessmentResultForLowerLimitNorm, calculator.DetailedAssessmentResultForLowerLimitNormInput);
+ Assert.AreEqual(sectionResult.DetailedAssessmentResultForFactorizedLowerLimitNorm, calculator.DetailedAssessmentResultForFactorizedLowerLimitNormInput);
+ }
+ }
+
+ [Test]
+ public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput()
+ {
+ // Setup
+ FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(failureMechanismSection);
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ FailureMechanismSectionAssemblyCategoryGroup actualOutput =
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleDetailedAssessment(sectionResult);
+
+ // Assert
+ Assert.AreEqual(calculator.DetailedAssessmentAssemblyGroupOutput, actualOutput);
+ }
+ }
+
+ [Test]
+ public void AssembleDetailedAssessment_CalculatorThrowsException_ThrowsAssemblyException()
+ {
+ // Setup
+ FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(failureMechanismSection);
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+ calculator.ThrowExceptionOnCalculate = true;
+
+ // Call
+ TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleDetailedAssessment(sectionResult);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ Assert.AreEqual(innerException.Message, exception.Message);
+ }
+ }
+
+ #endregion
+
+ #region Tailor Made Assembly
+
+ [Test]
+ public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleTailorMadeAssessment(null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanismSectionResult", exception.ParamName);
+ }
+
+ [Test]
+ public void AssembleTailorMadeAssessment_WithSectionResult_SetsInputOnCalculator()
+ {
+ // Setup
+ var random = new Random(21);
+ FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(failureMechanismSection)
+ {
+ TailorMadeAssessmentResult = random.NextEnumValue()
+ };
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleTailorMadeAssessment(sectionResult);
+
+ // Assert
+ Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentCategoryGroupResultInput);
+ }
+ }
+
+ [Test]
+ public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput()
+ {
+ // Setup
+ FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(failureMechanismSection);
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ FailureMechanismSectionAssemblyCategoryGroup actualOutput =
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleTailorMadeAssessment(sectionResult);
+
+ // Assert
+ Assert.AreEqual(calculator.TailorMadeAssemblyCategoryOutput, actualOutput);
+ }
+ }
+
+ [Test]
+ public void AssembleTailorMadeAssessment_CalculatorThrowsException_ThrowsAssemblyException()
+ {
+ // Setup
+ FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(failureMechanismSection);
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+ calculator.ThrowExceptionOnCalculate = true;
+
+ // Call
+ TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleTailorMadeAssessment(sectionResult);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ Assert.AreEqual(innerException.Message, exception.Message);
+ }
+ }
+
+ #endregion
+
+ #region Combined Assembly
+
+ [Test]
+ public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleCombinedAssessment(
+ null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanismSectionResult", exception.ParamName);
+ }
+
+ [Test]
+ [TestCase(SimpleAssessmentResultType.None)]
+ [TestCase(SimpleAssessmentResultType.AssessFurther)]
+ public void AssembleCombinedAssessment_WithVariousSimpleAssessmentInputAssemblesWithAllInformation_SetsInputOnCalculator(
+ SimpleAssessmentResultType simpleAssessmentResult)
+ {
+ // Setup
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ SimpleAssessmentResult = simpleAssessmentResult
+ };
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleCombinedAssessment(sectionResult);
+
+ // Assert
+ Assert.AreEqual(calculator.SimpleAssessmentAssemblyOutput.Group, calculator.CombinedSimpleAssemblyGroupInput);
+ Assert.AreEqual(calculator.DetailedAssessmentAssemblyGroupOutput, calculator.CombinedDetailedAssemblyGroupInput);
+ Assert.AreEqual(calculator.TailorMadeAssemblyCategoryOutput, calculator.CombinedTailorMadeAssemblyGroupInput);
+ }
+ }
+
+ [Test]
+ [TestCase(SimpleAssessmentResultType.NotApplicable)]
+ [TestCase(SimpleAssessmentResultType.ProbabilityNegligible)]
+ public void AssembleCombinedAssessment_WithVariousSimpleAssessmentInputAssemblesWithOnlySimpleAssessmentInput_SetsInputOnCalculator(
+ SimpleAssessmentResultType simpleAssessmentResult)
+ {
+ // Setup
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ SimpleAssessmentResult = simpleAssessmentResult
+ };
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleCombinedAssessment(sectionResult);
+
+ // Assert
+ Assert.AreEqual(calculator.SimpleAssessmentAssemblyOutput.Group, calculator.CombinedSimpleAssemblyGroupInput);
+ Assert.AreEqual((FailureMechanismSectionAssemblyCategoryGroup) 0, calculator.CombinedDetailedAssemblyGroupInput);
+ Assert.AreEqual((FailureMechanismSectionAssemblyCategoryGroup) 0, calculator.CombinedTailorMadeAssemblyGroupInput);
+ }
+ }
+
+ [Test]
+ public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput()
+ {
+ // Setup
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ FailureMechanismSectionAssemblyCategoryGroup actualOutput =
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleCombinedAssessment(
+ sectionResult);
+
+ // Assert
+ FailureMechanismSectionAssemblyCategoryGroup? calculatorOutput = calculator.CombinedAssemblyCategoryOutput;
+ Assert.AreEqual(calculatorOutput, actualOutput);
+ }
+ }
+
+ [Test]
+ public void AssembleCombinedAssessment_CalculatorThrowsException_ThrowsAssemblyException()
+ {
+ // Setup
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+ calculator.ThrowExceptionOnCalculateCombinedAssembly = true;
+
+ // Call
+ TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleCombinedAssessment(
+ sectionResult);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ Assert.AreEqual(innerException.Message, exception.Message);
+ }
+ }
+
+ #endregion
+
+ #region GetSectionAssemblyCategoryGroup
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_FailureMechanismSectionResultNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
+ null,
+ new Random(39).NextBoolean());
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanismSectionResult", exception.ParamName);
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_WithoutManualInput_SetsInputOnCalculator()
+ {
+ // Setup
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
+ sectionResult,
+ new Random(39).NextBoolean());
+
+ // Assert
+ Assert.AreEqual(calculator.SimpleAssessmentAssemblyOutput.Group, calculator.CombinedSimpleAssemblyGroupInput);
+ Assert.AreEqual(calculator.DetailedAssessmentAssemblyGroupOutput, calculator.CombinedDetailedAssemblyGroupInput);
+ Assert.AreEqual(calculator.TailorMadeAssemblyCategoryOutput, calculator.CombinedTailorMadeAssemblyGroupInput);
+ }
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_WithoutManualInput_ReturnsOutput()
+ {
+ // Setup
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ FailureMechanismSectionAssemblyCategoryGroup categoryGroup = GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
+ sectionResult,
+ new Random(39).NextBoolean());
+
+ // Assert
+ Assert.AreEqual(calculator.CombinedAssemblyCategoryOutput, categoryGroup);
+ }
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_WithManualInputAndUseManualTrue_ReturnsOutput()
+ {
+ // Setup
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ UseManualAssembly = true,
+ ManualAssemblyCategoryGroup = new Random(39).NextEnumValue()
+ };
+
+ // Call
+ FailureMechanismSectionAssemblyCategoryGroup categoryGroup = GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
+ sectionResult,
+ true);
+
+ // Assert
+ Assert.AreEqual(sectionResult.ManualAssemblyCategoryGroup, categoryGroup);
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_WithManualInputAndUseManualFalse_ReturnsOutput()
+ {
+ // Setup
+ var random = new Random(39);
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ UseManualAssembly = true,
+ ManualAssemblyCategoryGroup = random.NextEnumValue()
+ };
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ FailureMechanismSectionAssemblyCategoryGroup categoryGroup = GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
+ sectionResult,
+ false);
+
+ // Assert
+ Assert.AreEqual(calculator.CombinedAssemblyCategoryOutput, categoryGroup);
+ }
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_WithoutManualInputAndCalculatorThrowsException_ThrowsAssemblyException()
+ {
+ // Setup
+ var sectionResult = new GrassCoverErosionOutwardsFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+ calculator.ThrowExceptionOnCalculateCombinedAssembly = true;
+
+ // Call
+ TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
+ sectionResult,
+ false);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ Assert.AreEqual(innerException.Message, exception.Message);
+ }
+ }
+
+ #endregion
+
+ #region Failure Mechanism Assembly
+
+ [Test]
+ public void AssembleFailureMechanism_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(null, new Random(39).NextBoolean());
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_FailureMechanismNotInAssembly_ReturnsNotApplicableCategory()
+ {
+ // Setup
+ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism
+ {
+ InAssembly = false
+ };
+
+ // Call
+ FailureMechanismAssemblyCategoryGroup category = GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(failureMechanism, new Random(39).NextBoolean());
+
+ // Assert
+ Assert.AreEqual(FailureMechanismAssemblyResultFactoryOld.CreateNotApplicableCategory(), category);
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator()
+ {
+ // Setup
+ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
+ FailureMechanismTestHelper.SetSections(failureMechanism, new[]
+ {
+ FailureMechanismSectionTestFactory.CreateFailureMechanismSection()
+ });
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator;
+ FailureMechanismSectionAssemblyCalculatorOldStub sectionCalculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(failureMechanism, new Random(39).NextBoolean());
+
+ // Assert
+ Assert.AreEqual(sectionCalculator.CombinedAssemblyCategoryOutput, calculator.FailureMechanismSectionCategories.Single());
+ }
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_WithManualInputAndUseManualTrue_SetsInputOnCalculator()
+ {
+ // Setup
+ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
+ FailureMechanismTestHelper.SetSections(failureMechanism, new[]
+ {
+ FailureMechanismSectionTestFactory.CreateFailureMechanismSection()
+ });
+ GrassCoverErosionOutwardsFailureMechanismSectionResultOld sectionResult = failureMechanism.SectionResultsOld.Single();
+ sectionResult.UseManualAssembly = true;
+ sectionResult.ManualAssemblyCategoryGroup = new Random(39).NextEnumValue();
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator;
+
+ // Call
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(failureMechanism, true);
+
+ // Assert
+ Assert.AreEqual(sectionResult.ManualAssemblyCategoryGroup, calculator.FailureMechanismSectionCategories.Single());
+ }
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_WithManualInputAndUseManualFalse_SetsCombinedInputOnCalculator()
+ {
+ // Setup
+ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
+ FailureMechanismTestHelper.SetSections(failureMechanism, new[]
+ {
+ FailureMechanismSectionTestFactory.CreateFailureMechanismSection()
+ });
+ GrassCoverErosionOutwardsFailureMechanismSectionResultOld sectionResult = failureMechanism.SectionResultsOld.Single();
+ sectionResult.UseManualAssembly = true;
+ sectionResult.ManualAssemblyCategoryGroup = FailureMechanismSectionAssemblyCategoryGroup.IIv;
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator;
+ FailureMechanismSectionAssemblyCalculatorOldStub sectionCalculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(failureMechanism, false);
+
+ // Assert
+ Assert.AreEqual(sectionCalculator.CombinedAssemblyCategoryOutput, calculator.FailureMechanismSectionCategories.Single());
+ }
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput()
+ {
+ // Setup
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator;
+
+ // Call
+ FailureMechanismAssemblyCategoryGroup actualOutput =
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(new GrassCoverErosionOutwardsFailureMechanism(),
+ new Random(39).NextBoolean());
+
+ // Assert
+ Assert.AreEqual(calculator.FailureMechanismAssemblyCategoryGroupOutput, actualOutput);
+ }
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException()
+ {
+ // Setup
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator;
+ calculator.ThrowExceptionOnCalculate = true;
+
+ // Call
+ TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(
+ new GrassCoverErosionOutwardsFailureMechanism(),
+ new Random(39).NextBoolean());
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ Assert.AreEqual(innerException.Message, exception.Message);
+ }
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_FailureMechanismSectionCalculatorThrowsException_ThrowsAssemblyException()
+ {
+ // Setup
+ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
+ FailureMechanismTestHelper.SetSections(failureMechanism, new[]
+ {
+ FailureMechanismSectionTestFactory.CreateFailureMechanismSection()
+ });
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+ calculator.ThrowExceptionOnCalculate = true;
+
+ // Call
+ TestDelegate call = () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(failureMechanism,
+ new Random(39).NextBoolean());
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ Assert.AreEqual("Voor een of meerdere vakken kan geen resultaat worden bepaald.", exception.Message);
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Fisheye: Tag eb0db539d74db9edf5a167a21807405812c6529b refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Integration/src/Riskeer.Integration.Data/Assembly/AssessmentSectionAssemblyFactory.cs
===================================================================
diff -u -rdf3c3ac4860db8af1cbf61c7bc8661ed1db22bd0 -reb0db539d74db9edf5a167a21807405812c6529b
--- Riskeer/Integration/src/Riskeer.Integration.Data/Assembly/AssessmentSectionAssemblyFactory.cs (.../AssessmentSectionAssemblyFactory.cs) (revision df3c3ac4860db8af1cbf61c7bc8661ed1db22bd0)
+++ Riskeer/Integration/src/Riskeer.Integration.Data/Assembly/AssessmentSectionAssemblyFactory.cs (.../AssessmentSectionAssemblyFactory.cs) (revision eb0db539d74db9edf5a167a21807405812c6529b)
@@ -224,7 +224,7 @@
{
StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(assessmentSection.StabilityStoneCover, useManual),
WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(assessmentSection.WaveImpactAsphaltCover, useManual),
- GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(assessmentSection.GrassCoverErosionOutwards, useManual),
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(assessmentSection.GrassCoverErosionOutwards, useManual),
DuneErosionFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(assessmentSection.DuneErosion, useManual),
MicrostabilityFailureMechanismAssemblyFactory.AssembleFailureMechanism(assessmentSection.Microstability, useManual),
WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(assessmentSection.WaterPressureAsphaltCover, useManual),
Index: Riskeer/Integration/src/Riskeer.Integration.Data/Assembly/CombinedAssemblyFailureMechanismSectionFactory.cs
===================================================================
diff -u -rdf3c3ac4860db8af1cbf61c7bc8661ed1db22bd0 -reb0db539d74db9edf5a167a21807405812c6529b
--- Riskeer/Integration/src/Riskeer.Integration.Data/Assembly/CombinedAssemblyFailureMechanismSectionFactory.cs (.../CombinedAssemblyFailureMechanismSectionFactory.cs) (revision df3c3ac4860db8af1cbf61c7bc8661ed1db22bd0)
+++ Riskeer/Integration/src/Riskeer.Integration.Data/Assembly/CombinedAssemblyFailureMechanismSectionFactory.cs (.../CombinedAssemblyFailureMechanismSectionFactory.cs) (revision eb0db539d74db9edf5a167a21807405812c6529b)
@@ -290,7 +290,7 @@
{
get
{
- return GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.GetSectionAssemblyCategoryGroup;
+ return GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup;
}
}
Index: Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyResultTotalView.cs
===================================================================
diff -u -rdf3c3ac4860db8af1cbf61c7bc8661ed1db22bd0 -reb0db539d74db9edf5a167a21807405812c6529b
--- Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyResultTotalView.cs (.../AssemblyResultTotalView.cs) (revision df3c3ac4860db8af1cbf61c7bc8661ed1db22bd0)
+++ Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyResultTotalView.cs (.../AssemblyResultTotalView.cs) (revision eb0db539d74db9edf5a167a21807405812c6529b)
@@ -367,7 +367,7 @@
{
GrassCoverErosionOutwardsFailureMechanism grassCoverErosionOutwards = AssessmentSection.GrassCoverErosionOutwards;
return new FailureMechanismAssemblyCategoryGroupResultRow(grassCoverErosionOutwards,
- () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(grassCoverErosionOutwards, true));
+ () => GrassCoverErosionOutwardsFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(grassCoverErosionOutwards, true));
}
private FailureMechanismAssemblyCategoryGroupResultRow CreateDuneErosionFailureMechanismAssemblyResultRow()