Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs =================================================================== diff -u -r3fedb02f6284e45456911f5831bb399ecc85e307 -r48cf7bc97178507b34018066b407c85f7f47d3a5 --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision 3fedb02f6284e45456911f5831bb399ecc85e307) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision 48cf7bc97178507b34018066b407c85f7f47d3a5) @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Linq; using Riskeer.AssemblyTool.Data; using Riskeer.AssemblyTool.IO.Model; using Riskeer.AssemblyTool.IO.Model.Enums; @@ -78,9 +79,11 @@ throw new ArgumentNullException(nameof(assessmentSection)); } + var registry = new ExportableModelRegistry(); return new ExportableAssessmentSection($"{Resources.ExportableAssessmentSection_IdPrefix}.{assessmentSection.Id}", assessmentSection.Name, assessmentSection.ReferenceLine.Points, + CreateExportableFailureMechanismSectionCollections(idGenerator, registry, assessmentSection), CreateExportableAssessmentSectionAssemblyResult(idGenerator, assessmentSection), CreateExportableFailureMechanisms(idGenerator, assessmentSection), CreateExportableCombinedSectionAssemblyCollection(assessmentSection)); @@ -244,6 +247,18 @@ } } + private static IEnumerable CreateExportableFailureMechanismSectionCollections( + IdentifierGenerator idGenerator, ExportableModelRegistry registry, AssessmentSection assessmentSection) + { + IEnumerable failureMechanismsInAssembly = assessmentSection.GetFailureMechanisms() + .Concat(assessmentSection.SpecificFailureMechanisms) + .Where(fm => fm.InAssembly); + + return failureMechanismsInAssembly.Select(failureMechanism => ExportableFailureMechanismSectionCollectionFactory.CreateExportableFailureMechanismSectionCollection( + idGenerator, registry, failureMechanism.Sections)) + .ToArray(); + } + /// /// Creates a collection of based on . /// Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableAssessmentSectionFactoryTest.cs =================================================================== diff -u -r3fedb02f6284e45456911f5831bb399ecc85e307 -r48cf7bc97178507b34018066b407c85f7f47d3a5 --- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableAssessmentSectionFactoryTest.cs (.../ExportableAssessmentSectionFactoryTest.cs) (revision 3fedb02f6284e45456911f5831bb399ecc85e307) +++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableAssessmentSectionFactoryTest.cs (.../ExportableAssessmentSectionFactoryTest.cs) (revision 48cf7bc97178507b34018066b407c85f7f47d3a5) @@ -123,6 +123,9 @@ Assert.AreEqual(0.14, exportableAssessmentSectionAssemblyResult.Probability); AssertExportableFailureMechanisms(exportableAssessmentSection.FailureMechanisms, assessmentSection); + IEnumerable expectedFailureMechanisms = assessmentSection.GetFailureMechanisms() + .Concat(assessmentSection.SpecificFailureMechanisms); + AssertExportableFailureMechanismSectionCollection(expectedFailureMechanisms, exportableAssessmentSection.FailureMechanismSectionCollections); Assert.AreEqual(1, exportableAssessmentSection.CombinedSectionAssemblies.Count()); ExportableCombinedSectionAssembly exportableCombinedSectionAssembly = exportableAssessmentSection.CombinedSectionAssemblies.ElementAt(0); @@ -201,6 +204,7 @@ Assert.AreEqual(0.14, exportableAssessmentSectionAssemblyResult.Probability); CollectionAssert.IsEmpty(exportableAssessmentSection.FailureMechanisms); + CollectionAssert.IsEmpty(exportableAssessmentSection.FailureMechanismSectionCollections); Assert.AreEqual(1, exportableAssessmentSection.CombinedSectionAssemblies.Count()); ExportableCombinedSectionAssembly exportableCombinedSectionAssembly = exportableAssessmentSection.CombinedSectionAssemblies.ElementAt(0); @@ -215,6 +219,18 @@ } } + private static void AssertExportableFailureMechanismSectionCollection( + IEnumerable failureMechanisms, IEnumerable failureMechanismSectionCollections) + { + int nrOfExpectedCollections = failureMechanisms.Count(); + Assert.AreEqual(nrOfExpectedCollections, failureMechanismSectionCollections.Count()); + for (var i = 0; i < nrOfExpectedCollections; i++) + { + int nrOfExpectedSections = failureMechanisms.ElementAt(i).Sections.Count(); + Assert.AreEqual(nrOfExpectedSections, failureMechanismSectionCollections.ElementAt(i).Sections.Count()); + } + } + private static void AssertExportableFailureMechanisms( IEnumerable exportableFailureMechanisms, AssessmentSection assessmentSection)