Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/AssemblyMapDataFeaturesFactory.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/AssemblyMapDataFeaturesFactory.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/AssemblyMapDataFeaturesFactory.cs (revision f70e531b2ee3cf4877e41d4ea47c7d759c48de07)
@@ -0,0 +1,85 @@
+// Copyright (C) Stichting Deltares 2018. 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 Core.Common.Util;
+using Core.Components.Gis.Features;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.AssemblyTool.Forms;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Forms.Properties;
+
+namespace Ringtoets.Common.Forms.Factories
+{
+ ///
+ /// Factory for creating instances for assembly data.
+ ///
+ public static class AssemblyMapDataFeaturesFactory
+ {
+ ///
+ /// Creates a collection of for instances of .
+ ///
+ /// The type of failure mechanism to create the features for.
+ /// The type of section result to create the features for.
+ /// The failure mechanism to create the features for.
+ /// The used to assemble the result of a section result.
+ /// A collection of .
+ /// Thrown when any parameter is null.
+ public static IEnumerable CreateAssemblyFeatures(
+ TFailureMechanism failureMechanism, Func getAssemblyFunc)
+ where TFailureMechanism : IHasSectionResults
+ where TSectionResult : FailureMechanismSectionResult
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (getAssemblyFunc == null)
+ {
+ throw new ArgumentNullException(nameof(getAssemblyFunc));
+ }
+
+ return CreateFeatures(failureMechanism, getAssemblyFunc).ToArray();
+ }
+
+ private static IEnumerable CreateFeatures(
+ TFailureMechanism failureMechanism, Func getAssemblyFunc)
+ where TFailureMechanism : IHasSectionResults where TSectionResult : FailureMechanismSectionResult
+ {
+ foreach (TSectionResult sectionResult in failureMechanism.SectionResults)
+ {
+ MapFeature feature = RingtoetsMapDataFeaturesFactory.CreateSingleLineMapFeature(sectionResult.Section.Points);
+ FailureMechanismSectionAssembly assemblyResult = getAssemblyFunc(sectionResult);
+
+ feature.MetaData[Resources.AssemblyCategory_Group_DisplayName] =
+ new EnumDisplayWrapper(
+ DisplayFailureMechanismSectionAssemblyCategoryGroupConverter.Convert(assemblyResult.Group)).DisplayName;
+
+ feature.MetaData[Resources.MetaData_Probability] = assemblyResult.Probability;
+
+ yield return feature;
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj
===================================================================
diff -u -rb9d48f272caaffb9d0ee553ddf12d1d3af8966c2 -rf70e531b2ee3cf4877e41d4ea47c7d759c48de07
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision b9d48f272caaffb9d0ee553ddf12d1d3af8966c2)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision f70e531b2ee3cf4877e41d4ea47c7d759c48de07)
@@ -45,6 +45,7 @@
UserControl
+
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/AssemblyMapDataFeaturesFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/AssemblyMapDataFeaturesFactoryTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/AssemblyMapDataFeaturesFactoryTest.cs (revision f70e531b2ee3cf4877e41d4ea47c7d759c48de07)
@@ -0,0 +1,102 @@
+// Copyright (C) Stichting Deltares 2018. 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 Core.Common.TestUtil;
+using Core.Common.Util;
+using Core.Components.Gis.Features;
+using Core.Components.Gis.Geometries;
+using NUnit.Framework;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.AssemblyTool.Forms;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Forms.Factories;
+
+namespace Ringtoets.Common.Forms.Test.Factories
+{
+ [TestFixture]
+ public class AssemblyMapDataFeaturesFactoryTest
+ {
+ private const string categoryMetaData = "Categorie";
+ private const string probabilityMetaData = "Faalkans";
+
+ [Test]
+ public void CreateAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => AssemblyMapDataFeaturesFactory.CreateAssemblyFeatures<
+ IHasSectionResults, FailureMechanismSectionResult>(null, sr => null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("failureMechanism", paramName);
+ }
+
+ [Test]
+ public void CreateAssemblyFeatures_GetAssemblyFuncNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => AssemblyMapDataFeaturesFactory.CreateAssemblyFeatures<
+ TestFailureMechanism, FailureMechanismSectionResult>(new TestFailureMechanism(), null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("getAssemblyFunc", paramName);
+ }
+
+ [Test]
+ public void CreateAssemblyFeatures_ValidParameters_ReturnsExpectedFeatures()
+ {
+ // Setup
+ var random = new Random(39);
+ var failureMechanism = new TestFailureMechanism();
+ FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(0, 10));
+
+ var expectedAssembly = new FailureMechanismSectionAssembly(random.NextDouble(), random.NextEnumValue());
+
+ // Call
+ IEnumerable features = AssemblyMapDataFeaturesFactory.CreateAssemblyFeatures<
+ TestFailureMechanism, FailureMechanismSectionResult>(failureMechanism, sr => expectedAssembly);
+
+ // Assert
+ Assert.AreEqual(failureMechanism.Sections.Count(), features.Count());
+
+ for (var i = 0; i < features.Count(); i++)
+ {
+ FailureMechanismSection section = failureMechanism.Sections.ElementAt(i);
+ MapFeature mapFeature = features.ElementAt(i);
+ IEnumerable mapGeometries = mapFeature.MapGeometries;
+
+ Assert.AreEqual(1, mapGeometries.Count());
+ CollectionAssert.AreEqual(section.Points, mapGeometries.Single().PointCollections.First());
+ Assert.AreEqual(2, mapFeature.MetaData.Keys.Count);
+ Assert.AreEqual(new EnumDisplayWrapper(
+ DisplayFailureMechanismSectionAssemblyCategoryGroupConverter.Convert(expectedAssembly.Group)).DisplayName,
+ mapFeature.MetaData[categoryMetaData]);
+ Assert.AreEqual(expectedAssembly.Probability,
+ mapFeature.MetaData[probabilityMetaData]);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj
===================================================================
diff -u -rb9d48f272caaffb9d0ee553ddf12d1d3af8966c2 -rf70e531b2ee3cf4877e41d4ea47c7d759c48de07
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision b9d48f272caaffb9d0ee553ddf12d1d3af8966c2)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision f70e531b2ee3cf4877e41d4ea47c7d759c48de07)
@@ -55,6 +55,7 @@
+