Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Factories/ExportableStabilityStoneCoverFailureMechanismFactory.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Factories/ExportableStabilityStoneCoverFailureMechanismFactory.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Factories/ExportableStabilityStoneCoverFailureMechanismFactory.cs (revision c8d43f02e37553fa668bfbbb75257f9e64f00542)
@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.Common.Data.Exceptions;
+using Ringtoets.Integration.IO.Assembly;
+using Ringtoets.StabilityStoneCover.Data;
+
+namespace Ringtoets.Integration.IO.Factories
+{
+ ///
+ /// Factory to create instances of
+ /// with assembly results for stability stone cover.
+ ///
+ public static class ExportableStabilityStoneCoverFailureMechanismFactory
+ {
+ private const ExportableFailureMechanismType failureMechanismCode = ExportableFailureMechanismType.ZST;
+ private const ExportableFailureMechanismGroup failureMechanismGroup = ExportableFailureMechanismGroup.Group3;
+ private const ExportableAssemblyMethod failureMechanismAssemblyMethod = ExportableAssemblyMethod.WBI1A1;
+
+ ///
+ /// Creates a
+ /// with assmebly results based on the input parameters.
+ ///
+ /// The to create a
+ /// for.
+ /// A with assembly results.
+ /// Thrown when any parameter is null.
+ /// Thrown when assembly results cannot be created.
+ public static ExportableFailureMechanism CreateExportableStabilityStoneCoverFailureMechanism(
+ StabilityStoneCoverFailureMechanism failureMechanism)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (!failureMechanism.IsRelevant)
+ {
+ return ExportableFailureMechanismFactory.CreateDefaultExportableFailureMechanismWithoutProbability(failureMechanismCode,
+ failureMechanismGroup,
+ failureMechanismAssemblyMethod);
+ }
+
+ FailureMechanismAssemblyCategoryGroup failureMechanismAssembly = StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(failureMechanism);
+
+ Dictionary failureMechanismSectionsLookup =
+ failureMechanism.SectionResults
+ .ToDictionary(sectionResult => sectionResult,
+ sectionResult => ExportableFailureMechanismSectionFactory.CreateExportableFailureMechanismSection(sectionResult.Section));
+
+ return new ExportableFailureMechanism(
+ new ExportableFailureMechanismAssemblyResult(failureMechanismAssemblyMethod,
+ failureMechanismAssembly),
+ failureMechanismSectionsLookup.Values, CreateFailureMechanismSectionResults(failureMechanismSectionsLookup),
+ failureMechanismCode,
+ failureMechanismGroup);
+ }
+
+ ///
+ /// Creates a collection of
+ /// with assembly results based on the sections in .
+ ///
+ /// The mapping between the
+ /// and .
+ /// A collection of .
+ /// Thrown when assembly results cannot be created.
+ private static IEnumerable CreateFailureMechanismSectionResults(
+ Dictionary failureMechanismSections)
+ {
+ var exportableResults = new List();
+ foreach (KeyValuePair failureMechanismSectionPair in failureMechanismSections)
+ {
+ StabilityStoneCoverFailureMechanismSectionResult failureMechanismSectionResult = failureMechanismSectionPair.Key;
+ FailureMechanismSectionAssemblyCategoryGroup simpleAssembly =
+ StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment(failureMechanismSectionResult);
+
+ FailureMechanismSectionAssemblyCategoryGroup detailedAssembly =
+ StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleDetailedAssessment(failureMechanismSectionResult);
+ FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly =
+ StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(failureMechanismSectionResult);
+ FailureMechanismSectionAssemblyCategoryGroup combinedAssembly =
+ StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment(failureMechanismSectionResult);
+
+ exportableResults.Add(
+ new ExportableAggregatedFailureMechanismSectionAssemblyResult(
+ failureMechanismSectionPair.Value,
+ ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(simpleAssembly, ExportableAssemblyMethod.WBI0E3),
+ ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(detailedAssembly, ExportableAssemblyMethod.WBI0G6),
+ ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(tailorMadeAssembly, ExportableAssemblyMethod.WBI0T4),
+ ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(combinedAssembly, ExportableAssemblyMethod.WBI0A1)));
+ }
+
+ return exportableResults;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj
===================================================================
diff -u -r67ccd648ef0db4b9e75c60d2e060128fa8f54691 -rc8d43f02e37553fa668bfbbb75257f9e64f00542
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision 67ccd648ef0db4b9e75c60d2e060128fa8f54691)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision c8d43f02e37553fa668bfbbb75257f9e64f00542)
@@ -46,6 +46,7 @@
+
@@ -136,6 +137,11 @@
Ringtoets.StabilityPointStructures.Data
False
+
+ {b479e3af-7c34-488c-bb73-d324100d36c9}
+ Ringtoets.StabilityStoneCover.Data
+ False
+
{11F1F874-45AF-43E4-8AE5-15A5C9593E28}
Ringtoets.Integration.Data
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Factories/ExportableStabilityStoneCoverFailureMechanismFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Factories/ExportableStabilityStoneCoverFailureMechanismFactoryTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Factories/ExportableStabilityStoneCoverFailureMechanismFactoryTest.cs (revision c8d43f02e37553fa668bfbbb75257f9e64f00542)
@@ -0,0 +1,146 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.AssemblyTool.KernelWrapper.Calculators;
+using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators;
+using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Integration.IO.Assembly;
+using Ringtoets.Integration.IO.Factories;
+using Ringtoets.Integration.IO.TestUtil;
+using Ringtoets.StabilityStoneCover.Data;
+
+namespace Ringtoets.Integration.IO.Test.Factories
+{
+ [TestFixture]
+ public class ExportableStabilityStoneCoverFailureMechanismFactoryTest
+ {
+ [Test]
+ public void CreateExportableStabilityStoneCoverFailureMechanism_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () =>
+ ExportableStabilityStoneCoverFailureMechanismFactory.CreateExportableStabilityStoneCoverFailureMechanism(null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ }
+
+ [Test]
+ public void CreateExportableStabilityStoneCoverFailureMechanism_WithFailureMechanismNotRelevant_ReturnsDefaultExportableFailureMechanism()
+ {
+ // Setup
+ var random = new Random(21);
+ var failureMechanism = new StabilityStoneCoverFailureMechanism
+ {
+ IsRelevant = false
+ };
+ FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(2, 10));
+
+ // Call
+ ExportableFailureMechanism exportableFailureMechanism =
+ ExportableStabilityStoneCoverFailureMechanismFactory.CreateExportableStabilityStoneCoverFailureMechanism(failureMechanism);
+
+ // Assert
+ Assert.AreEqual(ExportableFailureMechanismType.ZST, exportableFailureMechanism.Code);
+ Assert.AreEqual(ExportableFailureMechanismGroup.Group3, exportableFailureMechanism.Group);
+
+ ExportableFailureMechanismAssemblyResult failureMechanismAssemblyResult = exportableFailureMechanism.FailureMechanismAssembly;
+ Assert.AreEqual(ExportableAssemblyMethod.WBI1A1, failureMechanismAssemblyResult.AssemblyMethod);
+ Assert.AreEqual(FailureMechanismAssemblyCategoryGroup.NotApplicable, failureMechanismAssemblyResult.AssemblyCategory);
+
+ CollectionAssert.IsEmpty(exportableFailureMechanism.Sections);
+ CollectionAssert.IsEmpty(exportableFailureMechanism.SectionAssemblyResults);
+ }
+
+ [Test]
+ public void CreateExportableStabilityStoneCoverFailureMechanism_WithFailureMechanismRelevant_ReturnsExportableFailureMechanism()
+ {
+ // Setup
+ var random = new Random(21);
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(2, 10));
+
+ using (new AssemblyToolCalculatorFactoryConfig())
+ {
+ var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ FailureMechanismAssemblyCalculatorStub failureMechanismAssemblyCalculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator;
+ FailureMechanismSectionAssemblyCalculatorStub failureMechanismSectionAssemblyCalculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ // Call
+ ExportableFailureMechanism exportableFailureMechanism =
+ ExportableStabilityStoneCoverFailureMechanismFactory.CreateExportableStabilityStoneCoverFailureMechanism(failureMechanism);
+
+ // Assert
+ Assert.AreEqual(ExportableFailureMechanismType.ZST, exportableFailureMechanism.Code);
+ Assert.AreEqual(ExportableFailureMechanismGroup.Group3, exportableFailureMechanism.Group);
+
+ FailureMechanismAssemblyCategoryGroup? calculatorOutput = failureMechanismAssemblyCalculator.FailureMechanismAssemblyCategoryGroupOutput;
+ ExportableFailureMechanismAssemblyResult exportableFailureMechanismAssembly = exportableFailureMechanism.FailureMechanismAssembly;
+ Assert.AreEqual(calculatorOutput.Value, exportableFailureMechanismAssembly.AssemblyCategory);
+ Assert.AreEqual(ExportableAssemblyMethod.WBI1A1, exportableFailureMechanismAssembly.AssemblyMethod);
+
+ ExportableFailureMechanismSectionTestHelper.AssertExportableFailureMechanismSections(failureMechanism.Sections, exportableFailureMechanism.Sections);
+ AssertExportableFailureMechanismSectionResults(failureMechanismSectionAssemblyCalculator.SimpleAssessmentAssemblyOutput.Group,
+ failureMechanismSectionAssemblyCalculator.DetailedAssessmentAssemblyGroupOutput.Value,
+ failureMechanismSectionAssemblyCalculator.TailorMadeAssemblyCategoryOutput.Value,
+ failureMechanismSectionAssemblyCalculator.CombinedAssemblyCategoryOutput.Value,
+ exportableFailureMechanism.Sections,
+ exportableFailureMechanism.SectionAssemblyResults.Cast());
+ }
+ }
+
+ private static void AssertExportableFailureMechanismSectionResults(FailureMechanismSectionAssemblyCategoryGroup expectedSimpleAssembly,
+ FailureMechanismSectionAssemblyCategoryGroup expectedDetailedAssembly,
+ FailureMechanismSectionAssemblyCategoryGroup expectedTailorMadeAssembly,
+ FailureMechanismSectionAssemblyCategoryGroup expectedCombinedAssembly,
+ IEnumerable sections,
+ IEnumerable results)
+ {
+ int expectedNrOfResults = sections.Count();
+ Assert.AreEqual(expectedNrOfResults, results.Count());
+
+ for (var i = 0; i < expectedNrOfResults; i++)
+ {
+ ExportableFailureMechanismSection section = sections.ElementAt(i);
+ ExportableAggregatedFailureMechanismSectionAssemblyResult result = results.ElementAt(i);
+
+ AssertExportableFailureMechanismSectionResult(expectedSimpleAssembly,
+ expectedDetailedAssembly,
+ expectedTailorMadeAssembly,
+ expectedCombinedAssembly,
+ section,
+ result);
+ }
+ }
+
+ private static void AssertExportableFailureMechanismSectionResult(FailureMechanismSectionAssemblyCategoryGroup expectedSimpleAssembly,
+ FailureMechanismSectionAssemblyCategoryGroup expectedDetailedAssembly,
+ FailureMechanismSectionAssemblyCategoryGroup expectedTailorMadeAssembly,
+ FailureMechanismSectionAssemblyCategoryGroup expectedCombinedAssembly,
+ ExportableFailureMechanismSection expectedSection,
+ ExportableAggregatedFailureMechanismSectionAssemblyResult actualResult)
+ {
+ Assert.AreSame(expectedSection, actualResult.FailureMechanismSection);
+
+ ExportableSectionAssemblyResultTestHelper.AssertExportableSectionAssemblyResult(expectedSimpleAssembly,
+ ExportableAssemblyMethod.WBI0E3,
+ actualResult.SimpleAssembly);
+
+ ExportableSectionAssemblyResultTestHelper.AssertExportableSectionAssemblyResult(expectedDetailedAssembly,
+ ExportableAssemblyMethod.WBI0G6,
+ actualResult.DetailedAssembly);
+
+ ExportableSectionAssemblyResultTestHelper.AssertExportableSectionAssemblyResult(expectedTailorMadeAssembly,
+ ExportableAssemblyMethod.WBI0T4,
+ actualResult.TailorMadeAssembly);
+
+ ExportableSectionAssemblyResultTestHelper.AssertExportableSectionAssemblyResult(expectedCombinedAssembly,
+ ExportableAssemblyMethod.WBI0A1,
+ actualResult.CombinedAssembly);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj
===================================================================
diff -u -r67ccd648ef0db4b9e75c60d2e060128fa8f54691 -rc8d43f02e37553fa668bfbbb75257f9e64f00542
--- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision 67ccd648ef0db4b9e75c60d2e060128fa8f54691)
+++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision c8d43f02e37553fa668bfbbb75257f9e64f00542)
@@ -48,6 +48,7 @@
+
@@ -121,6 +122,10 @@
{3D4B9740-8348-4434-8D77-B611FC6EE57F}
Ringtoets.StabilityPointStructures.Data
+
+ {b479e3af-7c34-488c-bb73-d324100d36c9}
+ Ringtoets.StabilityStoneCover.Data
+
{11F1F874-45AF-43E4-8AE5-15A5C9593E28}
Ringtoets.Integration.Data
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.TestUtil/ExportableSectionAssemblyResultTestHelper.cs
===================================================================
diff -u -rf5292d182348de2ddb7760b7e3f27b0f9cfc9177 -rc8d43f02e37553fa668bfbbb75257f9e64f00542
--- Ringtoets/Integration/test/Ringtoets.Integration.IO.TestUtil/ExportableSectionAssemblyResultTestHelper.cs (.../ExportableSectionAssemblyResultTestHelper.cs) (revision f5292d182348de2ddb7760b7e3f27b0f9cfc9177)
+++ Ringtoets/Integration/test/Ringtoets.Integration.IO.TestUtil/ExportableSectionAssemblyResultTestHelper.cs (.../ExportableSectionAssemblyResultTestHelper.cs) (revision c8d43f02e37553fa668bfbbb75257f9e64f00542)
@@ -21,9 +21,24 @@
ExportableAssemblyMethod assemblyMethod,
ExportableSectionAssemblyResultWithProbability exportableSectionAssemblyResult)
{
- Assert.AreEqual(assemblyMethod, exportableSectionAssemblyResult.AssemblyMethod);
- Assert.AreEqual(assemblyResult.Group, exportableSectionAssemblyResult.AssemblyCategory);
+ AssertExportableSectionAssemblyResult(assemblyResult.Group, assemblyMethod, exportableSectionAssemblyResult);
Assert.AreEqual(assemblyResult.Probability, exportableSectionAssemblyResult.Probability);
}
+
+ ///
+ /// Asserts a
+ /// against the assembly result and the method which was used to generate the result.
+ ///
+ /// The expected .
+ /// The which was
+ /// used to generate the result.
+ /// The to assert.
+ public static void AssertExportableSectionAssemblyResult(FailureMechanismSectionAssemblyCategoryGroup assemblyResult,
+ ExportableAssemblyMethod assemblyMethod,
+ ExportableSectionAssemblyResult exportableSectionAssemblyResult)
+ {
+ Assert.AreEqual(assemblyMethod, exportableSectionAssemblyResult.AssemblyMethod);
+ Assert.AreEqual(assemblyResult, exportableSectionAssemblyResult.AssemblyCategory);
+ }
}
}
\ No newline at end of file