Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismSectionAssemblyCreator.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismSectionAssemblyCreator.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismSectionAssemblyCreator.cs (revision ef94545e83d471d2a0a142c649414b507ea10a81)
@@ -0,0 +1,93 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets 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 Ringtoets.AssemblyTool.IO.Model;
+using Ringtoets.AssemblyTool.IO.Model.DataTypes;
+using Ringtoets.AssemblyTool.IO.Model.Enums;
+using Ringtoets.Integration.IO.Assembly;
+using Ringtoets.Integration.IO.Helpers;
+using Ringtoets.Integration.IO.Properties;
+
+namespace Ringtoets.Integration.IO.Creators
+{
+ ///
+ /// Creator to create instance of
+ ///
+ public static class SerializableFailureMechanismSectionAssemblyCreator
+ {
+ ///
+ /// Creates an instance of
+ /// based on its input parameters.
+ ///
+ /// The id generator to generate an id for .
+ /// The the result belongs to.
+ /// The the result belongs to.
+ /// The to create a
+ /// for.
+ /// A .
+ /// Thrown when any parameter is null.
+ public static SerializableFailureMechanismSectionAssembly Create(UniqueIdentifierGenerator idGenerator,
+ SerializableFailureMechanismSectionCollection serializableCollection,
+ SerializableFailureMechanism serializableFailureMechanism,
+ ExportableAggregatedFailureMechanismSectionAssemblyResult sectionResult)
+ {
+ if (idGenerator == null)
+ {
+ throw new ArgumentNullException(nameof(idGenerator));
+ }
+
+ if (serializableCollection == null)
+ {
+ throw new ArgumentNullException(nameof(serializableCollection));
+ }
+
+ if (serializableFailureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(serializableFailureMechanism));
+ }
+
+ if (sectionResult == null)
+ {
+ throw new ArgumentNullException(nameof(sectionResult));
+ }
+
+ return new SerializableFailureMechanismSectionAssembly(idGenerator.GetNewId(Resources.SerializableFailureMechanismSectionAssembly_IdPrefix),
+ serializableFailureMechanism,
+ SerializableFailureMechanismSectionCreator.Create(idGenerator,
+ serializableCollection,
+ sectionResult.FailureMechanismSection),
+ CreateAssemblySectionResults(sectionResult),
+ SerializableFailureMechanismSectionAssemblyResultCreator.Create(SerializableAssessmentType.CombinedAssessment,
+ sectionResult.CombinedAssembly));
+ }
+
+ private static SerializableFailureMechanismSectionAssemblyResult[] CreateAssemblySectionResults(ExportableAggregatedFailureMechanismSectionAssemblyResult sectionResult)
+ {
+ return new[]
+ {
+ SerializableFailureMechanismSectionAssemblyResultCreator.Create(SerializableAssessmentType.SimpleAssessment, sectionResult.SimpleAssembly),
+ SerializableFailureMechanismSectionAssemblyResultCreator.Create(SerializableAssessmentType.DetailedAssessment, sectionResult.DetailedAssembly),
+ SerializableFailureMechanismSectionAssemblyResultCreator.Create(SerializableAssessmentType.TailorMadeAssessment, sectionResult.TailorMadeAssembly)
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -rce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b -ref94545e83d471d2a0a142c649414b507ea10a81
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ef94545e83d471d2a0a142c649414b507ea10a81)
@@ -127,6 +127,15 @@
}
///
+ /// Looks up a localized string similar to T.
+ ///
+ internal static string SerializableFailureMechanismSectionAssembly_IdPrefix {
+ get {
+ return ResourceManager.GetString("SerializableFailureMechanismSectionAssembly_IdPrefix", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Vo.
///
internal static string SerializableTotalAssemblyResult_IdPrefix {
Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Properties/Resources.resx
===================================================================
diff -u -rce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b -ref94545e83d471d2a0a142c649414b507ea10a81
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Properties/Resources.resx (.../Resources.resx) (revision ce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Properties/Resources.resx (.../Resources.resx) (revision ef94545e83d471d2a0a142c649414b507ea10a81)
@@ -135,4 +135,7 @@
Wks
+
+ T
+
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj
===================================================================
diff -u -rce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b -ref94545e83d471d2a0a142c649414b507ea10a81
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision ce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision ef94545e83d471d2a0a142c649414b507ea10a81)
@@ -44,6 +44,7 @@
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismSectionAssemblyCreatorTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismSectionAssemblyCreatorTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismSectionAssemblyCreatorTest.cs (revision ef94545e83d471d2a0a142c649414b507ea10a81)
@@ -0,0 +1,198 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets 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 Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.AssemblyTool.IO.Model;
+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.Helpers;
+using Ringtoets.Integration.IO.TestUtil;
+
+namespace Ringtoets.Integration.IO.Test.Creators
+{
+ [TestFixture]
+ public class SerializableFailureMechanismSectionAssemblyCreatorTest
+ {
+ [Test]
+ public void CreateWithoutProbability_IdGeneratorNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => SerializableFailureMechanismSectionAssemblyCreator.Create(null,
+ new SerializableFailureMechanismSectionCollection(),
+ new SerializableFailureMechanism(),
+ new ExportableAggregatedFailureMechanismSectionAssemblyResult(
+ ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection(),
+ CreateSectionAssemblyResult(10),
+ CreateSectionAssemblyResult(11),
+ CreateSectionAssemblyResult(12),
+ CreateSectionAssemblyResult(13)));
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("idGenerator", exception.ParamName);
+ }
+
+ [Test]
+ public void CreateWithoutProbability_SerializableFailureMechanismSectionCollectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => SerializableFailureMechanismSectionAssemblyCreator.Create(new UniqueIdentifierGenerator(),
+ null,
+ new SerializableFailureMechanism(),
+ new ExportableAggregatedFailureMechanismSectionAssemblyResult(
+ ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection(),
+ CreateSectionAssemblyResult(10),
+ CreateSectionAssemblyResult(11),
+ CreateSectionAssemblyResult(12),
+ CreateSectionAssemblyResult(13)));
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("serializableCollection", exception.ParamName);
+ }
+
+ [Test]
+ public void CreateWithoutProbability_SerializableFailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => SerializableFailureMechanismSectionAssemblyCreator.Create(new UniqueIdentifierGenerator(),
+ new SerializableFailureMechanismSectionCollection(),
+ null,
+ new ExportableAggregatedFailureMechanismSectionAssemblyResult(
+ ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection(),
+ CreateSectionAssemblyResult(10),
+ CreateSectionAssemblyResult(11),
+ CreateSectionAssemblyResult(12),
+ CreateSectionAssemblyResult(13)));
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("serializableFailureMechanism", exception.ParamName);
+ }
+
+ [Test]
+ public void CreateWithoutProbability_SectionResultNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => SerializableFailureMechanismSectionAssemblyCreator.Create(new UniqueIdentifierGenerator(),
+ new SerializableFailureMechanismSectionCollection(),
+ new SerializableFailureMechanism(),
+ null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("sectionResult", exception.ParamName);
+ }
+
+ [Test]
+ public void CreateWithoutProbability_WithValidArguments_ReturnsSerializableFailureMechanismSectionAssembly()
+ {
+ // Setup
+ var idGenerator = new UniqueIdentifierGenerator();
+ var sectionResult = new ExportableAggregatedFailureMechanismSectionAssemblyResult(
+ ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection(),
+ CreateSectionAssemblyResult(10),
+ CreateSectionAssemblyResult(11),
+ CreateSectionAssemblyResult(12),
+ CreateSectionAssemblyResult(13));
+
+ var random = new Random(21);
+ const string serializableFailureMechanismId = "FailureMechanismId";
+ var serializableFailureMechanism = new SerializableFailureMechanism(serializableFailureMechanismId,
+ new SerializableTotalAssemblyResult(),
+ random.NextEnumValue(),
+ random.NextEnumValue(),
+ new SerializableFailureMechanismAssemblyResult());
+
+ const string serializableSectionCollectionId = "CollectionId";
+ var serializableCollection = new SerializableFailureMechanismSectionCollection(serializableSectionCollectionId,
+ serializableFailureMechanism);
+
+ // Call
+ SerializableFailureMechanismSectionAssembly serializableSectionAssembly =
+ SerializableFailureMechanismSectionAssemblyCreator.Create(idGenerator, serializableCollection, serializableFailureMechanism, sectionResult);
+
+ // Assert
+ Assert.AreEqual("T.0", serializableSectionAssembly.Id);
+ Assert.AreEqual(serializableFailureMechanism.Id, serializableSectionAssembly.FailureMechanismId);
+ Assert.AreEqual("Wks.1", serializableSectionAssembly.FailureMechanismSectionId);
+
+ SerializableFailureMechanismSectionAssemblyResult[] serializedSectionResults = serializableSectionAssembly.SectionResults;
+ Assert.AreEqual(3, serializedSectionResults.Length);
+ AssertAssemblyResult(sectionResult.SimpleAssembly,
+ SerializableAssessmentType.SimpleAssessment,
+ serializedSectionResults[0]);
+ AssertAssemblyResult(sectionResult.DetailedAssembly,
+ SerializableAssessmentType.DetailedAssessment,
+ serializedSectionResults[1]);
+ AssertAssemblyResult(sectionResult.TailorMadeAssembly,
+ SerializableAssessmentType.TailorMadeAssessment,
+ serializedSectionResults[2]);
+ AssertAssemblyResult(sectionResult.CombinedAssembly,
+ SerializableAssessmentType.CombinedAssessment,
+ serializableSectionAssembly.CombinedSectionResult);
+ }
+
+ private static void AssertAssemblyResult(ExportableSectionAssemblyResult expectedResult,
+ SerializableAssessmentType expectedAssessmentType,
+ SerializableFailureMechanismSectionAssemblyResult actualResult)
+ {
+ Assert.AreEqual(SerializableFailureMechanismSectionCategoryGroupCreator.Create(expectedResult.AssemblyCategory),
+ actualResult.CategoryGroup);
+ Assert.AreEqual(SerializableAssemblyMethodCreator.Create(expectedResult.AssemblyMethod),
+ actualResult.AssemblyMethod);
+ Assert.AreEqual(expectedAssessmentType, actualResult.AssessmentType);
+ Assert.IsNull(actualResult.Probability);
+ }
+
+ private static ExportableSectionAssemblyResult CreateSectionAssemblyResult(int seed)
+ {
+ var random = new Random(seed);
+ var assemblyCategory = random.NextEnumValue();
+ if (assemblyCategory == FailureMechanismSectionAssemblyCategoryGroup.None)
+ {
+ assemblyCategory = FailureMechanismSectionAssemblyCategoryGroup.IIIv;
+ }
+
+ return new ExportableSectionAssemblyResult(random.NextEnumValue(),
+ assemblyCategory);
+ }
+
+ private static ExportableSectionAssemblyResultWithProbability CreateSectionAssemblyResultWithProbability(int seed)
+ {
+ var random = new Random(seed);
+ var assemblyCategory = random.NextEnumValue();
+ if (assemblyCategory == FailureMechanismSectionAssemblyCategoryGroup.None)
+ {
+ assemblyCategory = FailureMechanismSectionAssemblyCategoryGroup.IIIv;
+ }
+
+ return new ExportableSectionAssemblyResultWithProbability(random.NextEnumValue(),
+ assemblyCategory,
+ random.NextDouble());
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj
===================================================================
diff -u -rce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b -ref94545e83d471d2a0a142c649414b507ea10a81
--- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision ce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b)
+++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision ef94545e83d471d2a0a142c649414b507ea10a81)
@@ -46,6 +46,7 @@
+