Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.cs
===================================================================
diff -u -r06800c4b5c53dd8a385a9f15ce44e9c4038a3726 -r9191cfb673ff1a5c9573f9aa0f7cc8b39fcb1b6f
--- Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.cs (.../StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.cs) (revision 06800c4b5c53dd8a385a9f15ce44e9c4038a3726)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Data/StandAlone/AssemblyFactories/StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.cs (.../StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.cs) (revision 9191cfb673ff1a5c9573f9aa0f7cc8b39fcb1b6f)
@@ -138,6 +138,27 @@
}
///
+ /// Gets the assembly category group of the given .
+ ///
+ /// The failure mechanism section result to get the assembly category group for.
+ /// A .
+ /// Thrown when any parameter is null.
+ /// Thrown when the
+ /// could not be created.
+ public static FailureMechanismSectionAssemblyCategoryGroup GetSectionAssemblyCategoryGroup(
+ StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult failureMechanismSectionResult)
+ {
+ if (failureMechanismSectionResult == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanismSectionResult));
+ }
+
+ return failureMechanismSectionResult.UseManualAssemblyCategoryGroup
+ ? failureMechanismSectionResult.ManualAssemblyCategoryGroup
+ : AssembleCombinedAssessment(failureMechanismSectionResult);
+ }
+
+ ///
/// Assembles the failure mechanism assembly.
///
/// The failure mechanism to assemble for.
@@ -159,9 +180,7 @@
}
IEnumerable sectionAssemblies =
- failureMechanism.SectionResults.Select(sectionResult => sectionResult.UseManualAssemblyCategoryGroup
- ? sectionResult.ManualAssemblyCategoryGroup
- : AssembleCombinedAssessment(sectionResult)).ToArray();
+ failureMechanism.SectionResults.Select(GetSectionAssemblyCategoryGroup).ToArray();
IAssemblyToolCalculatorFactory calculatorFactory = AssemblyToolCalculatorFactory.Instance;
IFailureMechanismAssemblyCalculator calculator =
Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactoryTest.cs
===================================================================
diff -u -r5e0a72833803f6a51d6e70a166bdd48d1d4418c7 -r9191cfb673ff1a5c9573f9aa0f7cc8b39fcb1b6f
--- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactoryTest.cs (.../StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactoryTest.cs) (revision 5e0a72833803f6a51d6e70a166bdd48d1d4418c7)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/StandAlone/AssemblyFactories/StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactoryTest.cs (.../StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactoryTest.cs) (revision 9191cfb673ff1a5c9573f9aa0f7cc8b39fcb1b6f)
@@ -290,6 +290,109 @@
#endregion
+ #region GetSectionAssemblyCategoryGroup
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_FailureMechanismSectionResultNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.GetSectionAssemblyCategoryGroup(
+ null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanismSectionResult", exception.ParamName);
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_WithoutManualInput_SetsInputOnCalculator()
+ {
+ // Setup
+ var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ using (new AssemblyToolCalculatorFactoryConfig())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.GetSectionAssemblyCategoryGroup(
+ sectionResult);
+
+ // Assert
+ FailureMechanismSectionAssemblyCategoryGroup expectedSimpleAssembly = StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleSimpleAssessment(
+ sectionResult);
+ FailureMechanismSectionAssemblyCategoryGroup expectedTailorMadeAssembly = StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(
+ sectionResult);
+
+ Assert.AreEqual(expectedSimpleAssembly, calculator.CombinedSimpleAssemblyGroupInput);
+ Assert.AreEqual(expectedTailorMadeAssembly, calculator.CombinedTailorMadeAssemblyGroupInput);
+ }
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_WithoutManualInput_ReturnsOutput()
+ {
+ // Setup
+ var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ using (new AssemblyToolCalculatorFactoryConfig())
+ {
+ // Call
+ FailureMechanismSectionAssemblyCategoryGroup categoryGroup = StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.GetSectionAssemblyCategoryGroup(
+ sectionResult);
+
+ // Assert
+ FailureMechanismSectionAssemblyCategoryGroup expectedAssembly = StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleCombinedAssessment(
+ sectionResult);
+ Assert.AreEqual(categoryGroup, expectedAssembly);
+ }
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_WithManualInput_ReturnsOutput()
+ {
+ // Setup
+ var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ UseManualAssemblyCategoryGroup = true,
+ ManualAssemblyCategoryGroup = new Random(39).NextEnumValue()
+ };
+
+ // Call
+ FailureMechanismSectionAssemblyCategoryGroup categoryGroup = StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.GetSectionAssemblyCategoryGroup(
+ sectionResult);
+
+ // Assert
+ Assert.AreEqual(categoryGroup, sectionResult.ManualAssemblyCategoryGroup);
+ }
+
+ [Test]
+ public void GetSectionAssemblyCategoryGroup_WithoutManualInputAndCalculatorThrowsException_ThrowsAssemblyException()
+ {
+ // Setup
+ var sectionResult = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ using (new AssemblyToolCalculatorFactoryConfig())
+ {
+ var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+ calculator.ThrowExceptionOnCalculateCombinedAssembly = true;
+
+ // Call
+ TestDelegate call = () => StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.GetSectionAssemblyCategoryGroup(
+ sectionResult);
+
+ // 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]
@@ -313,7 +416,7 @@
};
// Call
- FailureMechanismAssemblyCategoryGroup category =
+ FailureMechanismAssemblyCategoryGroup category =
StrengthStabilityLengthwiseConstructionFailureMechanismAssemblyFactory.AssembleFailureMechanism(failureMechanism);
// Assert