Index: Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.IO.TestUtil/ExportableFailureMechanismSectionAssemblyResultTestHelper.cs
===================================================================
diff -u -rd45c4d685f147e9ef02db77b8085ce59edf92d08 -rebec6b457e0542ba44b77d1c2471d8966537955d
--- Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.IO.TestUtil/ExportableFailureMechanismSectionAssemblyResultTestHelper.cs (.../ExportableFailureMechanismSectionAssemblyResultTestHelper.cs) (revision d45c4d685f147e9ef02db77b8085ce59edf92d08)
+++ Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.IO.TestUtil/ExportableFailureMechanismSectionAssemblyResultTestHelper.cs (.../ExportableFailureMechanismSectionAssemblyResultTestHelper.cs) (revision ebec6b457e0542ba44b77d1c2471d8966537955d)
@@ -43,9 +43,9 @@
/// Thrown when:
///
/// - The number of and number of do not match.
+ /// - The id does not contain the expected value.
/// - The values between and
/// do not match.
- /// - The id does not contain the expected value.
///
public static void AssertExportableFailureMechanismSectionResults(FailureMechanismSectionAssemblyResultWrapper expectedAssemblyResultWrapper,
IEnumerable sections,
@@ -59,16 +59,36 @@
ExportableFailureMechanismSection section = sections.ElementAt(i);
ExportableFailureMechanismSectionAssemblyResult actualExportableAssemblyResult = results.ElementAt(i);
- Assert.AreEqual($"Fa.{i}", actualExportableAssemblyResult.Id);
- Assert.AreSame(section, actualExportableAssemblyResult.FailureMechanismSection);
- FailureMechanismSectionAssemblyResult expectedAssemblyResult = expectedAssemblyResultWrapper.AssemblyResult;
- Assert.AreEqual(expectedAssemblyResult.FailureMechanismSectionAssemblyGroup, actualExportableAssemblyResult.AssemblyGroup);
- Assert.AreEqual(expectedAssemblyResult.SectionProbability, actualExportableAssemblyResult.Probability);
- Assert.AreEqual(ExportableAssemblyMethodFactory.Create(expectedAssemblyResultWrapper.AssemblyGroupMethod),
- actualExportableAssemblyResult.AssemblyGroupAssemblyMethod);
- Assert.AreEqual(ExportableAssemblyMethodFactory.Create(expectedAssemblyResultWrapper.ProbabilityMethod),
- actualExportableAssemblyResult.ProbabilityAssemblyMethod);
+ AssertExportableFailureMechanismSectionResult(expectedAssemblyResultWrapper, actualExportableAssemblyResult, section, i);
}
}
+
+ ///
+ /// Asserts the against the assembly result.
+ ///
+ /// The expected .
+ /// The actual .
+ /// The used .
+ /// The number of the section result.
+ /// Thrown when:
+ ///
+ /// - The id does not contain the expected value.
+ /// - The values between and
+ /// do not match.
+ ///
+ public static void AssertExportableFailureMechanismSectionResult(FailureMechanismSectionAssemblyResultWrapper expectedAssemblyResultWrapper,
+ ExportableFailureMechanismSectionAssemblyResult actualExportableAssemblyResult,
+ ExportableFailureMechanismSection section, int i = 0)
+ {
+ Assert.AreEqual($"Fa.{i}", actualExportableAssemblyResult.Id);
+ Assert.AreSame(section, actualExportableAssemblyResult.FailureMechanismSection);
+ FailureMechanismSectionAssemblyResult expectedAssemblyResult = expectedAssemblyResultWrapper.AssemblyResult;
+ Assert.AreEqual(expectedAssemblyResult.FailureMechanismSectionAssemblyGroup, actualExportableAssemblyResult.AssemblyGroup);
+ Assert.AreEqual(expectedAssemblyResult.SectionProbability, actualExportableAssemblyResult.Probability);
+ Assert.AreEqual(ExportableAssemblyMethodFactory.Create(expectedAssemblyResultWrapper.AssemblyGroupMethod),
+ actualExportableAssemblyResult.AssemblyGroupAssemblyMethod);
+ Assert.AreEqual(ExportableAssemblyMethodFactory.Create(expectedAssemblyResultWrapper.ProbabilityMethod),
+ actualExportableAssemblyResult.ProbabilityAssemblyMethod);
+ }
}
}
\ No newline at end of file
Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismFactory.cs
===================================================================
diff -u -r7b3aff14823c770cf5801b80f00f19892e40cfbe -rebec6b457e0542ba44b77d1c2471d8966537955d
--- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismFactory.cs (.../ExportableFailureMechanismFactory.cs) (revision 7b3aff14823c770cf5801b80f00f19892e40cfbe)
+++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismFactory.cs (.../ExportableFailureMechanismFactory.cs) (revision ebec6b457e0542ba44b77d1c2471d8966537955d)
@@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using Riskeer.AssemblyTool.Data;
using Riskeer.AssemblyTool.IO.Model;
using Riskeer.Common.Data.AssessmentSection;
@@ -184,34 +185,16 @@
/// Thrown when
/// returns an invalid result that cannot be exported.
private static IEnumerable CreateExportableFailureMechanismSectionResults(
- IdentifierGenerator idGenerator, ExportableFailureMechanismSectionRegistry registry, TFailureMechanism failureMechanism, IAssessmentSection assessmentSection,
- Func assembleFailureMechanismSectionFunc)
+ IdentifierGenerator idGenerator, ExportableFailureMechanismSectionRegistry registry, TFailureMechanism failureMechanism, IAssessmentSection assessmentSection,
+ Func assembleFailureMechanismSectionFunc)
where TFailureMechanism : IFailureMechanism
where TSectionResult : FailureMechanismSectionResult
{
- var exportableResults = new List();
- foreach (TSectionResult sectionResult in failureMechanism.SectionResults)
- {
- FailureMechanismSectionAssemblyResultWrapper assemblyResultWrapper = assembleFailureMechanismSectionFunc(
- sectionResult, failureMechanism, assessmentSection);
- FailureMechanismSectionAssemblyResult assemblyResult = assemblyResultWrapper.AssemblyResult;
-
- if (assemblyResult.FailureMechanismSectionAssemblyGroup == FailureMechanismSectionAssemblyGroup.NoResult
- || assemblyResult.FailureMechanismSectionAssemblyGroup == FailureMechanismSectionAssemblyGroup.Dominant)
- {
- throw new AssemblyFactoryException("The assembly result is invalid and cannot be created.");
- }
-
- exportableResults.Add(
- new ExportableFailureMechanismSectionAssemblyResult(
- idGenerator.GetNewId(Resources.ExportableFailureMechanismSectionAssemblyResult_IdPrefix),
- registry.Get(sectionResult.Section),
- assemblyResult.SectionProbability, assemblyResult.FailureMechanismSectionAssemblyGroup,
- ExportableAssemblyMethodFactory.Create(assemblyResultWrapper.AssemblyGroupMethod),
- ExportableAssemblyMethodFactory.Create(assemblyResultWrapper.ProbabilityMethod)));
- }
-
- return exportableResults;
+ return failureMechanism.SectionResults.Select(
+ sr => ExportableFailureMechanismSectionAssemblyResultFactory.Create(
+ idGenerator, registry, sr, failureMechanism, assessmentSection,
+ assembleFailureMechanismSectionFunc))
+ .ToList();
}
}
}
\ No newline at end of file
Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionAssemblyResultFactory.cs
===================================================================
diff -u
--- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionAssemblyResultFactory.cs (revision 0)
+++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableFailureMechanismSectionAssemblyResultFactory.cs (revision ebec6b457e0542ba44b77d1c2471d8966537955d)
@@ -0,0 +1,110 @@
+// Copyright (C) Stichting Deltares 2022. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using Riskeer.AssemblyTool.Data;
+using Riskeer.AssemblyTool.IO.Model;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.FailureMechanism;
+using Riskeer.Integration.IO.Exceptions;
+using Riskeer.Integration.IO.Helpers;
+using Riskeer.Integration.IO.Properties;
+
+namespace Riskeer.Integration.IO.Factories
+{
+ ///
+ /// Factory to create instances of .
+ ///
+ public static class ExportableFailureMechanismSectionAssemblyResultFactory
+ {
+ ///
+ /// Creates a .
+ ///
+ /// The generator to generate ids for the exportable components.
+ /// The to keep track of
+ /// the created .
+ /// The to assemble for.
+ /// The the
+ /// belongs to.
+ /// The to use in the assembly.
+ /// The to perform the assembly.
+ /// The type of section result.
+ /// The type of failure mechanism.
+ /// An .
+ /// Thrown when any parameter is null.
+ /// Thrown when returns an invalid value
+ /// that cannot be exported.
+ public static ExportableFailureMechanismSectionAssemblyResult Create(
+ IdentifierGenerator idGenerator, ExportableFailureMechanismSectionRegistry registry,
+ TSectionResult sectionResult, TFailureMechanism failureMechanism, IAssessmentSection assessmentSection,
+ Func assemblyFunc)
+ where TFailureMechanism : IFailureMechanism
+ where TSectionResult : FailureMechanismSectionResult
+ {
+ if (idGenerator == null)
+ {
+ throw new ArgumentNullException(nameof(idGenerator));
+ }
+
+ if (registry == null)
+ {
+ throw new ArgumentNullException(nameof(registry));
+ }
+
+ if (sectionResult == null)
+ {
+ throw new ArgumentNullException(nameof(sectionResult));
+ }
+
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ if (assemblyFunc == null)
+ {
+ throw new ArgumentNullException(nameof(assemblyFunc));
+ }
+
+ FailureMechanismSectionAssemblyResultWrapper assemblyResultWrapper = assemblyFunc(
+ sectionResult, failureMechanism, assessmentSection);
+ FailureMechanismSectionAssemblyResult assemblyResult = assemblyResultWrapper.AssemblyResult;
+
+ if (assemblyResult.FailureMechanismSectionAssemblyGroup == FailureMechanismSectionAssemblyGroup.NoResult
+ || assemblyResult.FailureMechanismSectionAssemblyGroup == FailureMechanismSectionAssemblyGroup.Dominant)
+ {
+ throw new AssemblyFactoryException("The assembly result is invalid and cannot be created.");
+ }
+
+ return new ExportableFailureMechanismSectionAssemblyResult(
+ idGenerator.GetNewId(Resources.ExportableFailureMechanismSectionAssemblyResult_IdPrefix),
+ registry.Get(sectionResult.Section),
+ assemblyResult.SectionProbability, assemblyResult.FailureMechanismSectionAssemblyGroup,
+ ExportableAssemblyMethodFactory.Create(assemblyResultWrapper.AssemblyGroupMethod),
+ ExportableAssemblyMethodFactory.Create(assemblyResultWrapper.ProbabilityMethod));
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismFactoryTest.cs
===================================================================
diff -u -r7b3aff14823c770cf5801b80f00f19892e40cfbe -rebec6b457e0542ba44b77d1c2471d8966537955d
--- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismFactoryTest.cs (.../ExportableFailureMechanismFactoryTest.cs) (revision 7b3aff14823c770cf5801b80f00f19892e40cfbe)
+++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismFactoryTest.cs (.../ExportableFailureMechanismFactoryTest.cs) (revision ebec6b457e0542ba44b77d1c2471d8966537955d)
@@ -32,7 +32,6 @@
using Riskeer.Common.Data.AssessmentSection;
using Riskeer.Common.Data.FailureMechanism;
using Riskeer.Common.Data.TestUtil;
-using Riskeer.Integration.IO.Exceptions;
using Riskeer.Integration.IO.Factories;
using Riskeer.Integration.IO.Helpers;
@@ -144,37 +143,6 @@
}
[Test]
- [TestCase(FailureMechanismSectionAssemblyGroup.NoResult)]
- [TestCase(FailureMechanismSectionAssemblyGroup.Dominant)]
- public void CreateExportableGenericFailureMechanism_InvalidFailureMechanismSectionAssemblyResult_ThrowsAssemblyFactoryException(
- FailureMechanismSectionAssemblyGroup assemblyGroup)
- {
- // Setup
- var random = new Random(21);
- var failureMechanism = new TestFailureMechanism();
- FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(2, 10));
- var assessmentSection = new AssessmentSectionStub();
-
- var idGenerator = new IdentifierGenerator();
-
- var registry = new ExportableFailureMechanismSectionRegistry();
- RegisterFailureMechanismSections(registry, failureMechanism.Sections);
-
- // Call
- void Call() => ExportableFailureMechanismFactory.CreateExportableGenericFailureMechanism(
- idGenerator, registry, failureMechanism, assessmentSection, (fm, section) => new FailureMechanismAssemblyResultWrapper(
- random.NextDouble(), random.NextEnumValue()),
- (sr, fm, section) => new FailureMechanismSectionAssemblyResultWrapper(
- new FailureMechanismSectionAssemblyResult(
- random.NextDouble(), random.NextDouble(), random.NextDouble(), assemblyGroup),
- random.NextEnumValue(), random.NextEnumValue()));
-
- // Assert
- var exception = Assert.Throws(Call);
- Assert.AreEqual("The assembly result is invalid and cannot be created.", exception.Message);
- }
-
- [Test]
public void CreateExportableGenericFailureMechanism_WithValidData_ReturnsExportableFailureMechanism()
{
// Setup
@@ -317,37 +285,6 @@
}
[Test]
- [TestCase(FailureMechanismSectionAssemblyGroup.NoResult)]
- [TestCase(FailureMechanismSectionAssemblyGroup.Dominant)]
- public void CreateExportableSpecificFailureMechanism_InvalidFailureMechanismSectionAssemblyResult_ThrowsAssemblyFactoryException(
- FailureMechanismSectionAssemblyGroup assemblyGroup)
- {
- // Setup
- var random = new Random(21);
- var failureMechanism = new SpecificFailureMechanism();
- FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(2, 10));
- var assessmentSection = new AssessmentSectionStub();
-
- var idGenerator = new IdentifierGenerator();
-
- var registry = new ExportableFailureMechanismSectionRegistry();
- RegisterFailureMechanismSections(registry, failureMechanism.Sections);
-
- // Call
- void Call() => ExportableFailureMechanismFactory.CreateExportableSpecificFailureMechanism(
- idGenerator, registry, failureMechanism, assessmentSection, (fm, section) => new FailureMechanismAssemblyResultWrapper(
- random.NextDouble(), random.NextEnumValue()),
- (sr, fm, section) => new FailureMechanismSectionAssemblyResultWrapper(
- new FailureMechanismSectionAssemblyResult(
- random.NextDouble(), random.NextDouble(), random.NextDouble(), assemblyGroup),
- random.NextEnumValue(), random.NextEnumValue()));
-
- // Assert
- var exception = Assert.Throws(Call);
- Assert.AreEqual("The assembly result is invalid and cannot be created.", exception.Message);
- }
-
- [Test]
public void CreateExportableSpecificFailureMechanism_WithValidData_ReturnsExportableFailureMechanism()
{
// Setup
Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismSectionAssemblyResultFactoryTest.cs
===================================================================
diff -u
--- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismSectionAssemblyResultFactoryTest.cs (revision 0)
+++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableFailureMechanismSectionAssemblyResultFactoryTest.cs (revision ebec6b457e0542ba44b77d1c2471d8966537955d)
@@ -0,0 +1,205 @@
+// Copyright (C) Stichting Deltares 2022. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Linq;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Riskeer.AssemblyTool.Data;
+using Riskeer.AssemblyTool.Data.TestUtil;
+using Riskeer.AssemblyTool.IO.Model;
+using Riskeer.AssemblyTool.IO.TestUtil;
+using Riskeer.Common.Data.TestUtil;
+using Riskeer.Integration.IO.Exceptions;
+using Riskeer.Integration.IO.Factories;
+using Riskeer.Integration.IO.Helpers;
+
+namespace Riskeer.Integration.IO.Test.Factories
+{
+ [TestFixture]
+ public class ExportableFailureMechanismSectionAssemblyResultFactoryTest
+ {
+ [Test]
+ public void Create_IdGeneratorNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var random = new Random(21);
+ var failureMechanism = new TestFailureMechanism();
+ FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(2, 10));
+ var assessmentSection = new AssessmentSectionStub();
+
+ // Call
+ void Call() => ExportableFailureMechanismSectionAssemblyResultFactory.Create(
+ null, new ExportableFailureMechanismSectionRegistry(), failureMechanism.SectionResults.First(),
+ failureMechanism, assessmentSection, (sr, fm, section) => null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("idGenerator", exception.ParamName);
+ }
+
+ [Test]
+ public void Create_RegistryNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var random = new Random(21);
+ var failureMechanism = new TestFailureMechanism();
+ FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(2, 10));
+ var assessmentSection = new AssessmentSectionStub();
+
+ // Call
+ void Call() => ExportableFailureMechanismSectionAssemblyResultFactory.Create(
+ new IdentifierGenerator(), null, failureMechanism.SectionResults.First(),
+ failureMechanism, assessmentSection, (sr, fm, section) => null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("registry", exception.ParamName);
+ }
+
+ [Test]
+ public void Create_SectionResultNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var random = new Random(21);
+ var failureMechanism = new TestFailureMechanism();
+ FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(2, 10));
+ var assessmentSection = new AssessmentSectionStub();
+
+ // Call
+ void Call() => ExportableFailureMechanismSectionAssemblyResultFactory.Create(
+ new IdentifierGenerator(), new ExportableFailureMechanismSectionRegistry(), null,
+ failureMechanism, assessmentSection, (sr, fm, section) => null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("sectionResult", exception.ParamName);
+ }
+
+ [Test]
+ public void Create_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var random = new Random(21);
+ var failureMechanism = new TestFailureMechanism();
+ FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(2, 10));
+ var assessmentSection = new AssessmentSectionStub();
+
+ // Call
+ void Call() => ExportableFailureMechanismSectionAssemblyResultFactory.Create(
+ new IdentifierGenerator(), new ExportableFailureMechanismSectionRegistry(), failureMechanism.SectionResults.First(),
+ null, assessmentSection, (sr, fm, section) => null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ }
+
+ [Test]
+ public void Create_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var random = new Random(21);
+ var failureMechanism = new TestFailureMechanism();
+ FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(2, 10));
+
+ // Call
+ void Call() => ExportableFailureMechanismSectionAssemblyResultFactory.Create(
+ new IdentifierGenerator(), new ExportableFailureMechanismSectionRegistry(), failureMechanism.SectionResults.First(),
+ failureMechanism, null, (sr, fm, section) => null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
+ public void Create_AssemblyFuncNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var random = new Random(21);
+ var failureMechanism = new TestFailureMechanism();
+ FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(2, 10));
+ var assessmentSection = new AssessmentSectionStub();
+
+ // Call
+ void Call() => ExportableFailureMechanismSectionAssemblyResultFactory.Create(
+ new IdentifierGenerator(), new ExportableFailureMechanismSectionRegistry(), failureMechanism.SectionResults.First(),
+ failureMechanism, assessmentSection, null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("assemblyFunc", exception.ParamName);
+ }
+
+ [Test]
+ [TestCase(FailureMechanismSectionAssemblyGroup.NoResult)]
+ [TestCase(FailureMechanismSectionAssemblyGroup.Dominant)]
+ public void Create_InvalidFailureMechanismSectionAssemblyResult_ThrowsAssemblyFactoryException(
+ FailureMechanismSectionAssemblyGroup assemblyGroup)
+ {
+ // Setup
+ var random = new Random(21);
+ var failureMechanism = new TestFailureMechanism();
+ FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(2, 10));
+ var assessmentSection = new AssessmentSectionStub();
+
+ // Call
+ void Call() => ExportableFailureMechanismSectionAssemblyResultFactory.Create(
+ new IdentifierGenerator(), new ExportableFailureMechanismSectionRegistry(), failureMechanism.SectionResults.First(),
+ failureMechanism, assessmentSection, (sr, fm, section) => new FailureMechanismSectionAssemblyResultWrapper(
+ new FailureMechanismSectionAssemblyResult(
+ random.NextDouble(), random.NextDouble(), random.NextDouble(), assemblyGroup),
+ random.NextEnumValue(), random.NextEnumValue()));
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("The assembly result is invalid and cannot be created.", exception.Message);
+ }
+
+ [Test]
+ public void Create_ValidData_ReturnsExportableFailureMechanismSectionAssemblyResult()
+ {
+ // Setup
+ var random = new Random(21);
+ var failureMechanism = new TestFailureMechanism();
+ FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(2, 10));
+ var assessmentSection = new AssessmentSectionStub();
+
+ FailureMechanismSectionAssemblyResultWrapper expectedSectionOutput = FailureMechanismSectionAssemblyResultWrapperTestFactory.Create();
+
+ var idGenerator = new IdentifierGenerator();
+
+ var registry = new ExportableFailureMechanismSectionRegistry();
+ ExportableFailureMechanismSectionCollectionFactory.CreateExportableFailureMechanismSectionCollection(
+ new IdentifierGenerator(), registry, failureMechanism.Sections);
+
+ // Call
+ ExportableFailureMechanismSectionAssemblyResult assemblyResult = ExportableFailureMechanismSectionAssemblyResultFactory.Create(
+ idGenerator, registry, failureMechanism.SectionResults.First(), failureMechanism, assessmentSection,
+ (sr, fm, section) => expectedSectionOutput);
+
+ // Assert
+ ExportableFailureMechanismSectionAssemblyResultTestHelper.AssertExportableFailureMechanismSectionResult(
+ expectedSectionOutput, assemblyResult, registry.Get(failureMechanism.Sections.First()));
+ }
+ }
+}
\ No newline at end of file