Index: Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.IO/AssemblyGmlWriter.cs
===================================================================
diff -u -r191163e5ea9e3725076cd87d69225f6420bd2aad -rd8340b402c51ae80af23df797bbbe73a3da9a48e
--- Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.IO/AssemblyGmlWriter.cs (.../AssemblyGmlWriter.cs) (revision 191163e5ea9e3725076cd87d69225f6420bd2aad)
+++ Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.IO/AssemblyGmlWriter.cs (.../AssemblyGmlWriter.cs) (revision d8340b402c51ae80af23df797bbbe73a3da9a48e)
@@ -253,21 +253,20 @@
foreach (ExportableFailureMechanismCombinedSectionAssemblyResult failureMechanismResult in combinedSectionAssembly.FailureMechanismResults)
{
- WriteFeatureMember(() => WriteCombinedSectionAssemblyFailureMechanismResult(failureMechanismResult, combinedSectionAssembly.CombinedSectionAssemblyResult.Id));
+ WriteFeatureMember(() => WriteCombinedSectionAssemblyFailureMechanismResult(failureMechanismResult, combinedSectionAssembly.Id));
}
}
}
private void WriteCombinedSectionAssembly(ExportableCombinedSectionAssembly combinedSectionAssembly, string assessmentSectionAssemblyId)
{
WriteStartElementWithId(AssemblyXmlIdentifiers.CombinedFailureMechanismSection, AssemblyXmlIdentifiers.UboiNamespace,
- combinedSectionAssembly.CombinedSectionAssemblyResult.Id);
+ combinedSectionAssembly.Id);
- ExportableFailureMechanismSectionAssemblyResult combinedSectionAssemblyResult = combinedSectionAssembly.CombinedSectionAssemblyResult;
writer.WriteElementString(AssemblyXmlIdentifiers.FailureMechanismSectionAssemblyGroup, AssemblyXmlIdentifiers.UboiNamespace,
- EnumDisplayNameHelper.GetDisplayName(combinedSectionAssemblyResult.AssemblyGroup));
+ EnumDisplayNameHelper.GetDisplayName(combinedSectionAssembly.AssemblyGroup));
writer.WriteElementString(AssemblyXmlIdentifiers.AssemblyMethod, AssemblyXmlIdentifiers.UboiNamespace,
- EnumDisplayNameHelper.GetDisplayName(combinedSectionAssemblyResult.AssemblyGroupAssemblyMethod));
+ EnumDisplayNameHelper.GetDisplayName(combinedSectionAssembly.AssemblyGroupAssemblyMethod));
writer.WriteElementString(AssemblyXmlIdentifiers.Status, AssemblyXmlIdentifiers.UboiNamespace, Resources.FullAssembly);
WriteLink(AssemblyXmlIdentifiers.Specifies, AssemblyXmlIdentifiers.UboiNamespace, assessmentSectionAssemblyId);
Index: Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.IO/Model/ExportableCombinedSectionAssembly.cs
===================================================================
diff -u -rf56c6e3627abb4f2399032992d4793089f86d419 -rd8340b402c51ae80af23df797bbbe73a3da9a48e
--- Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.IO/Model/ExportableCombinedSectionAssembly.cs (.../ExportableCombinedSectionAssembly.cs) (revision f56c6e3627abb4f2399032992d4793089f86d419)
+++ Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.IO/Model/ExportableCombinedSectionAssembly.cs (.../ExportableCombinedSectionAssembly.cs) (revision d8340b402c51ae80af23df797bbbe73a3da9a48e)
@@ -21,6 +21,9 @@
using System;
using System.Collections.Generic;
+using Riskeer.AssemblyTool.Data;
+using Riskeer.AssemblyTool.IO.Helpers;
+using Riskeer.AssemblyTool.IO.Model.Enums;
namespace Riskeer.AssemblyTool.IO.Model
{
@@ -32,45 +35,60 @@
///
/// Creates a new instance of .
///
+ /// The id of the section assembly result.
/// The section that belongs to the assembly result.
- /// The combined assembly result of this section.
+ /// The assembly group of this combined section.
+ /// The method used to assemble the assembly group for this combined section.
/// The assembly results per failure mechanism.
- /// Thrown when any parameter is null.
- public ExportableCombinedSectionAssembly(ExportableCombinedFailureMechanismSection section,
- ExportableFailureMechanismSectionAssemblyResult combinedSectionAssemblyResult,
+ /// Thrown when or
+ /// is null.
+ /// Thrown when is invalid.
+ public ExportableCombinedSectionAssembly(string id,
+ ExportableCombinedFailureMechanismSection section,
+ FailureMechanismSectionAssemblyGroup assemblyGroup,
+ ExportableAssemblyMethod assemblyGroupAssemblyMethod,
IEnumerable failureMechanismResults)
{
+ IdValidationHelper.ThrowIfInvalid(id);
+
if (section == null)
{
throw new ArgumentNullException(nameof(section));
}
- if (combinedSectionAssemblyResult == null)
- {
- throw new ArgumentNullException(nameof(combinedSectionAssemblyResult));
- }
-
if (failureMechanismResults == null)
{
throw new ArgumentNullException(nameof(failureMechanismResults));
}
+ Id = id;
Section = section;
- CombinedSectionAssemblyResult = combinedSectionAssemblyResult;
+ AssemblyGroup = assemblyGroup;
+ AssemblyGroupAssemblyMethod = assemblyGroupAssemblyMethod;
FailureMechanismResults = failureMechanismResults;
}
+
+ ///
+ /// Gets the id of the combined section assembly.
+ ///
+ public string Id { get; }
///
- /// Gets the section of the assembly.
+ /// Gets the section.
///
public ExportableCombinedFailureMechanismSection Section { get; }
///
- /// Gets the combined assembly result of this section.
+ /// Gets the assembly group.
///
- public ExportableFailureMechanismSectionAssemblyResult CombinedSectionAssemblyResult { get; }
+ public FailureMechanismSectionAssemblyGroup AssemblyGroup { get; }
///
+ /// Gets the method that was used to assemble the assembly group for this combined section.
+ ///
+ public ExportableAssemblyMethod AssemblyGroupAssemblyMethod { get; }
+
+ ///
/// Gets the assembly results per failure mechanism.
///
public IEnumerable FailureMechanismResults { get; }
Index: Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/AssemblyGmlWriterTest.cs
===================================================================
diff -u -r191163e5ea9e3725076cd87d69225f6420bd2aad -rd8340b402c51ae80af23df797bbbe73a3da9a48e
--- Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/AssemblyGmlWriterTest.cs (.../AssemblyGmlWriterTest.cs) (revision 191163e5ea9e3725076cd87d69225f6420bd2aad)
+++ Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/AssemblyGmlWriterTest.cs (.../AssemblyGmlWriterTest.cs) (revision d8340b402c51ae80af23df797bbbe73a3da9a48e)
@@ -183,9 +183,8 @@
Enumerable.Empty(), "Specifiek faalmechanisme")
}, new[]
{
- new ExportableCombinedSectionAssembly(combinedSection, new ExportableFailureMechanismSectionAssemblyResult(
- "resultaat_gecombineerd_1", combinedSection, 0.37,
- FailureMechanismSectionAssemblyGroup.I, ExportableAssemblyMethod.BOI3C1, ExportableAssemblyMethod.Manual),
+ new ExportableCombinedSectionAssembly("resultaat_gecombineerd_1", combinedSection,
+ FailureMechanismSectionAssemblyGroup.I, ExportableAssemblyMethod.BOI3C1,
new[]
{
new ExportableFailureMechanismCombinedSectionAssemblyResult(
Index: Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/ExportableCombinedSectionAssemblyTest.cs
===================================================================
diff -u -r54be8d72ca7e4cea39fe62f9ed711cc4ab53b4c9 -rd8340b402c51ae80af23df797bbbe73a3da9a48e
--- Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/ExportableCombinedSectionAssemblyTest.cs (.../ExportableCombinedSectionAssemblyTest.cs) (revision 54be8d72ca7e4cea39fe62f9ed711cc4ab53b4c9)
+++ Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.IO.Test/Model/ExportableCombinedSectionAssemblyTest.cs (.../ExportableCombinedSectionAssemblyTest.cs) (revision d8340b402c51ae80af23df797bbbe73a3da9a48e)
@@ -22,8 +22,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Core.Common.TestUtil;
using NUnit.Framework;
+using Riskeer.AssemblyTool.Data;
using Riskeer.AssemblyTool.IO.Model;
+using Riskeer.AssemblyTool.IO.Model.Enums;
using Riskeer.AssemblyTool.IO.TestUtil;
namespace Riskeer.AssemblyTool.IO.Test.Model
@@ -32,34 +35,37 @@
public class ExportableCombinedSectionAssemblyTest
{
[Test]
- public void Constructor_SectionNull_ThrowsArgumentNullException()
+ [TestCaseSource(typeof(InvalidIdTestHelper), nameof(InvalidIdTestHelper.InvalidIdCases))]
+ public void Constructor_InvalidId_ThrowsArgumentException(string invalidId)
{
// Setup
- ExportableFailureMechanismSection section = ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection();
- ExportableFailureMechanismSectionAssemblyResult combinedAssemblyResult = ExportableFailureMechanismSectionAssemblyResultTestFactory.Create(section, 21);
+ var random = new Random(21);
+ ExportableCombinedFailureMechanismSection section = ExportableFailureMechanismSectionTestFactory.CreateExportableCombinedFailureMechanismSection();
// Call
void Call() => new ExportableCombinedSectionAssembly(
- null, combinedAssemblyResult, Enumerable.Empty());
+ invalidId, section, random.NextEnumValue(),
+ random.NextEnumValue(), Enumerable.Empty());
// Assert
- var exception = Assert.Throws(Call);
- Assert.AreEqual("section", exception.ParamName);
+ const string expectedMessage = "'id' must have a value and consist only of alphanumerical characters, '-', '_' or '.'.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage);
}
[Test]
- public void Constructor_CombinedSectionAssemblyResultNull_ThrowsArgumentNullException()
+ public void Constructor_SectionNull_ThrowsArgumentNullException()
{
// Setup
- ExportableCombinedFailureMechanismSection section = ExportableFailureMechanismSectionTestFactory.CreateExportableCombinedFailureMechanismSection();
+ var random = new Random(21);
// Call
void Call() => new ExportableCombinedSectionAssembly(
- section, null, Enumerable.Empty());
+ "id", null, random.NextEnumValue(),
+ random.NextEnumValue(), Enumerable.Empty());
// Assert
var exception = Assert.Throws(Call);
- Assert.AreEqual("combinedSectionAssemblyResult", exception.ParamName);
+ Assert.AreEqual("section", exception.ParamName);
}
[Test]
@@ -68,11 +74,11 @@
// Setup
var random = new Random(21);
ExportableCombinedFailureMechanismSection section = ExportableFailureMechanismSectionTestFactory.CreateExportableCombinedFailureMechanismSection();
- ExportableFailureMechanismSectionAssemblyResult combinedAssemblyResult = ExportableFailureMechanismSectionAssemblyResultTestFactory.Create(
- section, random.Next());
// Call
- void Call() => new ExportableCombinedSectionAssembly(section, combinedAssemblyResult, null);
+ void Call() => new ExportableCombinedSectionAssembly(
+ "id", section, random.NextEnumValue(),
+ random.NextEnumValue(), null);
// Assert
var exception = Assert.Throws(Call);
@@ -84,20 +90,23 @@
{
// Setup
var random = new Random(21);
+ const string id = "id";
+ var assemblyGroup = random.NextEnumValue();
+ var assemblyMethod = random.NextEnumValue();
+
ExportableCombinedFailureMechanismSection section = ExportableFailureMechanismSectionTestFactory.CreateExportableCombinedFailureMechanismSection();
- ExportableFailureMechanismSectionAssemblyResult combinedAssemblyResult = ExportableFailureMechanismSectionAssemblyResultTestFactory.Create(
- section, random.Next());
-
IEnumerable failureMechanismResults =
Enumerable.Empty();
// Call
- var result = new ExportableCombinedSectionAssembly(section, combinedAssemblyResult, failureMechanismResults);
+ var result = new ExportableCombinedSectionAssembly(id, section, assemblyGroup, assemblyMethod, failureMechanismResults);
// Assert
+ Assert.AreEqual(id, result.Id);
Assert.AreSame(section, result.Section);
- Assert.AreSame(combinedAssemblyResult, result.CombinedSectionAssemblyResult);
+ Assert.AreEqual(assemblyGroup, result.AssemblyGroup);
+ Assert.AreEqual(assemblyMethod, result.AssemblyGroupAssemblyMethod);
Assert.AreSame(failureMechanismResults, result.FailureMechanismResults);
}
}
Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableCombinedSectionAssemblyFactory.cs
===================================================================
diff -u -rfaef9046b62f643860c2885dc4270fce2542a1e3 -rd8340b402c51ae80af23df797bbbe73a3da9a48e
--- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableCombinedSectionAssemblyFactory.cs (.../ExportableCombinedSectionAssemblyFactory.cs) (revision faef9046b62f643860c2885dc4270fce2542a1e3)
+++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableCombinedSectionAssemblyFactory.cs (.../ExportableCombinedSectionAssemblyFactory.cs) (revision d8340b402c51ae80af23df797bbbe73a3da9a48e)
@@ -63,15 +63,15 @@
var sectionResults = new List();
foreach (CombinedFailureMechanismSectionAssemblyResult assemblyResult in combinedSectionAssemblyResults)
{
- var exportableSection = new ExportableCombinedFailureMechanismSection("id", FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(
- assessmentSection.ReferenceLine, assemblyResult.SectionStart, assemblyResult.SectionEnd),
- assemblyResult.SectionStart,
- assemblyResult.SectionEnd,
- ExportableAssemblyMethodFactory.Create(assemblyResult.CommonSectionAssemblyMethod));
+ var exportableSection = new ExportableCombinedFailureMechanismSection(
+ "id", FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(
+ assessmentSection.ReferenceLine, assemblyResult.SectionStart, assemblyResult.SectionEnd),
+ assemblyResult.SectionStart, assemblyResult.SectionEnd,
+ ExportableAssemblyMethodFactory.Create(assemblyResult.CommonSectionAssemblyMethod));
var exportableSectionResult = new ExportableCombinedSectionAssembly(
- exportableSection, new ExportableFailureMechanismSectionAssemblyResult(
- "id", exportableSection, 13.37, assemblyResult.TotalResult, ExportableAssemblyMethodFactory.Create(assemblyResult.CombinedSectionResultAssemblyMethod), ExportableAssemblyMethod.Manual),
+ "id", exportableSection, assemblyResult.TotalResult,
+ ExportableAssemblyMethodFactory.Create(assemblyResult.CombinedSectionResultAssemblyMethod),
CreateFailureMechanismCombinedSectionAssemblyResults(assemblyResult, assessmentSection));
sectionResults.Add(exportableSectionResult);
Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableAssessmentSectionFactoryTest.cs
===================================================================
diff -u -r48cf7bc97178507b34018066b407c85f7f47d3a5 -rd8340b402c51ae80af23df797bbbe73a3da9a48e
--- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableAssessmentSectionFactoryTest.cs (.../ExportableAssessmentSectionFactoryTest.cs) (revision 48cf7bc97178507b34018066b407c85f7f47d3a5)
+++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableAssessmentSectionFactoryTest.cs (.../ExportableAssessmentSectionFactoryTest.cs) (revision d8340b402c51ae80af23df797bbbe73a3da9a48e)
@@ -129,10 +129,10 @@
Assert.AreEqual(1, exportableAssessmentSection.CombinedSectionAssemblies.Count());
ExportableCombinedSectionAssembly exportableCombinedSectionAssembly = exportableAssessmentSection.CombinedSectionAssemblies.ElementAt(0);
- Assert.AreEqual(FailureMechanismSectionAssemblyGroup.Zero, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.AssemblyGroup);
- Assert.AreEqual(ExportableAssemblyMethod.BOI3C1, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.AssemblyGroupAssemblyMethod);
- Assert.AreEqual(0.0, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.FailureMechanismSection.StartDistance);
- Assert.AreEqual(1.0, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.FailureMechanismSection.EndDistance);
+ Assert.AreEqual(FailureMechanismSectionAssemblyGroup.Zero, exportableCombinedSectionAssembly.AssemblyGroup);
+ Assert.AreEqual(ExportableAssemblyMethod.BOI3C1, exportableCombinedSectionAssembly.AssemblyGroupAssemblyMethod);
+ Assert.AreEqual(0.0, exportableCombinedSectionAssembly.Section.StartDistance);
+ Assert.AreEqual(1.0, exportableCombinedSectionAssembly.Section.EndDistance);
AssertExportableFailureMechanismCombinedSectionAssemblyResults(exportableCombinedSectionAssembly.FailureMechanismResults, assessmentSection);
Assert.AreEqual(ExportableAssemblyMethod.BOI3A1, exportableCombinedSectionAssembly.Section.AssemblyMethod);
Assert.AreEqual(0.0, exportableCombinedSectionAssembly.Section.StartDistance);
@@ -208,10 +208,10 @@
Assert.AreEqual(1, exportableAssessmentSection.CombinedSectionAssemblies.Count());
ExportableCombinedSectionAssembly exportableCombinedSectionAssembly = exportableAssessmentSection.CombinedSectionAssemblies.ElementAt(0);
- Assert.AreEqual(FailureMechanismSectionAssemblyGroup.Zero, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.AssemblyGroup);
- Assert.AreEqual(ExportableAssemblyMethod.BOI3C1, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.AssemblyGroupAssemblyMethod);
- Assert.AreEqual(0.0, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.FailureMechanismSection.StartDistance);
- Assert.AreEqual(1.0, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.FailureMechanismSection.EndDistance);
+ Assert.AreEqual(FailureMechanismSectionAssemblyGroup.Zero, exportableCombinedSectionAssembly.AssemblyGroup);
+ Assert.AreEqual(ExportableAssemblyMethod.BOI3C1, exportableCombinedSectionAssembly.AssemblyGroupAssemblyMethod);
+ Assert.AreEqual(0.0, exportableCombinedSectionAssembly.Section.StartDistance);
+ Assert.AreEqual(1.0, exportableCombinedSectionAssembly.Section.EndDistance);
CollectionAssert.IsEmpty(exportableCombinedSectionAssembly.FailureMechanismResults);
Assert.AreEqual(ExportableAssemblyMethod.BOI3A1, exportableCombinedSectionAssembly.Section.AssemblyMethod);
Assert.AreEqual(0.0, exportableCombinedSectionAssembly.Section.StartDistance);
Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableCombinedSectionAssemblyFactoryTest.cs
===================================================================
diff -u -rc5b8fb02fff7b66b609b690ffc0e95c240e30771 -rd8340b402c51ae80af23df797bbbe73a3da9a48e
--- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableCombinedSectionAssemblyFactoryTest.cs (.../ExportableCombinedSectionAssemblyFactoryTest.cs) (revision c5b8fb02fff7b66b609b690ffc0e95c240e30771)
+++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Factories/ExportableCombinedSectionAssemblyFactoryTest.cs (.../ExportableCombinedSectionAssemblyFactoryTest.cs) (revision d8340b402c51ae80af23df797bbbe73a3da9a48e)
@@ -184,8 +184,8 @@
bool hasAssemblyGroupResults)
{
Assert.AreSame(actualSection, actualSectionResult.Section);
- Assert.AreEqual(expectedSection.TotalResult, actualSectionResult.CombinedSectionAssemblyResult.AssemblyGroup);
- Assert.AreEqual(ExportableAssemblyMethodFactory.Create(expectedSection.CombinedSectionResultAssemblyMethod), actualSectionResult.CombinedSectionAssemblyResult.AssemblyGroupAssemblyMethod);
+ Assert.AreEqual(expectedSection.TotalResult, actualSectionResult.AssemblyGroup);
+ Assert.AreEqual(ExportableAssemblyMethodFactory.Create(expectedSection.CombinedSectionResultAssemblyMethod), actualSectionResult.AssemblyGroupAssemblyMethod);
IEnumerable failureMechanismCombinedSectionResults = actualSectionResult.FailureMechanismResults;