Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismSectionAssemblyResultCreator.cs
===================================================================
diff -u -rc2e1b46490dfdc848647c515e3ea04c1f7f69535 -r4b7ea112093d1c9c952fd0b56fe78ba13b4e03e8
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismSectionAssemblyResultCreator.cs (.../SerializableFailureMechanismSectionAssemblyResultCreator.cs) (revision c2e1b46490dfdc848647c515e3ea04c1f7f69535)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismSectionAssemblyResultCreator.cs (.../SerializableFailureMechanismSectionAssemblyResultCreator.cs) (revision 4b7ea112093d1c9c952fd0b56fe78ba13b4e03e8)
@@ -20,9 +20,11 @@
// All rights reserved.
using System;
+using Ringtoets.AssemblyTool.Data;
using Ringtoets.AssemblyTool.IO.Model.DataTypes;
using Ringtoets.AssemblyTool.IO.Model.Enums;
using Ringtoets.Integration.IO.Assembly;
+using Ringtoets.Integration.IO.Exceptions;
namespace Ringtoets.Integration.IO.Creators
{
@@ -41,6 +43,8 @@
/// for.
/// A .
/// Thrown when is null.
+ /// Thrown when is invalid to
+ /// create a serializable counterpart for.
public static SerializableFailureMechanismSectionAssemblyResult Create(SerializableAssessmentType assessmentType,
ExportableSectionAssemblyResult sectionResult)
{
@@ -49,6 +53,8 @@
throw new ArgumentNullException(nameof(sectionResult));
}
+ ValidateAssemblyResult(sectionResult);
+
return new SerializableFailureMechanismSectionAssemblyResult(SerializableAssemblyMethodCreator.Create(sectionResult.AssemblyMethod),
assessmentType,
SerializableFailureMechanismSectionCategoryGroupCreator.Create(sectionResult.AssemblyCategory));
@@ -64,6 +70,8 @@
/// for.
/// A .
/// Thrown when is null.
+ /// Thrown when is invalid to
+ /// create a serializable counterpart for.
public static SerializableFailureMechanismSectionAssemblyResult Create(SerializableAssessmentType assessmentType,
ExportableSectionAssemblyResultWithProbability sectionResult)
{
@@ -72,10 +80,26 @@
throw new ArgumentNullException(nameof(sectionResult));
}
+ ValidateAssemblyResult(sectionResult);
+
return new SerializableFailureMechanismSectionAssemblyResult(SerializableAssemblyMethodCreator.Create(sectionResult.AssemblyMethod),
assessmentType,
SerializableFailureMechanismSectionCategoryGroupCreator.Create(sectionResult.AssemblyCategory),
sectionResult.Probability);
}
+
+ ///
+ /// Validates the to determine whether a serializable section assembly result can be created.
+ ///
+ /// The to validate.
+ /// Thrown when is invalid
+ /// and a serializable assembly result cannot be created.
+ private static void ValidateAssemblyResult(ExportableSectionAssemblyResult sectionResult)
+ {
+ if (sectionResult.AssemblyCategory == FailureMechanismSectionAssemblyCategoryGroup.None)
+ {
+ throw new AssemblyCreatorException(@"The assembly result is invalid and cannot be created.");
+ }
+ }
}
}
\ No newline at end of file