Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Helpers/ExportableFailureMechanismSectionHelper.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Helpers/ExportableFailureMechanismSectionHelper.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Helpers/ExportableFailureMechanismSectionHelper.cs (revision 712a8c27a403a3da9bb6441d6ecd8ee53172803c)
@@ -0,0 +1,64 @@
+// 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 System.Collections.Generic;
+using System.Linq;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Integration.IO.Assembly;
+using Ringtoets.Integration.IO.Factories;
+
+namespace Ringtoets.Integration.IO.Helpers
+{
+ public static class ExportableFailureMechanismSectionHelper
+ {
+ ///
+ /// Creates a lookup between failure mechanism section results and the corresponding
+ /// .
+ ///
+ /// The type of
+ /// The failure mechanism sections results to create a
+ /// for.
+ /// A between the failure mechanism section results
+ /// and .
+ /// Thrown when is null.n
+ public static IDictionary CreateFailureMechanismSectionResultLookup(
+ IEnumerable failureMechanismSectionResults)
+ where TSectionResult : FailureMechanismSectionResult
+ {
+ if (failureMechanismSectionResults == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanismSectionResults));
+ }
+
+ IEnumerable sections = failureMechanismSectionResults.Select(sr => sr.Section);
+ IEnumerable exportableFailureMechanismSections =
+ ExportableFailureMechanismSectionFactory.CreateExportableFailureMechanismSections(sections);
+
+ return failureMechanismSectionResults.Zip(exportableFailureMechanismSections, (sectionResult, exportableSection) => new
+ {
+ key = sectionResult,
+ value = exportableSection
+ })
+ .ToDictionary(pair => pair.key, pair => pair.value);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj
===================================================================
diff -u -re2ad465c881cae0f566d5aa5e16e476aa2239980 -r712a8c27a403a3da9bb6441d6ecd8ee53172803c
--- Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision e2ad465c881cae0f566d5aa5e16e476aa2239980)
+++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision 712a8c27a403a3da9bb6441d6ecd8ee53172803c)
@@ -59,6 +59,7 @@
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Helpers/ExportableFailureMechanismSectionHelperTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Helpers/ExportableFailureMechanismSectionHelperTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Helpers/ExportableFailureMechanismSectionHelperTest.cs (revision 712a8c27a403a3da9bb6441d6ecd8ee53172803c)
@@ -0,0 +1,96 @@
+// 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 System.Collections.Generic;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Integration.IO.Assembly;
+using Ringtoets.Integration.IO.Helpers;
+
+namespace Ringtoets.Integration.IO.Test.Helpers
+{
+ [TestFixture]
+ public class ExportableFailureMechanismSectionHelperTest
+ {
+ [Test]
+ public void CreateFailureMechanismSectionResultLookup_FailureMechanismSectionResultsNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () =>
+ ExportableFailureMechanismSectionHelper.CreateFailureMechanismSectionResultLookup(null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanismSectionResults", exception.ParamName);
+ }
+
+ [Test]
+ public void CreateFailureMechanismSectionResultLookup_WithFailureMechanismSectionResults_ReturnsExpectedDictionary()
+ {
+ // Setup
+ var failureMechanismSectionResults = new[]
+ {
+ new TestFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection(new[]
+ {
+ new Point2D(0, 0),
+ new Point2D(0, 10)
+ })),
+ new TestFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection(new[]
+ {
+ new Point2D(0, 10),
+ new Point2D(0, 20)
+ })),
+ new TestFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection(new[]
+ {
+ new Point2D(0, 20),
+ new Point2D(0, 40)
+ }))
+ };
+
+ // Call
+ IDictionary failureMechanismSectionResultsLookup =
+ ExportableFailureMechanismSectionHelper.CreateFailureMechanismSectionResultLookup(failureMechanismSectionResults);
+
+ // Assert
+ CollectionAssert.AreEqual(failureMechanismSectionResults, failureMechanismSectionResultsLookup.Keys);
+
+ TestFailureMechanismSectionResult firstSectionResult = failureMechanismSectionResults[0];
+ ExportableFailureMechanismSection firstExportableSection = failureMechanismSectionResultsLookup[firstSectionResult];
+ Assert.AreSame(firstSectionResult.Section.Points, firstExportableSection.Geometry);
+ Assert.AreEqual(0, firstExportableSection.StartDistance);
+ Assert.AreEqual(10, firstExportableSection.EndDistance);
+
+ TestFailureMechanismSectionResult secondSectionResult = failureMechanismSectionResults[1];
+ ExportableFailureMechanismSection secondExportableSection = failureMechanismSectionResultsLookup[secondSectionResult];
+ Assert.AreSame(secondSectionResult.Section.Points, secondExportableSection.Geometry);
+ Assert.AreEqual(10, secondExportableSection.StartDistance);
+ Assert.AreEqual(20, secondExportableSection.EndDistance);
+
+ TestFailureMechanismSectionResult thirdSectionResult = failureMechanismSectionResults[2];
+ ExportableFailureMechanismSection thirdExportableSection = failureMechanismSectionResultsLookup[thirdSectionResult];
+ Assert.AreSame(thirdSectionResult.Section.Points, thirdExportableSection.Geometry);
+ Assert.AreEqual(20, thirdExportableSection.StartDistance);
+ Assert.AreEqual(40, thirdExportableSection.EndDistance);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj
===================================================================
diff -u -r8252a821af2a44171926227f694a73facdb0da3c -r712a8c27a403a3da9bb6441d6ecd8ee53172803c
--- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision 8252a821af2a44171926227f694a73facdb0da3c)
+++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision 712a8c27a403a3da9bb6441d6ecd8ee53172803c)
@@ -61,6 +61,7 @@
+