Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs
===================================================================
diff -u -r2405096e924870d4acbad5651a3469be121ae1a8 -rb2c9c7dbf837ef7d5bc4002ae0237498bef9200e
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision 2405096e924870d4acbad5651a3469be121ae1a8)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision b2c9c7dbf837ef7d5bc4002ae0237498bef9200e)
@@ -94,7 +94,8 @@
return new[]
{
ExportableStabilityStoneCoverFailureMechanismFactory.CreateExportableStabilityStoneCoverFailureMechanism(assessmentSection.StabilityStoneCover),
- ExportableWaveImpactAsphaltCoverFailureMechanismFactory.CreateExportableWaveImpactAsphaltCoverFailureMechanism(assessmentSection.WaveImpactAsphaltCover)
+ ExportableWaveImpactAsphaltCoverFailureMechanismFactory.CreateExportableWaveImpactAsphaltCoverFailureMechanism(assessmentSection.WaveImpactAsphaltCover),
+ ExportableGrassCoverErosionOutwardsFailureMechanismFactory.CreateExportableGrassCoverErosionOutwardsFailureMechanism(assessmentSection.GrassCoverErosionOutwards)
};
}
}
Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Factories/ExportableGrassCoverErosionOutwardsFailureMechanismFactory.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Factories/ExportableGrassCoverErosionOutwardsFailureMechanismFactory.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Factories/ExportableGrassCoverErosionOutwardsFailureMechanismFactory.cs (revision b2c9c7dbf837ef7d5bc4002ae0237498bef9200e)
@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.Common.Data.Exceptions;
+using Ringtoets.GrassCoverErosionOutwards.Data;
+using Ringtoets.Integration.IO.Assembly;
+
+namespace Ringtoets.Integration.IO.Factories
+{
+ ///
+ /// Factory to create instances of
+ /// with assembly results for grass cover erosion outwards.
+ ///
+ public static class ExportableGrassCoverErosionOutwardsFailureMechanismFactory
+ {
+ private const ExportableFailureMechanismType failureMechanismCode = ExportableFailureMechanismType.GEBU;
+ 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 CreateExportableGrassCoverErosionOutwardsFailureMechanism(
+ GrassCoverErosionOutwardsFailureMechanism failureMechanism)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (!failureMechanism.IsRelevant)
+ {
+ return ExportableFailureMechanismFactory.CreateDefaultExportableFailureMechanismWithoutProbability(failureMechanismCode,
+ failureMechanismGroup,
+ failureMechanismAssemblyMethod);
+ }
+
+ FailureMechanismAssemblyCategoryGroup failureMechanismAssembly = GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.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)
+ {
+ GrassCoverErosionOutwardsFailureMechanismSectionResult failureMechanismSectionResult = failureMechanismSectionPair.Key;
+ FailureMechanismSectionAssemblyCategoryGroup simpleAssembly =
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(failureMechanismSectionResult);
+
+ FailureMechanismSectionAssemblyCategoryGroup detailedAssembly =
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(failureMechanismSectionResult);
+ FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly =
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(failureMechanismSectionResult);
+ FailureMechanismSectionAssemblyCategoryGroup combinedAssembly =
+ GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(failureMechanismSectionResult);
+
+ exportableResults.Add(
+ new ExportableAggregatedFailureMechanismSectionAssemblyResult(
+ failureMechanismSectionPair.Value,
+ ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(simpleAssembly, ExportableAssemblyMethod.WBI0E1),
+ 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 -r2405096e924870d4acbad5651a3469be121ae1a8 -rb2c9c7dbf837ef7d5bc4002ae0237498bef9200e
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision 2405096e924870d4acbad5651a3469be121ae1a8)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision b2c9c7dbf837ef7d5bc4002ae0237498bef9200e)
@@ -41,6 +41,7 @@
+
@@ -118,6 +119,11 @@
Ringtoets.GrassCoverErosionInwards.Data
False
+
+ {e7225477-577f-4a17-b7ec-6721158e1543}
+ Ringtoets.GrassCoverErosionOutwards.Data
+ False
+
{1c0017d8-35b5-4ca0-8fc7-a83f46dbdc99}
Ringtoets.HeightStructures.Data
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Factories/ExportableAssessmentSectionFactoryTest.cs
===================================================================
diff -u -r2405096e924870d4acbad5651a3469be121ae1a8 -rb2c9c7dbf837ef7d5bc4002ae0237498bef9200e
--- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Factories/ExportableAssessmentSectionFactoryTest.cs (.../ExportableAssessmentSectionFactoryTest.cs) (revision 2405096e924870d4acbad5651a3469be121ae1a8)
+++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Factories/ExportableAssessmentSectionFactoryTest.cs (.../ExportableAssessmentSectionFactoryTest.cs) (revision b2c9c7dbf837ef7d5bc4002ae0237498bef9200e)
@@ -11,6 +11,7 @@
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.TestUtil;
using Ringtoets.GrassCoverErosionInwards.Data;
+using Ringtoets.GrassCoverErosionOutwards.Data;
using Ringtoets.HeightStructures.Data;
using Ringtoets.Integration.Data;
using Ringtoets.Integration.IO.Assembly;
@@ -163,7 +164,7 @@
FailureMechanismAssemblyCalculatorStub failureMechanismAssemblyCalculator,
AssessmentSection assessmentSection)
{
- Assert.AreEqual(2, exportableFailureMechanisms.Count());
+ Assert.AreEqual(3, exportableFailureMechanisms.Count());
ExportableFailureMechanism exportableStabilityStoneCover = exportableFailureMechanisms.First();
Assert.AreEqual(failureMechanismAssemblyCalculator.FailureMechanismAssemblyCategoryGroupOutput, exportableStabilityStoneCover.FailureMechanismAssembly.AssemblyCategory);
@@ -180,6 +181,14 @@
WaveImpactAsphaltCoverFailureMechanism waveImpactAsphaltCover = assessmentSection.WaveImpactAsphaltCover;
Assert.AreEqual(waveImpactAsphaltCover.Sections.Count(), exportableWaveImpactAsphaltCover.Sections.Count());
Assert.AreEqual(waveImpactAsphaltCover.SectionResults.Count(), exportableWaveImpactAsphaltCover.SectionAssemblyResults.Count());
+
+ ExportableFailureMechanism exportableGrassCoverErosionOutwards = exportableFailureMechanisms.ElementAt(2);
+ Assert.AreEqual(failureMechanismAssemblyCalculator.FailureMechanismAssemblyCategoryGroupOutput, exportableGrassCoverErosionOutwards.FailureMechanismAssembly.AssemblyCategory);
+ Assert.AreEqual(ExportableFailureMechanismType.GEBU, exportableGrassCoverErosionOutwards.Code);
+ Assert.AreEqual(ExportableFailureMechanismGroup.Group3, exportableGrassCoverErosionOutwards.Group);
+ GrassCoverErosionOutwardsFailureMechanism grassCoverErosionOutwards = assessmentSection.GrassCoverErosionOutwards;
+ Assert.AreEqual(grassCoverErosionOutwards.Sections.Count(), exportableGrassCoverErosionOutwards.Sections.Count());
+ Assert.AreEqual(grassCoverErosionOutwards.SectionResults.Count(), exportableGrassCoverErosionOutwards.SectionAssemblyResults.Count());
}
}
}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Factories/ExportableGrassCoverErosionOutwardsFailureMechanismFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Factories/ExportableGrassCoverErosionOutwardsFailureMechanismFactoryTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Factories/ExportableGrassCoverErosionOutwardsFailureMechanismFactoryTest.cs (revision b2c9c7dbf837ef7d5bc4002ae0237498bef9200e)
@@ -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.GrassCoverErosionOutwards.Data;
+using Ringtoets.Integration.IO.Assembly;
+using Ringtoets.Integration.IO.Factories;
+using Ringtoets.Integration.IO.TestUtil;
+
+namespace Ringtoets.Integration.IO.Test.Factories
+{
+ [TestFixture]
+ public class ExportableGrassCoverErosionOutwardsFailureMechanismFactoryTest
+ {
+ [Test]
+ public void CreateExportableGrassCoverErosionOutwardsFailureMechanism_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () =>
+ ExportableGrassCoverErosionOutwardsFailureMechanismFactory.CreateExportableGrassCoverErosionOutwardsFailureMechanism(null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ }
+
+ [Test]
+ public void CreateExportableGrassCoverErosionOutwardsFailureMechanism_WithFailureMechanismNotRelevant_ReturnsDefaultExportableFailureMechanism()
+ {
+ // Setup
+ var random = new Random(21);
+ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism
+ {
+ IsRelevant = false
+ };
+ FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(2, 10));
+
+ // Call
+ ExportableFailureMechanism exportableFailureMechanism =
+ ExportableGrassCoverErosionOutwardsFailureMechanismFactory.CreateExportableGrassCoverErosionOutwardsFailureMechanism(failureMechanism);
+
+ // Assert
+ Assert.AreEqual(ExportableFailureMechanismType.GEBU, 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 CreateExportableGrassCoverErosionOutwardsFailureMechanism_WithFailureMechanismRelevant_ReturnsExportableFailureMechanism()
+ {
+ // Setup
+ var random = new Random(21);
+ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
+ 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 =
+ ExportableGrassCoverErosionOutwardsFailureMechanismFactory.CreateExportableGrassCoverErosionOutwardsFailureMechanism(failureMechanism);
+
+ // Assert
+ Assert.AreEqual(ExportableFailureMechanismType.GEBU, 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.WBI0E1,
+ 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 -r2405096e924870d4acbad5651a3469be121ae1a8 -rb2c9c7dbf837ef7d5bc4002ae0237498bef9200e
--- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision 2405096e924870d4acbad5651a3469be121ae1a8)
+++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision b2c9c7dbf837ef7d5bc4002ae0237498bef9200e)
@@ -43,6 +43,7 @@
+
@@ -107,6 +108,10 @@
{90DE728E-48EF-4665-AB38-3D88E41D9F4D}
Ringtoets.GrassCoverErosionInwards.Data
+
+ {E7225477-577F-4A17-B7EC-6721158E1543}
+ Ringtoets.GrassCoverErosionOutwards.Data
+
{1C0017D8-35B5-4CA0-8FC7-A83F46DBDC99}
Ringtoets.HeightStructures.Data