Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/AggregatedSerializableCombinedFailureMechanismSectionAssembliesCreator.cs =================================================================== diff -u -r645a6301e4aac4aa9bc8c1c595562740fd41aa3e -r4b7ea112093d1c9c952fd0b56fe78ba13b4e03e8 --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/AggregatedSerializableCombinedFailureMechanismSectionAssembliesCreator.cs (.../AggregatedSerializableCombinedFailureMechanismSectionAssembliesCreator.cs) (revision 645a6301e4aac4aa9bc8c1c595562740fd41aa3e) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/AggregatedSerializableCombinedFailureMechanismSectionAssembliesCreator.cs (.../AggregatedSerializableCombinedFailureMechanismSectionAssembliesCreator.cs) (revision 4b7ea112093d1c9c952fd0b56fe78ba13b4e03e8) @@ -25,6 +25,7 @@ using Ringtoets.AssemblyTool.IO.Model; using Ringtoets.Integration.IO.AggregatedSerializable; using Ringtoets.Integration.IO.Assembly; +using Ringtoets.Integration.IO.Exceptions; using Ringtoets.Integration.IO.Helpers; using Ringtoets.Integration.IO.Properties; @@ -45,6 +46,8 @@ /// to create an for. /// An . /// Thrown when any parameter is null. + /// Thrown when is invalid to + /// create a serializable counterpart for. public static AggregatedSerializableCombinedFailureMechanismSectionAssemblies Create(IdentifierGenerator idGenerator, SerializableTotalAssemblyResult totalAssemblyResult, IEnumerable combinedSectionAssemblies) Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/AggregatedSerializableCombinedFailureMechanismSectionAssemblyCreator.cs =================================================================== diff -u -r9b579488697db6bd54b10ccc9eb146dfc191927d -r4b7ea112093d1c9c952fd0b56fe78ba13b4e03e8 --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/AggregatedSerializableCombinedFailureMechanismSectionAssemblyCreator.cs (.../AggregatedSerializableCombinedFailureMechanismSectionAssemblyCreator.cs) (revision 9b579488697db6bd54b10ccc9eb146dfc191927d) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/AggregatedSerializableCombinedFailureMechanismSectionAssemblyCreator.cs (.../AggregatedSerializableCombinedFailureMechanismSectionAssemblyCreator.cs) (revision 4b7ea112093d1c9c952fd0b56fe78ba13b4e03e8) @@ -25,6 +25,7 @@ using Ringtoets.AssemblyTool.IO.Model.Enums; using Ringtoets.Integration.IO.AggregatedSerializable; using Ringtoets.Integration.IO.Assembly; +using Ringtoets.Integration.IO.Exceptions; using Ringtoets.Integration.IO.Helpers; using Ringtoets.Integration.IO.Properties; @@ -48,6 +49,7 @@ /// for. /// An . /// Thrown when any parameter is null. + /// Thrown when is invalid to create a serializable counterpart for. public static AggregatedSerializableCombinedFailureMechanismSectionAssembly Create(IdentifierGenerator idGenerator, SerializableTotalAssemblyResult serializableTotalAssemblyResult, SerializableFailureMechanismSectionCollection serializableFailureMechanismSectionCollection, Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/AggregatedSerializableFailureMechanismCreator.cs =================================================================== diff -u -rb741ba716e73996ab805398ae44a1bb3cd675fc9 -r4b7ea112093d1c9c952fd0b56fe78ba13b4e03e8 --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/AggregatedSerializableFailureMechanismCreator.cs (.../AggregatedSerializableFailureMechanismCreator.cs) (revision b741ba716e73996ab805398ae44a1bb3cd675fc9) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/AggregatedSerializableFailureMechanismCreator.cs (.../AggregatedSerializableFailureMechanismCreator.cs) (revision 4b7ea112093d1c9c952fd0b56fe78ba13b4e03e8) @@ -44,7 +44,7 @@ /// create an for. /// An . /// Thrown when any parameter is null. - /// Thrown when the inputs are invalid to create a serializable counterpart for. + /// Thrown when is invalid to create a serializable counterpart for. /// Thrown when the /// contains unsupported items in the failure mechanism section assembly results. public static AggregatedSerializableFailureMechanism Create(IdentifierGenerator idGenerator, @@ -92,7 +92,7 @@ /// create an for. /// An . /// Thrown when any parameter is null. - /// Thrown when the inputs are invalid to create a serializable counterpart for. + /// Thrown when is invalid to create a serializable counterpart for. /// Thrown when the /// contains unsupported items in the failure mechanism section assembly results. public static AggregatedSerializableFailureMechanism Create(IdentifierGenerator idGenerator, @@ -140,7 +140,7 @@ /// An aggregated failure mechanism section assembly result to /// create an for. /// An . - /// Thrown when the inputs are invalid to create a serializable counterpart for. + /// Thrown when is invalid to create a serializable counterpart for. /// Thrown when an /// cannot be created for . private static AggregatedSerializableFailureMechanismSectionAssembly CreateFailureMechanismSectionAssembly( Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/AggregatedSerializableFailureMechanismSectionAssemblyCreator.cs =================================================================== diff -u -r821ea9c9eada82e432462f9be0390dd5b45ffb29 -r4b7ea112093d1c9c952fd0b56fe78ba13b4e03e8 --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/AggregatedSerializableFailureMechanismSectionAssemblyCreator.cs (.../AggregatedSerializableFailureMechanismSectionAssemblyCreator.cs) (revision 821ea9c9eada82e432462f9be0390dd5b45ffb29) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/AggregatedSerializableFailureMechanismSectionAssemblyCreator.cs (.../AggregatedSerializableFailureMechanismSectionAssemblyCreator.cs) (revision 4b7ea112093d1c9c952fd0b56fe78ba13b4e03e8) @@ -49,7 +49,7 @@ /// for. /// An . /// Thrown when any parameter is null. - /// Thrown when the serializable assembly cannot be created. + /// Thrown when is invalid to create a serializable counterpart for. public static AggregatedSerializableFailureMechanismSectionAssembly Create(IdentifierGenerator idGenerator, SerializableFailureMechanismSectionCollection serializableCollection, SerializableFailureMechanism serializableFailureMechanism, @@ -102,7 +102,7 @@ /// for. /// An . /// Thrown when any parameter is null. - /// Thrown when the serializable assembly cannot be created. + /// Thrown when is invalid to create a serializable counterpart for. public static AggregatedSerializableFailureMechanismSectionAssembly Create(IdentifierGenerator idGenerator, SerializableFailureMechanismSectionCollection serializableCollection, SerializableFailureMechanism serializableFailureMechanism, @@ -155,7 +155,7 @@ /// for. /// An . /// Thrown when any parameter is null. - /// Thrown when the serializable assembly cannot be created. + /// Thrown when is invalid to create a serializable counterpart for. public static AggregatedSerializableFailureMechanismSectionAssembly Create(IdentifierGenerator idGenerator, SerializableFailureMechanismSectionCollection serializableCollection, SerializableFailureMechanism serializableFailureMechanism, @@ -211,6 +211,14 @@ } } + + /// + /// Creates a collection of whether an based on . + /// + /// The to create a collection of + /// for. + /// Thrown when + /// is invalid to create a serializable counterpart for. private static SerializableFailureMechanismSectionAssemblyResult[] CreateAssemblySectionResults(ExportableAggregatedFailureMechanismSectionAssemblyResult sectionResult) { var serializableSectionAssemblyResults = new List(); @@ -236,6 +244,13 @@ return serializableSectionAssemblyResults.ToArray(); } + /// + /// Creates a collection of whether an based on . + /// + /// The to create a collection of + /// for. + /// Thrown when + /// is invalid to create a serializable counterpart for. private static SerializableFailureMechanismSectionAssemblyResult[] CreateAssemblySectionResults( ExportableAggregatedFailureMechanismSectionAssemblyResultWithProbability sectionResult) { @@ -262,6 +277,13 @@ return serializableSectionAssemblyResults.ToArray(); } + /// + /// Creates a collection of whether an based on . + /// + /// The to create a collection of + /// for. + /// Thrown when + /// is invalid to create a serializable counterpart for. private static SerializableFailureMechanismSectionAssemblyResult[] CreateAssemblySectionResults( ExportableAggregatedFailureMechanismSectionAssemblyResultWithoutDetailedAssembly sectionResult) { 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 Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismSectionAssemblyResultCreatorTest.cs =================================================================== diff -u -r220558aee26959ac8967aecd907ddfcf1c9adba7 -r4b7ea112093d1c9c952fd0b56fe78ba13b4e03e8 --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismSectionAssemblyResultCreatorTest.cs (.../SerializableFailureMechanismSectionAssemblyResultCreatorTest.cs) (revision 220558aee26959ac8967aecd907ddfcf1c9adba7) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismSectionAssemblyResultCreatorTest.cs (.../SerializableFailureMechanismSectionAssemblyResultCreatorTest.cs) (revision 4b7ea112093d1c9c952fd0b56fe78ba13b4e03e8) @@ -22,10 +22,12 @@ using System; using Core.Common.TestUtil; using NUnit.Framework; +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.Creators; +using Ringtoets.Integration.IO.Exceptions; using Ringtoets.Integration.IO.TestUtil; namespace Ringtoets.Integration.IO.Test.Creators @@ -48,6 +50,23 @@ } [Test] + public void Create_WithExportableSectionAssemblyResultAndResultNone_ReturnsSerializableFailureMechanismAssemblyResult() + { + // Setup + var random = new Random(21); + var assessmentType = random.NextEnumValue(); + var sectionResult = new ExportableSectionAssemblyResult(random.NextEnumValue(), + FailureMechanismSectionAssemblyCategoryGroup.None); + + // Call + TestDelegate call = () => SerializableFailureMechanismSectionAssemblyResultCreator.Create(assessmentType, sectionResult); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("The assembly result is invalid and cannot be created.", exception.Message); + } + + [Test] public void Create_WithExportableSectionAssemblyResult_ReturnsSerializableFailureMechanismAssemblyResult() { // Setup @@ -81,6 +100,24 @@ } [Test] + public void Create_WithExportableSectionAssemblyResultWithProbabilityAndResultNone_ReturnsSerializableFailureMechanismAssemblyResult() + { + // Setup + var random = new Random(21); + var assessmentType = random.NextEnumValue(); + var sectionResult = new ExportableSectionAssemblyResultWithProbability(random.NextEnumValue(), + FailureMechanismSectionAssemblyCategoryGroup.None, + random.NextDouble()); + + // Call + TestDelegate call = () => SerializableFailureMechanismSectionAssemblyResultCreator.Create(assessmentType, sectionResult); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("The assembly result is invalid and cannot be created.", exception.Message); + } + + [Test] public void Create_WithExportableSectionAssemblyResultWithProbability_ReturnsSerializableFailureMechanismAssemblyResult() { // Setup