Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs
===================================================================
diff -u -r6ade88c0cbceb0799e6f48f2a646a3bfebfb00df -rb25d71c274bf802dc8dd9fce8c69fd8263f7c054
--- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision 6ade88c0cbceb0799e6f48f2a646a3bfebfb00df)
+++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision b25d71c274bf802dc8dd9fce8c69fd8263f7c054)
@@ -67,7 +67,8 @@
/// An with assembly results.
/// Thrown when any parameter is null.
/// Thrown when no reference line is set for .
- /// Thrown when assembly results cannot be created for .
+ /// Thrown when assembly results cannot be created for
+ /// .
/// Thrown when assembly results are invalid and cannot be exported.
public static ExportableAssessmentSection CreateExportableAssessmentSection(IdentifierGenerator idGenerator, AssessmentSection assessmentSection)
{
@@ -92,17 +93,19 @@
CreateExportableFailureMechanismSectionCollections(idGenerator, registry, assessmentSection, combinedSectionAssemblyResults),
CreateExportableAssessmentSectionAssemblyResult(idGenerator, assessmentSection),
CreateExportableFailureMechanisms(idGenerator, registry, assessmentSection),
- CreateExportableCombinedSectionAssemblyCollection(assessmentSection, combinedSectionAssemblyResults));
+ CreateExportableCombinedSectionAssemblyCollection(idGenerator, registry, assessmentSection, combinedSectionAssemblyResults));
}
///
/// Creates an with the assembly result
/// based on .
///
/// The generator to generate ids for the exportable components.
- /// The assessment section to create an for.
+ /// The assessment section to create an
+ /// for.
/// An with assembly result.
- /// Thrown when assembly result cannot be created for .
+ /// Thrown when assembly result cannot be created for
+ /// .
private static ExportableAssessmentSectionAssemblyResult CreateExportableAssessmentSectionAssemblyResult(IdentifierGenerator idGenerator,
AssessmentSection assessmentSection)
{
@@ -116,7 +119,8 @@
}
///
- /// Converts an into an .
+ /// Converts an into an
+ /// .
///
/// The to convert.
/// The converted .
@@ -161,7 +165,8 @@
/// with probability for.
/// A collection of based on failure
/// mechanisms that are in assembly.
- /// Thrown when assembly results cannot be created for .
+ /// Thrown when assembly results cannot be created for
+ /// .
/// Thrown when assembly results are invalid and cannot be exported.
private static IEnumerable CreateExportableFailureMechanisms(
IdentifierGenerator idGenerator, ExportableModelRegistry registry, AssessmentSection assessmentSection)
@@ -253,10 +258,12 @@
/// The failure mechanism to export.
/// The assessment section the failure mechanism belongs to.
/// The to assemble the failure mechanism.
- /// The to assemble the failure mechanism section.
+ /// The to assemble the failure
+ /// mechanism section.
/// The type of failure mechanism.
/// The type of section result.
- /// Thrown when assembly results cannot be created for .
+ /// Thrown when assembly results cannot be created for
+ /// .
/// Thrown when assembly results are invalid and cannot be exported.
private static void AddGenericFailureMechanismWhenInAssembly(
IdentifierGenerator idGenerator, ExportableModelRegistry registry, List exportableFailureMechanisms,
@@ -285,31 +292,35 @@
failureMechanismsInAssembly.Select(failureMechanism => ExportableFailureMechanismSectionCollectionFactory.CreateExportableFailureMechanismSectionCollection(
idGenerator, registry, failureMechanism.Sections))
.ToArray();
-
+
var failureMechanismSectionCollections = new List();
failureMechanismSectionCollections.AddRange(failureMechanismsInAssemblySectionCollections);
if (combinedSectionAssemblyResults.Any())
{
failureMechanismSectionCollections.Add(ExportableFailureMechanismSectionCollectionFactory.CreateExportableFailureMechanismSectionCollection(
idGenerator, registry, assessmentSection.ReferenceLine, combinedSectionAssemblyResults));
}
-
+
return failureMechanismSectionCollections;
}
///
/// Creates a collection of based on .
///
- /// The assessment section to create a collection of for.
- /// The collection of .
+ /// The generator to generate ids for the exportable components.
+ /// The to keep track of the created items.
+ /// The assessment section to create a collection of
+ /// for.
+ /// The collection of
+ /// .
/// An of .
/// Thrown when assembly results are invalid and cannot be exported.
private static IEnumerable CreateExportableCombinedSectionAssemblyCollection(
- AssessmentSection assessmentSection, IEnumerable combinedFailureMechanismSectionAssemblyResults)
+ IdentifierGenerator idGenerator, ExportableModelRegistry registry, AssessmentSection assessmentSection,
+ IEnumerable combinedFailureMechanismSectionAssemblyResults)
{
return ExportableCombinedSectionAssemblyFactory.CreateExportableCombinedSectionAssemblyCollection(
- combinedFailureMechanismSectionAssemblyResults,
- assessmentSection);
+ idGenerator, registry, combinedFailureMechanismSectionAssemblyResults, assessmentSection);
}
}
}
\ No newline at end of file
Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableCombinedSectionAssemblyFactory.cs
===================================================================
diff -u -r67b3d776bcd2a24360d3187557b5aaa6ba74f7c9 -rb25d71c274bf802dc8dd9fce8c69fd8263f7c054
--- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableCombinedSectionAssemblyFactory.cs (.../ExportableCombinedSectionAssemblyFactory.cs) (revision 67b3d776bcd2a24360d3187557b5aaa6ba74f7c9)
+++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableCombinedSectionAssemblyFactory.cs (.../ExportableCombinedSectionAssemblyFactory.cs) (revision b25d71c274bf802dc8dd9fce8c69fd8263f7c054)
@@ -30,7 +30,8 @@
using Riskeer.Integration.Data;
using Riskeer.Integration.Data.Assembly;
using Riskeer.Integration.IO.Exceptions;
-using Riskeer.Integration.Util;
+using Riskeer.Integration.IO.Helpers;
+using Riskeer.Integration.IO.Properties;
namespace Riskeer.Integration.IO.Factories
{
@@ -43,6 +44,8 @@
/// Creates a collection of
/// based on .
///
+ /// The generator to generate ids for the exportable components.
+ /// The to keep track of the created items.
/// A collection of combined section results to
/// create a collection of for.
/// The the section results belong to.
@@ -51,9 +54,20 @@
/// Thrown when
/// is invalid and cannot be exported.
public static IEnumerable CreateExportableCombinedSectionAssemblyCollection(
+ IdentifierGenerator idGenerator, ExportableModelRegistry registry,
IEnumerable combinedSectionAssemblyResults,
AssessmentSection assessmentSection)
{
+ if (idGenerator == null)
+ {
+ throw new ArgumentNullException(nameof(idGenerator));
+ }
+
+ if (registry == null)
+ {
+ throw new ArgumentNullException(nameof(registry));
+ }
+
if (combinedSectionAssemblyResults == null)
{
throw new ArgumentNullException(nameof(combinedSectionAssemblyResults));
@@ -72,15 +86,11 @@
{
throw new AssemblyFactoryException("The assembly result is invalid and cannot be created.");
}
-
- var exportableSection = new ExportableCombinedFailureMechanismSection(
- "id", FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(
- assessmentSection.ReferenceLine, assemblyResult.SectionStart, assemblyResult.SectionEnd),
- assemblyResult.SectionStart, assemblyResult.SectionEnd,
- ExportableAssemblyMethodConverter.ConvertTo(assemblyResult.CommonSectionAssemblyMethod));
+ ExportableCombinedFailureMechanismSection exportableSection = registry.Get(assemblyResult);
+
var exportableSectionResult = new ExportableCombinedSectionAssembly(
- "id", exportableSection, assemblyResult.TotalResult,
+ idGenerator.GetNewId(Resources.ExportableCombinedSectionAssembly_IdPrefix), exportableSection, assemblyResult.TotalResult,
ExportableAssemblyMethodConverter.ConvertTo(assemblyResult.CombinedSectionResultAssemblyMethod),
CreateFailureMechanismCombinedSectionAssemblyResults(assemblyResult, assessmentSection));
Index: Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -r84db10065dd9b7c393da13a6db0b01bf122aba80 -rb25d71c274bf802dc8dd9fce8c69fd8263f7c054
--- Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 84db10065dd9b7c393da13a6db0b01bf122aba80)
+++ Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision b25d71c274bf802dc8dd9fce8c69fd8263f7c054)
@@ -136,6 +136,15 @@
}
///
+ /// Looks up a localized string similar to Gf.
+ ///
+ public static string ExportableCombinedSectionAssembly_IdPrefix {
+ get {
+ return ResourceManager.GetString("ExportableCombinedSectionAssembly_IdPrefix", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Fm.
///
public static string ExportableFailureMechanism_IdPrefix {
Index: Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.resx
===================================================================
diff -u -r84db10065dd9b7c393da13a6db0b01bf122aba80 -rb25d71c274bf802dc8dd9fce8c69fd8263f7c054
--- Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.resx (.../Resources.resx) (revision 84db10065dd9b7c393da13a6db0b01bf122aba80)
+++ Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.resx (.../Resources.resx) (revision b25d71c274bf802dc8dd9fce8c69fd8263f7c054)
@@ -206,4 +206,7 @@
Fa
+
+ Gf
+
\ No newline at end of file
Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableCombinedSectionAssemblyFactoryTest.cs
===================================================================
diff -u -r3f16d047b4c6d2a626357315f8ae38d678be17bb -rb25d71c274bf802dc8dd9fce8c69fd8263f7c054
--- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableCombinedSectionAssemblyFactoryTest.cs (.../ExportableCombinedSectionAssemblyFactoryTest.cs) (revision 3f16d047b4c6d2a626357315f8ae38d678be17bb)
+++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableCombinedSectionAssemblyFactoryTest.cs (.../ExportableCombinedSectionAssemblyFactoryTest.cs) (revision b25d71c274bf802dc8dd9fce8c69fd8263f7c054)
@@ -35,19 +35,45 @@
using Riskeer.Integration.Data.TestUtil;
using Riskeer.Integration.IO.Exceptions;
using Riskeer.Integration.IO.Factories;
-using Riskeer.Integration.Util;
+using Riskeer.Integration.IO.Helpers;
namespace Riskeer.Integration.IO.Test.Factories
{
[TestFixture]
public class ExportableCombinedSectionAssemblyFactoryTest
{
[Test]
+ public void CreateExportableCombinedSectionAssemblyCollection_IdGeneratorNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => ExportableCombinedSectionAssemblyFactory.CreateExportableCombinedSectionAssemblyCollection(
+ null, new ExportableModelRegistry(), Enumerable.Empty(),
+ new AssessmentSection(AssessmentSectionComposition.Dike));
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("idGenerator", exception.ParamName);
+ }
+
+ [Test]
+ public void CreateExportableCombinedSectionAssemblyCollection_RegistryNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => ExportableCombinedSectionAssemblyFactory.CreateExportableCombinedSectionAssemblyCollection(
+ new IdentifierGenerator(), null, Enumerable.Empty(),
+ new AssessmentSection(AssessmentSectionComposition.Dike));
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("registry", exception.ParamName);
+ }
+
+ [Test]
public void CreateExportableCombinedSectionAssemblyCollection_CombinedSectionAssemblyResultsNull_ThrowsArgumentNullException()
{
// Call
void Call() => ExportableCombinedSectionAssemblyFactory.CreateExportableCombinedSectionAssemblyCollection(
- null, new AssessmentSection(AssessmentSectionComposition.Dike));
+ new IdentifierGenerator(), new ExportableModelRegistry(), null, new AssessmentSection(AssessmentSectionComposition.Dike));
// Assert
var exception = Assert.Throws(Call);
@@ -59,7 +85,7 @@
{
// Call
void Call() => ExportableCombinedSectionAssemblyFactory.CreateExportableCombinedSectionAssemblyCollection(
- Enumerable.Empty(), null);
+ new IdentifierGenerator(), new ExportableModelRegistry(), Enumerable.Empty(), null);
// Assert
var exception = Assert.Throws(Call);
@@ -79,12 +105,13 @@
CombinedFailureMechanismSectionAssemblyResult[] assemblyResults =
{
new CombinedFailureMechanismSectionAssemblyResult(random.NextDouble(), random.NextDouble(), assemblyGroup,
- random.NextEnumValue(), random.NextEnumValue(), random.NextEnumValue(),
- new CombinedFailureMechanismSectionAssemblyResult.ConstructionProperties())
+ random.NextEnumValue(), random.NextEnumValue(), random.NextEnumValue(),
+ new CombinedFailureMechanismSectionAssemblyResult.ConstructionProperties())
};
// Call
- void Call() => ExportableCombinedSectionAssemblyFactory.CreateExportableCombinedSectionAssemblyCollection(assemblyResults, assessmentSection);
+ void Call() => ExportableCombinedSectionAssemblyFactory.CreateExportableCombinedSectionAssemblyCollection(
+ new IdentifierGenerator(), new ExportableModelRegistry(), assemblyResults, assessmentSection);
// Assert
var exception = Assert.Throws(Call);
@@ -122,20 +149,32 @@
CombinedFailureMechanismSectionAssemblyResultTestFactory.Create(22, hasAssemblyGroupResults)
};
+ var idGenerator = new IdentifierGenerator();
+ var registry = new ExportableModelRegistry();
+ RegisterFailureMechanismSections(registry, assessmentSection.ReferenceLine, assemblyResults);
+
// Call
IEnumerable exportableCombinedSectionAssemblies =
- ExportableCombinedSectionAssemblyFactory.CreateExportableCombinedSectionAssemblyCollection(assemblyResults, assessmentSection);
+ ExportableCombinedSectionAssemblyFactory.CreateExportableCombinedSectionAssemblyCollection(
+ idGenerator, registry, assemblyResults, assessmentSection);
// Assert
- AssertCombinedFailureMechanismSectionAssemblyResults(
- assemblyResults, exportableCombinedSectionAssemblies,
- assessmentSection.ReferenceLine, hasAssemblyGroupResults);
+ AssertCombinedFailureMechanismSectionAssemblyResults(registry, assemblyResults, exportableCombinedSectionAssemblies,
+ hasAssemblyGroupResults);
}
- private static void AssertCombinedFailureMechanismSectionAssemblyResults(IEnumerable assemblyResults,
- IEnumerable exportableCombinedSectionAssemblies,
- ReferenceLine referenceLine, bool hasAssemblyGroupResults)
+ private static void RegisterFailureMechanismSections(ExportableModelRegistry registry, ReferenceLine referenceLine,
+ IEnumerable assemblyResults)
{
+ ExportableFailureMechanismSectionCollectionFactory.CreateExportableFailureMechanismSectionCollection(new IdentifierGenerator(), registry, referenceLine, assemblyResults);
+ }
+
+ private static void AssertCombinedFailureMechanismSectionAssemblyResults(
+ ExportableModelRegistry registry,
+ IEnumerable assemblyResults,
+ IEnumerable exportableCombinedSectionAssemblies,
+ bool hasAssemblyGroupResults)
+ {
int expectedNrOfSections = assemblyResults.Count();
Assert.AreEqual(expectedNrOfSections, exportableCombinedSectionAssemblies.Count());
@@ -144,34 +183,20 @@
CombinedFailureMechanismSectionAssemblyResult combinedFailureMechanismSectionAssemblyResult = assemblyResults.ElementAt(i);
ExportableCombinedSectionAssembly exportableCombinedSectionAssembly = exportableCombinedSectionAssemblies.ElementAt(i);
- AssertExportableCombinedFailureMechanismSection(combinedFailureMechanismSectionAssemblyResult, exportableCombinedSectionAssembly.Section, referenceLine);
AssertExportableCombinedFailureMechanismSectionResult(
- combinedFailureMechanismSectionAssemblyResult, exportableCombinedSectionAssembly.Section, exportableCombinedSectionAssembly,
- hasAssemblyGroupResults);
+ i, combinedFailureMechanismSectionAssemblyResult, registry.Get(combinedFailureMechanismSectionAssemblyResult),
+ exportableCombinedSectionAssembly, hasAssemblyGroupResults);
}
}
- private static void AssertExportableCombinedFailureMechanismSection(CombinedFailureMechanismSectionAssemblyResult expectedSection,
- ExportableCombinedFailureMechanismSection actualSection,
- ReferenceLine referenceLine)
- {
- IEnumerable expectedGeometry = FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(
- referenceLine,
- actualSection.StartDistance,
- actualSection.EndDistance).ToArray();
- CollectionAssert.IsNotEmpty(expectedGeometry);
-
- Assert.AreEqual(expectedSection.SectionStart, actualSection.StartDistance);
- Assert.AreEqual(expectedSection.SectionEnd, actualSection.EndDistance);
- CollectionAssert.AreEqual(expectedGeometry, actualSection.Geometry);
- Assert.AreEqual(ExportableAssemblyMethodConverter.ConvertTo(expectedSection.CommonSectionAssemblyMethod), actualSection.AssemblyMethod);
- }
-
- private static void AssertExportableCombinedFailureMechanismSectionResult(CombinedFailureMechanismSectionAssemblyResult expectedSection,
+ private static void AssertExportableCombinedFailureMechanismSectionResult(int index,
+ CombinedFailureMechanismSectionAssemblyResult expectedSection,
ExportableCombinedFailureMechanismSection actualSection,
ExportableCombinedSectionAssembly actualSectionResult,
bool hasAssemblyGroupResults)
{
+ Assert.AreEqual($"Gf.{index}", actualSectionResult.Id);
+
Assert.AreSame(actualSection, actualSectionResult.Section);
Assert.AreEqual(expectedSection.TotalResult, actualSectionResult.AssemblyGroup);
Assert.AreEqual(ExportableAssemblyMethodConverter.ConvertTo(expectedSection.CombinedSectionResultAssemblyMethod), actualSectionResult.AssemblyGroupAssemblyMethod);
Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/AssemblyExporter/ExpectedGml.gml
===================================================================
diff -u -r0a99f56530fcba864b9d978accda370bf2a78c69 -rb25d71c274bf802dc8dd9fce8c69fd8263f7c054
--- Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/AssemblyExporter/ExpectedGml.gml (.../ExpectedGml.gml) (revision 0a99f56530fcba864b9d978accda370bf2a78c69)
+++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/AssemblyExporter/ExpectedGml.gml (.../ExpectedGml.gml) (revision b25d71c274bf802dc8dd9fce8c69fd8263f7c054)
@@ -526,12 +526,12 @@
-
+
+II
BOI-3C-1
VOLLDG
-
+
@@ -540,7 +540,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -549,7 +549,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -558,7 +558,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -567,7 +567,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -576,7 +576,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -585,7 +585,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -594,7 +594,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -603,7 +603,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -612,7 +612,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -621,7 +621,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -630,7 +630,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -639,7 +639,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -648,7 +648,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -657,7 +657,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -666,7 +666,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -675,16 +675,16 @@
BOI-3B-1
VOLLDG
-
+
-
+
+III
BOI-3C-1
VOLLDG
-
+
@@ -693,7 +693,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -702,7 +702,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -711,7 +711,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -720,7 +720,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -729,7 +729,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -738,7 +738,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -747,7 +747,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -756,7 +756,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -765,7 +765,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -774,7 +774,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -783,7 +783,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -792,7 +792,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -801,7 +801,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -810,7 +810,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -819,7 +819,7 @@
BOI-3B-1
VOLLDG
-
+
@@ -828,7 +828,7 @@
BOI-3B-1
VOLLDG
-
+