Index: Riskeer/Integration/src/Riskeer.Integration.Data/Assembly/AssessmentSectionAssemblyFactory.cs
===================================================================
diff -u -ra56a4e8adbfd873ece61ccfbcf46317b854cd2bb -rf45746773b70d8f42fef2189c15edc2a62794dbe
--- Riskeer/Integration/src/Riskeer.Integration.Data/Assembly/AssessmentSectionAssemblyFactory.cs (.../AssessmentSectionAssemblyFactory.cs) (revision a56a4e8adbfd873ece61ccfbcf46317b854cd2bb)
+++ Riskeer/Integration/src/Riskeer.Integration.Data/Assembly/AssessmentSectionAssemblyFactory.cs (.../AssessmentSectionAssemblyFactory.cs) (revision f45746773b70d8f42fef2189c15edc2a62794dbe)
@@ -211,7 +211,7 @@
GrassCoverErosionInwardsFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(assessmentSection.GrassCoverErosionInwards, assessmentSection, useManual),
HeightStructuresFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(assessmentSection.HeightStructures, assessmentSection, useManual),
ClosingStructuresFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(assessmentSection.ClosingStructures, assessmentSection, useManual),
- StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism(assessmentSection.StabilityPointStructures, assessmentSection, useManual),
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(assessmentSection.StabilityPointStructures, assessmentSection, useManual),
PipingFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(assessmentSection.Piping, assessmentSection, useManual),
MacroStabilityInwardsFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(assessmentSection.MacroStabilityInwards, assessmentSection, useManual)
};
Index: Riskeer/Integration/src/Riskeer.Integration.Data/Assembly/CombinedAssemblyFailureMechanismSectionFactory.cs
===================================================================
diff -u -ra56a4e8adbfd873ece61ccfbcf46317b854cd2bb -rf45746773b70d8f42fef2189c15edc2a62794dbe
--- Riskeer/Integration/src/Riskeer.Integration.Data/Assembly/CombinedAssemblyFailureMechanismSectionFactory.cs (.../CombinedAssemblyFailureMechanismSectionFactory.cs) (revision a56a4e8adbfd873ece61ccfbcf46317b854cd2bb)
+++ Riskeer/Integration/src/Riskeer.Integration.Data/Assembly/CombinedAssemblyFailureMechanismSectionFactory.cs (.../CombinedAssemblyFailureMechanismSectionFactory.cs) (revision f45746773b70d8f42fef2189c15edc2a62794dbe)
@@ -340,7 +340,7 @@
{
get
{
- return (sectionResult, assessmentSection, useManual) => StabilityPointStructuresFailureMechanismAssemblyFactory.GetSectionAssemblyCategoryGroup(
+ return (sectionResult, assessmentSection, useManual) => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
sectionResult, assessmentSection.StabilityPointStructures, assessmentSection, useManual);
}
}
Index: Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyResultTotalView.cs
===================================================================
diff -u -ra56a4e8adbfd873ece61ccfbcf46317b854cd2bb -rf45746773b70d8f42fef2189c15edc2a62794dbe
--- Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyResultTotalView.cs (.../AssemblyResultTotalView.cs) (revision a56a4e8adbfd873ece61ccfbcf46317b854cd2bb)
+++ Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyResultTotalView.cs (.../AssemblyResultTotalView.cs) (revision f45746773b70d8f42fef2189c15edc2a62794dbe)
@@ -309,9 +309,9 @@
{
StabilityPointStructuresFailureMechanism stabilityPointStructures = AssessmentSection.StabilityPointStructures;
return new FailureMechanismAssemblyResultRow(stabilityPointStructures,
- () => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism(stabilityPointStructures,
- AssessmentSection,
- true));
+ () => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(stabilityPointStructures,
+ AssessmentSection,
+ true));
}
private FailureMechanismAssemblyResultRow CreateGrassCoverErosionInwardsFailureMechanismAssemblyResultRow()
Fisheye: Tag f45746773b70d8f42fef2189c15edc2a62794dbe refers to a dead (removed) revision in file `Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Data/StabilityPointStructuresFailureMechanismAssemblyFactory.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Data/StabilityPointStructuresFailureMechanismAssemblyFactoryOld.cs
===================================================================
diff -u
--- Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Data/StabilityPointStructuresFailureMechanismAssemblyFactoryOld.cs (revision 0)
+++ Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Data/StabilityPointStructuresFailureMechanismAssemblyFactoryOld.cs (revision f45746773b70d8f42fef2189c15edc2a62794dbe)
@@ -0,0 +1,393 @@
+// 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.AssessmentSection;
+using Riskeer.Common.Data.Exceptions;
+using Riskeer.Common.Data.Structures;
+using Riskeer.Common.Primitives;
+using RiskeerCommonDataResources = Riskeer.Common.Data.Properties.Resources;
+
+namespace Riskeer.StabilityPointStructures.Data
+{
+ ///
+ /// Factory for assembling assembly results for a stability point structures failure mechanism.
+ ///
+ public static class StabilityPointStructuresFailureMechanismAssemblyFactoryOld
+ {
+ ///
+ /// 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 FailureMechanismSectionAssemblyOld AssembleSimpleAssessment(
+ StabilityPointStructuresFailureMechanismSectionResultOld 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);
+ }
+ catch (FailureMechanismSectionAssemblyCalculatorException e)
+ {
+ throw new AssemblyException(e.Message, e);
+ }
+ }
+
+ ///
+ /// Assembles the detailed assessment result.
+ ///
+ /// The failure mechanism section result to
+ /// assemble the detailed assembly for.
+ /// All calculation scenarios in the failure mechanism.
+ /// The failure mechanism this section belongs to.
+ /// The this section belongs to.
+ /// A .
+ /// Thrown when any parameter is null.
+ /// Thrown when the
+ /// could not be created.
+ public static FailureMechanismSectionAssemblyOld AssembleDetailedAssessment(
+ StabilityPointStructuresFailureMechanismSectionResultOld failureMechanismSectionResult,
+ IEnumerable> calculationScenarios,
+ StabilityPointStructuresFailureMechanism 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));
+ }
+
+ IAssemblyToolCalculatorFactoryOld calculatorFactory = AssemblyToolCalculatorFactoryOld.Instance;
+ IFailureMechanismSectionAssemblyCalculatorOld calculator =
+ calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactoryOld.Instance);
+
+ try
+ {
+ return calculator.AssembleDetailedAssessment(
+ failureMechanismSectionResult.DetailedAssessmentResult,
+ failureMechanismSectionResult.GetDetailedAssessmentProbability(calculationScenarios),
+ CreateAssemblyCategoriesInput(failureMechanism, assessmentSection));
+ }
+ 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 for.
+ /// The failure mechanism this section belongs to.
+ /// The this section belongs to.
+ /// A .
+ /// Thrown when any parameter is null.
+ /// Thrown when the
+ /// could not be created.
+ public static FailureMechanismSectionAssemblyOld AssembleTailorMadeAssessment(
+ StabilityPointStructuresFailureMechanismSectionResultOld failureMechanismSectionResult,
+ StabilityPointStructuresFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection)
+ {
+ if (failureMechanismSectionResult == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanismSectionResult));
+ }
+
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ IAssemblyToolCalculatorFactoryOld calculatorFactory = AssemblyToolCalculatorFactoryOld.Instance;
+ IFailureMechanismSectionAssemblyCalculatorOld calculator =
+ calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactoryOld.Instance);
+
+ try
+ {
+ return calculator.AssembleTailorMadeAssessment(
+ failureMechanismSectionResult.TailorMadeAssessmentResult,
+ failureMechanismSectionResult.TailorMadeAssessmentProbability,
+ CreateAssemblyCategoriesInput(failureMechanism, assessmentSection));
+ }
+ catch (FailureMechanismSectionAssemblyCalculatorException e)
+ {
+ throw new AssemblyException(e.Message, e);
+ }
+ }
+
+ ///
+ /// Assembles the combined assembly.
+ ///
+ /// The failure mechanism section result to
+ /// combine the assemblies for.
+ /// All calculation scenarios in the failure mechanism.
+ /// The failure mechanism this section belongs to.
+ /// The this section belongs to.
+ /// A .
+ /// Thrown when any parameter is null.
+ /// Thrown when the
+ /// could not be created.
+ public static FailureMechanismSectionAssemblyOld AssembleCombinedAssessment(
+ StabilityPointStructuresFailureMechanismSectionResultOld failureMechanismSectionResult,
+ IEnumerable> calculationScenarios,
+ StabilityPointStructuresFailureMechanism 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));
+ }
+
+ IAssemblyToolCalculatorFactoryOld calculatorFactory = AssemblyToolCalculatorFactoryOld.Instance;
+ IFailureMechanismSectionAssemblyCalculatorOld calculator =
+ calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactoryOld.Instance);
+
+ try
+ {
+ FailureMechanismSectionAssemblyOld simpleAssembly = AssembleSimpleAssessment(failureMechanismSectionResult);
+
+ if (failureMechanismSectionResult.SimpleAssessmentResult == SimpleAssessmentValidityOnlyResultType.NotApplicable)
+ {
+ return calculator.AssembleCombined(simpleAssembly);
+ }
+
+ return calculator.AssembleCombined(
+ simpleAssembly,
+ AssembleDetailedAssessment(failureMechanismSectionResult, calculationScenarios, failureMechanism, assessmentSection),
+ AssembleTailorMadeAssessment(failureMechanismSectionResult, failureMechanism, assessmentSection));
+ }
+ 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.
+ /// The failure mechanism this section belongs to.
+ /// The this section belongs to.
+ /// Indicator that determines whether the manual assembly should be considered when assembling the result.
+ /// A .
+ /// Thrown when any parameter is null.
+ /// Thrown when the
+ /// could not be created.
+ public static FailureMechanismSectionAssemblyCategoryGroup GetSectionAssemblyCategoryGroup(StabilityPointStructuresFailureMechanismSectionResultOld failureMechanismSectionResult,
+ StabilityPointStructuresFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection,
+ bool useManual)
+ {
+ if (failureMechanismSectionResult == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanismSectionResult));
+ }
+
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ return GetSectionAssembly(failureMechanismSectionResult, failureMechanism, assessmentSection, useManual).Group;
+ }
+
+ ///
+ /// Assembles the failure mechanism assembly.
+ ///
+ /// The failure mechanism to assemble for.
+ /// The the failure mechanism belongs to.
+ /// Indicator that determines whether the manual assembly should be considered when assembling the result.
+ /// A .
+ /// Thrown when any parameter is null.
+ /// Thrown when the
+ /// could not be created.
+ public static FailureMechanismAssembly AssembleFailureMechanism(
+ StabilityPointStructuresFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection,
+ bool useManual)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ if (!failureMechanism.InAssembly)
+ {
+ return FailureMechanismAssemblyResultFactoryOld.CreateNotApplicableAssembly();
+ }
+
+ try
+ {
+ IAssemblyToolCalculatorFactoryOld calculatorFactory = AssemblyToolCalculatorFactoryOld.Instance;
+ AssemblyCategoriesInput assemblyCategoriesInput = CreateAssemblyCategoriesInput(failureMechanism, assessmentSection);
+ IEnumerable sectionAssemblies = failureMechanism.SectionResultsOld
+ .Select(sr => GetSectionAssembly(sr, failureMechanism, assessmentSection, useManual))
+ .ToArray();
+
+ IFailureMechanismAssemblyCalculatorOld calculator =
+ calculatorFactory.CreateFailureMechanismAssemblyCalculator(AssemblyToolKernelFactoryOld.Instance);
+
+ return calculator.Assemble(sectionAssemblies, assemblyCategoriesInput);
+ }
+ catch (FailureMechanismAssemblyCalculatorException e)
+ {
+ throw new AssemblyException(e.Message, e);
+ }
+ catch (AssemblyException e)
+ {
+ throw new AssemblyException(RiskeerCommonDataResources.FailureMechanismAssemblyFactory_Error_while_assembling_failureMechanism, e);
+ }
+ }
+
+ ///
+ /// Gets the assembly of the given .
+ ///
+ /// The failure mechanism section result to get the assembly for.
+ /// The failure mechanism to assemble for.
+ /// The the failure mechanism belongs to.
+ /// Indicator that determines whether the manual assembly should be considered when assembling the result.
+ /// A .
+ /// Thrown when a
+ /// could not be created.
+ private static FailureMechanismSectionAssemblyOld GetSectionAssembly(StabilityPointStructuresFailureMechanismSectionResultOld failureMechanismSectionResult,
+ StabilityPointStructuresFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection,
+ bool useManual)
+ {
+ FailureMechanismSectionAssemblyOld sectionAssembly;
+ if (failureMechanismSectionResult.UseManualAssembly && useManual)
+ {
+ sectionAssembly = AssembleManualAssessment(failureMechanismSectionResult,
+ CreateAssemblyCategoriesInput(failureMechanism, assessmentSection));
+ }
+ else
+ {
+ sectionAssembly = AssembleCombinedAssessment(failureMechanismSectionResult,
+ failureMechanism.Calculations.Cast>(),
+ failureMechanism,
+ assessmentSection);
+ }
+
+ return sectionAssembly;
+ }
+
+ ///
+ /// Assembles the manual assembly.
+ ///
+ /// The failure mechanism section result to assemble the
+ /// manual assembly for.
+ /// The input parameters used to determine the assembly categories.
+ /// A .
+ /// Thrown when the
+ /// could not be created.
+ private static FailureMechanismSectionAssemblyOld AssembleManualAssessment(StabilityPointStructuresFailureMechanismSectionResultOld sectionResult,
+ AssemblyCategoriesInput assemblyCategoriesInput)
+ {
+ IAssemblyToolCalculatorFactoryOld calculatorFactory = AssemblyToolCalculatorFactoryOld.Instance;
+ IFailureMechanismSectionAssemblyCalculatorOld calculator =
+ calculatorFactory.CreateFailureMechanismSectionAssemblyCalculator(AssemblyToolKernelFactoryOld.Instance);
+
+ try
+ {
+ return calculator.AssembleManual(sectionResult.ManualAssemblyProbability, assemblyCategoriesInput);
+ }
+ catch (FailureMechanismSectionAssemblyCalculatorException e)
+ {
+ throw new AssemblyException(e.Message, e);
+ }
+ }
+
+ private static AssemblyCategoriesInput CreateAssemblyCategoriesInput(StabilityPointStructuresFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection)
+ {
+ return AssemblyCategoriesInputFactory.CreateAssemblyCategoriesInput(failureMechanism.GeneralInput.N,
+ failureMechanism,
+ assessmentSection);
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/Factories/StabilityPointStructuresAssemblyMapDataFeaturesFactory.cs
===================================================================
diff -u -rd07611d7e455e358e7255b2807447412ac56f9c6 -rf45746773b70d8f42fef2189c15edc2a62794dbe
--- Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/Factories/StabilityPointStructuresAssemblyMapDataFeaturesFactory.cs (.../StabilityPointStructuresAssemblyMapDataFeaturesFactory.cs) (revision d07611d7e455e358e7255b2807447412ac56f9c6)
+++ Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/Factories/StabilityPointStructuresAssemblyMapDataFeaturesFactory.cs (.../StabilityPointStructuresAssemblyMapDataFeaturesFactory.cs) (revision f45746773b70d8f42fef2189c15edc2a62794dbe)
@@ -52,7 +52,7 @@
return AssemblyMapDataFeaturesFactory.CreateAssemblyFeatures(
failureMechanism,
- StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleSimpleAssessment);
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleSimpleAssessment);
}
///
@@ -78,7 +78,7 @@
return AssemblyMapDataFeaturesFactory.CreateAssemblyFeatures(
failureMechanism,
- sectionResult => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleDetailedAssessment(
+ sectionResult => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleDetailedAssessment(
sectionResult,
failureMechanism.Calculations.Cast>(),
failureMechanism,
@@ -107,9 +107,9 @@
return AssemblyMapDataFeaturesFactory.CreateAssemblyFeatures(
failureMechanism,
- sectionResult => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult,
- failureMechanism,
- assessmentSection));
+ sectionResult => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleTailorMadeAssessment(sectionResult,
+ failureMechanism,
+ assessmentSection));
}
///
@@ -134,7 +134,7 @@
return AssemblyMapDataFeaturesFactory.CreateAssemblyFeatures(
failureMechanism,
- sectionResult => StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleCombinedAssessment(
+ sectionResult => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleCombinedAssessment(
sectionResult,
failureMechanism.Calculations.Cast>(),
failureMechanism,
Index: Riskeer/StabilityPointStructures/test/Riskeer.StabilityPointStructures.Data.Test/StabilityPointStructuresFailureMechanismAssemblyFactoryOldTest.cs
===================================================================
diff -u
--- Riskeer/StabilityPointStructures/test/Riskeer.StabilityPointStructures.Data.Test/StabilityPointStructuresFailureMechanismAssemblyFactoryOldTest.cs (revision 0)
+++ Riskeer/StabilityPointStructures/test/Riskeer.StabilityPointStructures.Data.Test/StabilityPointStructuresFailureMechanismAssemblyFactoryOldTest.cs (revision f45746773b70d8f42fef2189c15edc2a62794dbe)
@@ -0,0 +1,1216 @@
+// 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 Rhino.Mocks;
+using Riskeer.AssemblyTool.Data;
+using Riskeer.AssemblyTool.Data.TestUtil;
+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.AssessmentSection;
+using Riskeer.Common.Data.Exceptions;
+using Riskeer.Common.Data.FailureMechanism;
+using Riskeer.Common.Data.Structures;
+using Riskeer.Common.Data.TestUtil;
+using Riskeer.Common.Primitives;
+
+namespace Riskeer.StabilityPointStructures.Data.Test
+{
+ [TestFixture]
+ public class StabilityPointStructuresFailureMechanismAssemblyFactoryOldTest
+ {
+ private static void AssertAssemblyCategoriesInput(IAssessmentSection assessmentSection,
+ StabilityPointStructuresFailureMechanism failureMechanism,
+ AssemblyCategoriesInput assemblyCategoriesInput)
+ {
+ Assert.AreEqual(assessmentSection.FailureMechanismContribution.SignalingNorm, assemblyCategoriesInput.SignalingNorm);
+ Assert.AreEqual(assessmentSection.FailureMechanismContribution.LowerLimitNorm, assemblyCategoriesInput.LowerLimitNorm);
+ Assert.AreEqual(failureMechanism.Contribution, assemblyCategoriesInput.FailureMechanismContribution);
+ Assert.AreEqual(failureMechanism.GeneralInput.N, assemblyCategoriesInput.N);
+ }
+
+ #region Simple Assembly
+
+ [Test]
+ public void AssembleSimpleAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.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 StabilityPointStructuresFailureMechanismSectionResultOld(failureMechanismSection)
+ {
+ SimpleAssessmentResult = random.NextEnumValue()
+ };
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleSimpleAssessment(sectionResult);
+
+ // Assert
+ Assert.AreEqual(sectionResult.SimpleAssessmentResult, calculator.SimpleAssessmentValidityOnlyInput);
+ }
+ }
+
+ [Test]
+ public void AssembleSimpleAssessment_AssemblyRan_ReturnsOutput()
+ {
+ // Setup
+ FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(failureMechanismSection);
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ FailureMechanismSectionAssemblyOld actualOutput =
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleSimpleAssessment(sectionResult);
+
+ // Assert
+ FailureMechanismSectionAssemblyOld calculatorOutput = calculator.SimpleAssessmentAssemblyOutput;
+ Assert.AreSame(calculatorOutput, actualOutput);
+ }
+ }
+
+ [Test]
+ public void AssembleSimpleAssessment_CalculatorThrowsException_ThrowsAssemblyException()
+ {
+ // Setup
+ FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(failureMechanismSection);
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+ calculator.ThrowExceptionOnCalculate = true;
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.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()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleDetailedAssessment(
+ null, Enumerable.Empty>(),
+ new StabilityPointStructuresFailureMechanism(), assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("failureMechanismSectionResult", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AssembleDetailedAssessment_CalculationScenariosNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleDetailedAssessment(
+ new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()),
+ null, new StabilityPointStructuresFailureMechanism(), assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("calculationScenarios", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AssembleDetailedAssessment_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleDetailedAssessment(
+ new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()),
+ Enumerable.Empty>(), null, assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AssembleDetailedAssessment_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleDetailedAssessment(
+ new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()),
+ Enumerable.Empty>(), new StabilityPointStructuresFailureMechanism(), null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
+ public void AssembleDetailedAssessment_WithInput_SetsInputOnCalculator()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ DetailedAssessmentResult = new Random(21).NextEnumValue()
+ };
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleDetailedAssessment(
+ sectionResult, Enumerable.Empty>(),
+ failureMechanism, assessmentSection);
+
+ // Assert
+ Assert.AreEqual(sectionResult.GetDetailedAssessmentProbability(
+ Enumerable.Empty>()),
+ calculator.DetailedAssessmentProbabilityInput);
+ Assert.AreEqual(sectionResult.DetailedAssessmentResult, calculator.DetailedAssessmentProbabilityOnlyResultInput);
+ AssertAssemblyCategoriesInput(assessmentSection, failureMechanism, calculator.DetailedAssessmentAssemblyCategoriesInput);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void AssembleDetailedAssessment_AssemblyRan_ReturnsOutput()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ FailureMechanismSectionAssemblyOld actualOutput =
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleDetailedAssessment(
+ sectionResult, Enumerable.Empty>(),
+ failureMechanism, assessmentSection);
+
+ // Assert
+ FailureMechanismSectionAssemblyOld calculatorOutput = calculator.DetailedAssessmentAssemblyOutput;
+ Assert.AreSame(calculatorOutput, actualOutput);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void AssembleDetailedAssessment_CalculatorThrowsException_ThrowsAssemblyException()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+ calculator.ThrowExceptionOnCalculate = true;
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleDetailedAssessment(
+ sectionResult, Enumerable.Empty>(),
+ failureMechanism, assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ Assert.AreEqual(innerException.Message, exception.Message);
+ mocks.VerifyAll();
+ }
+ }
+
+ #endregion
+
+ #region Tailor Made Assembly
+
+ [Test]
+ public void AssembleTailorMadeAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleTailorMadeAssessment(
+ null, new StabilityPointStructuresFailureMechanism(), assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("failureMechanismSectionResult", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AssembleTailorMadeAssessment_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleTailorMadeAssessment(
+ new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()),
+ null, assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AssembleTailorMadeAssessment_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleTailorMadeAssessment(
+ new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()),
+ new StabilityPointStructuresFailureMechanism(), null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
+ public void AssembleTailorMadeAssessment_WithInput_SetsInputOnCalculator()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleTailorMadeAssessment(
+ sectionResult,
+ failureMechanism,
+ assessmentSection);
+
+ // Assert
+ Assert.AreEqual(sectionResult.TailorMadeAssessmentProbability, calculator.TailorMadeAssessmentProbabilityInput);
+ Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentProbabilityCalculationResultInput);
+ AssertAssemblyCategoriesInput(assessmentSection, failureMechanism, calculator.TailorMadeAssessmentAssemblyCategoriesInput);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void AssembleTailorMadeAssessment_AssemblyRan_ReturnsOutput()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ FailureMechanismSectionAssemblyOld actualOutput =
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleTailorMadeAssessment(
+ sectionResult,
+ failureMechanism,
+ assessmentSection);
+
+ // Assert
+ FailureMechanismSectionAssemblyOld calculatorOutput = calculator.TailorMadeAssessmentAssemblyOutput;
+ Assert.AreSame(calculatorOutput, actualOutput);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void AssembleTailorMadeAssessment_CalculatorThrowsException_ThrowsAssemblyException()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+ calculator.ThrowExceptionOnCalculate = true;
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleTailorMadeAssessment(
+ sectionResult, failureMechanism, assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ Assert.AreEqual(innerException.Message, exception.Message);
+ mocks.VerifyAll();
+ }
+ }
+
+ #endregion
+
+ #region Combined Assembly
+
+ [Test]
+ public void AssembleCombinedAssessment_FailureMechanismSectionResultNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleCombinedAssessment(
+ null, Enumerable.Empty>(),
+ new StabilityPointStructuresFailureMechanism(), assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("failureMechanismSectionResult", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AssembleCombinedAssessment_CalculationScenariosNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleCombinedAssessment(
+ new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()),
+ null, new StabilityPointStructuresFailureMechanism(), assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("calculationScenarios", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AssembleCombinedAssessment_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleCombinedAssessment(
+ new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()),
+ Enumerable.Empty>(), null, assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AssembleCombinedAssessment_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleCombinedAssessment(
+ new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()),
+ Enumerable.Empty>(), new StabilityPointStructuresFailureMechanism(), null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
+ [TestCase(SimpleAssessmentValidityOnlyResultType.None)]
+ [TestCase(SimpleAssessmentValidityOnlyResultType.Applicable)]
+ public void AssembleCombinedAssessment_WithVariousSimpleAssessmentInputAssemblesWithAllInformation_SetsInputOnCalculator(
+ SimpleAssessmentValidityOnlyResultType simpleAssessmentResult)
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ SimpleAssessmentResult = simpleAssessmentResult
+ };
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleCombinedAssessment(
+ sectionResult, Enumerable.Empty>(),
+ failureMechanism, assessmentSection);
+
+ // Assert
+ AssemblyToolTestHelper.AssertAreEqual(calculator.SimpleAssessmentAssemblyOutput, calculator.CombinedSimpleAssemblyInput);
+ AssemblyToolTestHelper.AssertAreEqual(calculator.DetailedAssessmentAssemblyOutput, calculator.CombinedDetailedAssemblyInput);
+ AssemblyToolTestHelper.AssertAreEqual(calculator.TailorMadeAssessmentAssemblyOutput, calculator.CombinedTailorMadeAssemblyInput);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void AssembleCombinedAssessment_WithInputSimpleAssessmentNotApplicable_SetsInputOnCalculator()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ SimpleAssessmentResult = SimpleAssessmentValidityOnlyResultType.NotApplicable
+ };
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleCombinedAssessment(
+ sectionResult, Enumerable.Empty>(),
+ failureMechanism, assessmentSection);
+
+ // Assert
+ AssemblyToolTestHelper.AssertAreEqual(calculator.SimpleAssessmentAssemblyOutput, calculator.CombinedSimpleAssemblyInput);
+ Assert.IsNull(calculator.CombinedDetailedAssemblyInput);
+ Assert.IsNull(calculator.CombinedTailorMadeAssemblyInput);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void AssembleCombinedAssessment_AssemblyRan_ReturnsOutput()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ FailureMechanismSectionAssemblyOld actualOutput =
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleCombinedAssessment(
+ sectionResult, Enumerable.Empty>(),
+ failureMechanism, assessmentSection);
+
+ // Assert
+ Assert.AreSame(calculator.CombinedAssemblyOutput, actualOutput);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void AssembleCombinedAssessment_CalculatorThrowsException_ThrowsAssemblyException()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+ calculator.ThrowExceptionOnCalculateCombinedAssembly = true;
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleCombinedAssessment(
+ sectionResult, Enumerable.Empty>(),
+ failureMechanism, assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ Assert.AreEqual(innerException.Message, exception.Message);
+ mocks.VerifyAll();
+ }
+ }
+
+ #endregion
+
+ #region GetSectionAssemblyCategoryGroup
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_FailureMechanismSectionResultNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
+ null, new StabilityPointStructuresFailureMechanism(),
+ assessmentSection, new Random(39).NextBoolean());
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("failureMechanismSectionResult", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
+ new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()),
+ null, assessmentSection, new Random(39).NextBoolean());
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
+ new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()),
+ new StabilityPointStructuresFailureMechanism(), null, new Random(39).NextBoolean());
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_WithoutManualInput_SetsInputOnCalculator()
+ {
+ // Setup
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
+ sectionResult,
+ failureMechanism,
+ assessmentSection,
+ new Random(39).NextBoolean());
+
+ // Assert
+ AssemblyToolTestHelper.AssertAreEqual(calculator.SimpleAssessmentAssemblyOutput, calculator.CombinedSimpleAssemblyInput);
+ AssemblyToolTestHelper.AssertAreEqual(calculator.DetailedAssessmentAssemblyOutput, calculator.CombinedDetailedAssemblyInput);
+ AssemblyToolTestHelper.AssertAreEqual(calculator.TailorMadeAssessmentAssemblyOutput, calculator.CombinedTailorMadeAssemblyInput);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_WithManualInputAndUseManualTrue_SetsInputOnCalculator()
+ {
+ // Setup
+ var random = new Random(39);
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ UseManualAssembly = true,
+ ManualAssemblyProbability = random.NextDouble(),
+ TailorMadeAssessmentResult = random.NextEnumValue(),
+ TailorMadeAssessmentProbability = random.NextDouble()
+ };
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
+ sectionResult,
+ failureMechanism,
+ assessmentSection,
+ true);
+
+ // Assert
+ Assert.AreEqual(sectionResult.ManualAssemblyProbability, calculator.ManualAssemblyProbabilityInput);
+ Assert.AreEqual(0.0, calculator.TailorMadeAssessmentProbabilityInput);
+ Assert.AreEqual((TailorMadeAssessmentProbabilityCalculationResultType) 0, calculator.TailorMadeAssessmentProbabilityCalculationResultInput);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_WithManualInputAndUseManualFalse_SetsInputOnCalculator()
+ {
+ // Setup
+ var random = new Random(39);
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ UseManualAssembly = true,
+ ManualAssemblyProbability = random.NextDouble(),
+ TailorMadeAssessmentResult = random.NextEnumValue(),
+ TailorMadeAssessmentProbability = random.NextDouble()
+ };
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
+ sectionResult,
+ failureMechanism,
+ assessmentSection,
+ false);
+
+ // Assert
+ Assert.AreEqual(0.0, calculator.ManualAssemblyProbabilityInput);
+ Assert.AreEqual(sectionResult.TailorMadeAssessmentProbability, calculator.TailorMadeAssessmentProbabilityInput);
+ Assert.AreEqual(sectionResult.TailorMadeAssessmentResult, calculator.TailorMadeAssessmentProbabilityCalculationResultInput);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_WithoutManualInput_ReturnsOutput()
+ {
+ // Setup
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ FailureMechanismSectionAssemblyCategoryGroup categoryGroup = StabilityPointStructuresFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
+ sectionResult,
+ failureMechanism,
+ assessmentSection,
+ new Random(39).NextBoolean());
+
+ // Assert
+ Assert.AreEqual(calculator.CombinedAssemblyOutput.Group, categoryGroup);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_WithManualInputAndUseManualTrue_ReturnsOutput()
+ {
+ // Setup
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ UseManualAssembly = true,
+ ManualAssemblyProbability = new Random(39).NextDouble()
+ };
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ FailureMechanismSectionAssemblyCategoryGroup categoryGroup = StabilityPointStructuresFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
+ sectionResult,
+ failureMechanism,
+ assessmentSection,
+ true);
+
+ // Assert
+ Assert.AreEqual(calculator.ManualAssemblyAssemblyOutput.Group, categoryGroup);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_WithManualInputAndUseManualFalse_ReturnsOutput()
+ {
+ // Setup
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ UseManualAssembly = true,
+ ManualAssemblyProbability = new Random(39).NextDouble()
+ };
+
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ FailureMechanismSectionAssemblyCategoryGroup categoryGroup = StabilityPointStructuresFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
+ sectionResult,
+ failureMechanism,
+ assessmentSection,
+ false);
+
+ // Assert
+ Assert.AreEqual(calculator.CombinedAssemblyOutput.Group, categoryGroup);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void GetSectionAssemblyCategoryGroup_CalculatorThrowsException_ThrowsAssemblyException(bool useManualAssembly)
+ {
+ // Setup
+ var sectionResult = new StabilityPointStructuresFailureMechanismSectionResultOld(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ UseManualAssembly = useManualAssembly
+ };
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+ if (useManualAssembly)
+ {
+ calculator.ThrowExceptionOnCalculate = true;
+ }
+ else
+ {
+ calculator.ThrowExceptionOnCalculateCombinedAssembly = true;
+ }
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.GetSectionAssemblyCategoryGroup(
+ sectionResult, failureMechanism, assessmentSection, useManualAssembly);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ Assert.AreEqual(innerException.Message, exception.Message);
+ mocks.VerifyAll();
+ }
+ }
+
+ #endregion
+
+ #region Failure Mechanism Assembly
+
+ [Test]
+ public void AssembleFailureMechanism_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(
+ null, assessmentSection, new Random(39).NextBoolean());
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(
+ new StabilityPointStructuresFailureMechanism(), null, new Random(39).NextBoolean());
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_FailureMechanismNotInAssembly_ReturnsNotApplicableAssembly()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism
+ {
+ InAssembly = false
+ };
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ // Call
+ FailureMechanismAssembly assembly = StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(
+ failureMechanism,
+ assessmentSection,
+ new Random(39).NextBoolean());
+
+ // Assert
+ AssemblyToolTestHelper.AssertAreEqual(FailureMechanismAssemblyResultFactoryOld.CreateNotApplicableAssembly(), assembly);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_WithoutManualInput_SetsInputOnCalculator()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ FailureMechanismTestHelper.SetSections(failureMechanism, new[]
+ {
+ FailureMechanismSectionTestFactory.CreateFailureMechanismSection()
+ });
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator;
+ FailureMechanismSectionAssemblyCalculatorOldStub sectionCalculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(
+ failureMechanism,
+ assessmentSection,
+ new Random(39).NextBoolean());
+
+ // Assert
+ AssemblyToolTestHelper.AssertAreEqual(sectionCalculator.CombinedAssemblyOutput, calculator.FailureMechanismSectionAssemblies.Single());
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_WithManualInputAndUseManualTrue_SetsInputOnCalculator()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ FailureMechanismTestHelper.SetSections(failureMechanism, new[]
+ {
+ FailureMechanismSectionTestFactory.CreateFailureMechanismSection()
+ });
+ StabilityPointStructuresFailureMechanismSectionResultOld sectionResult = failureMechanism.SectionResultsOld.Single();
+ sectionResult.UseManualAssembly = true;
+ sectionResult.ManualAssemblyProbability = new Random(39).NextDouble();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator;
+ FailureMechanismSectionAssemblyCalculatorOldStub sectionCalculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(
+ failureMechanism,
+ assessmentSection,
+ true);
+
+ // Assert
+ AssemblyToolTestHelper.AssertAreEqual(sectionCalculator.ManualAssemblyAssemblyOutput, calculator.FailureMechanismSectionAssemblies.Single());
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_WithManualInputAndUseManualFalse_SetsInputOnCalculator()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ FailureMechanismTestHelper.SetSections(failureMechanism, new[]
+ {
+ FailureMechanismSectionTestFactory.CreateFailureMechanismSection()
+ });
+ StabilityPointStructuresFailureMechanismSectionResultOld sectionResult = failureMechanism.SectionResultsOld.Single();
+ sectionResult.UseManualAssembly = true;
+ sectionResult.ManualAssemblyProbability = new Random(39).NextDouble();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator;
+ FailureMechanismSectionAssemblyCalculatorOldStub sectionCalculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(
+ failureMechanism,
+ assessmentSection,
+ false);
+
+ // Assert
+ AssemblyToolTestHelper.AssertAreEqual(sectionCalculator.CombinedAssemblyOutput, calculator.FailureMechanismSectionAssemblies.Single());
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_AssemblyRan_ReturnsOutput()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator;
+
+ // Call
+ FailureMechanismAssembly actualOutput =
+ StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(
+ failureMechanism,
+ assessmentSection,
+ new Random(39).NextBoolean());
+
+ // Assert
+ Assert.AreSame(calculator.FailureMechanismAssemblyOutput, actualOutput);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_FailureMechanismCalculatorThrowsException_ThrowsAssemblyException()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator;
+ calculator.ThrowExceptionOnCalculate = true;
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(
+ failureMechanism, assessmentSection, new Random(39).NextBoolean());
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ Assert.AreEqual(innerException.Message, exception.Message);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_FailureMechanismSectionCalculatorThrowsException_ThrowsAssemblyException()
+ {
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ FailureMechanismTestHelper.SetSections(failureMechanism, new[]
+ {
+ FailureMechanismSectionTestFactory.CreateFailureMechanismSection()
+ });
+
+ var mocks = new MockRepository();
+ IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
+ mocks.ReplayAll();
+
+ using (new AssemblyToolCalculatorFactoryConfigOld())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
+ FailureMechanismSectionAssemblyCalculatorOldStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+ calculator.ThrowExceptionOnCalculateCombinedAssembly = true;
+
+ // Call
+ void Call() => StabilityPointStructuresFailureMechanismAssemblyFactoryOld.AssembleFailureMechanism(
+ failureMechanism, assessmentSection, 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);
+ mocks.VerifyAll();
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Fisheye: Tag f45746773b70d8f42fef2189c15edc2a62794dbe refers to a dead (removed) revision in file `Riskeer/StabilityPointStructures/test/Riskeer.StabilityPointStructures.Data.Test/StabilityPointStructuresFailureMechanismAssemblyFactoryTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?