Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Factories/GrassCoverErosionInwardsAssemblyMapDataFeaturesFactory.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Factories/GrassCoverErosionInwardsAssemblyMapDataFeaturesFactory.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Factories/GrassCoverErosionInwardsAssemblyMapDataFeaturesFactory.cs (revision 7d945fdf7703ac34381e37b9215e647328930fc6)
@@ -0,0 +1,140 @@
+// 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 Core.Components.Gis.Features;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Forms.Factories;
+using Ringtoets.GrassCoverErosionInwards.Data;
+
+namespace Ringtoets.GrassCoverErosionInwards.Forms.Factories
+{
+ ///
+ /// Factory for creating collections of for assembly results in a .
+ ///
+ public static class GrassCoverErosionInwardsAssemblyMapDataFeaturesFactory
+ {
+ ///
+ /// Creates features for the simple assembly results in .
+ ///
+ /// The to create the features for.
+ /// A collection of .
+ /// Thrown when
+ /// is null.
+ public static IEnumerable CreateSimpleAssemblyFeatures(GrassCoverErosionInwardsFailureMechanism failureMechanism)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ return AssemblyMapDataFeaturesFactory.CreateAssemblyFeatures(
+ failureMechanism,
+ GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment);
+ }
+
+ ///
+ /// Creates features for the detailed assembly results in .
+ ///
+ /// The to create the features for.
+ /// The the belongs to.
+ /// A collection of .
+ /// Thrown when any parameter is null.
+ public static IEnumerable CreateDetailedAssemblyFeatures(GrassCoverErosionInwardsFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ return AssemblyMapDataFeaturesFactory.CreateAssemblyFeatures(
+ failureMechanism,
+ sectionResult => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(
+ sectionResult,
+ failureMechanism,
+ assessmentSection));
+ }
+
+ ///
+ /// Creates features for the tailor made assembly results in .
+ ///
+ /// The to create the features for.
+ /// The the belongs to.
+ /// A collection of .
+ /// Thrown when any parameter is null.
+ public static IEnumerable CreateTailorMadeAssemblyFeatures(GrassCoverErosionInwardsFailureMechanism failureMechanism, IAssessmentSection assessmentSection)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ return AssemblyMapDataFeaturesFactory.CreateAssemblyFeatures(
+ failureMechanism,
+ sectionResult => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(sectionResult,
+ failureMechanism,
+ assessmentSection));
+ }
+
+ ///
+ /// Creates features for the combined assembly results in .
+ ///
+ /// The to create the features for.
+ /// The the belongs to.
+ /// A collection of .
+ /// Thrown when any parameter is null.
+ public static IEnumerable CreateCombinedAssemblyFeatures(GrassCoverErosionInwardsFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ return AssemblyMapDataFeaturesFactory.CreateAssemblyFeatures(
+ failureMechanism,
+ sectionResult => GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(
+ sectionResult,
+ failureMechanism,
+ assessmentSection));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj
===================================================================
diff -u -r21ee838997690c7f1cdc9eaf5089e309aa4291d6 -r7d945fdf7703ac34381e37b9215e647328930fc6
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.csproj) (revision 21ee838997690c7f1cdc9eaf5089e309aa4291d6)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.csproj) (revision 7d945fdf7703ac34381e37b9215e647328930fc6)
@@ -13,6 +13,7 @@
+
Form
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Factories/GrassCoverErosionInwardsAssemblyMapDataFeaturesFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Factories/GrassCoverErosionInwardsAssemblyMapDataFeaturesFactoryTest.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Factories/GrassCoverErosionInwardsAssemblyMapDataFeaturesFactoryTest.cs (revision 7d945fdf7703ac34381e37b9215e647328930fc6)
@@ -0,0 +1,298 @@
+// 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 NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.AssemblyTool.Forms;
+using Ringtoets.AssemblyTool.KernelWrapper.Calculators;
+using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators;
+using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.GrassCoverErosionInwards.Data;
+using Ringtoets.GrassCoverErosionInwards.Forms.Factories;
+
+namespace Ringtoets.GrassCoverErosionInwards.Forms.Test.Factories
+{
+ [TestFixture]
+ public class GrassCoverErosionInwardsAssemblyMapDataFeaturesFactoryTest
+ {
+ private const string categoryMetaData = "Categorie";
+ private const string probabilityMetaData = "Faalkans";
+
+ [Test]
+ public void CreateSimpleAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => GrassCoverErosionInwardsAssemblyMapDataFeaturesFactory.CreateSimpleAssemblyFeatures(null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("failureMechanism", paramName);
+ }
+
+ [Test]
+ public void CreateSimpleAssemblyFeatures_WithValidData_ReturnsFeaturesCollection()
+ {
+ // Setup
+ var random = new Random(39);
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(0, 10));
+
+ using (new AssemblyToolCalculatorFactoryConfig())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ calculator.SimpleAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(random.NextDouble(),
+ random.NextEnumValue());
+
+ // Call
+ IEnumerable features = GrassCoverErosionInwardsAssemblyMapDataFeaturesFactory.CreateSimpleAssemblyFeatures(failureMechanism);
+
+ // Assert
+ Assert.AreEqual(failureMechanism.Sections.Count(), features.Count());
+
+ for (var i = 0; i < features.Count(); i++)
+ {
+ FailureMechanismSection section = failureMechanism.Sections.ElementAt(i);
+ Assert.AreEqual(1, features.ElementAt(i).MapGeometries.Count());
+ CollectionAssert.AreEqual(section.Points, features.ElementAt(i).MapGeometries.Single().PointCollections.Single());
+ Assert.AreEqual(2, features.ElementAt(i).MetaData.Keys.Count);
+ Assert.AreEqual(new EnumDisplayWrapper(
+ DisplayFailureMechanismSectionAssemblyCategoryGroupConverter.Convert(calculator.SimpleAssessmentAssemblyOutput.Group)).DisplayName,
+ features.ElementAt(i).MetaData[categoryMetaData]);
+ Assert.AreEqual(calculator.SimpleAssessmentAssemblyOutput.Probability,
+ features.ElementAt(i).MetaData[probabilityMetaData]);
+ }
+ }
+ }
+
+ [Test]
+ public void CreateDetailedAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => GrassCoverErosionInwardsAssemblyMapDataFeaturesFactory.CreateDetailedAssemblyFeatures(null, assessmentSection);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("failureMechanism", paramName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CreateDetailedAssemblyFeatures_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => GrassCoverErosionInwardsAssemblyMapDataFeaturesFactory.CreateDetailedAssemblyFeatures(new GrassCoverErosionInwardsFailureMechanism(), null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("assessmentSection", paramName);
+ }
+
+ [Test]
+ public void CreateDetailedAssemblyFeatures_WithValidData_ReturnsFeaturesCollection()
+ {
+ // Setup
+ var random = new Random(39);
+ var assessmentSection = new AssessmentSectionStub();
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(0, 10));
+
+ using (new AssemblyToolCalculatorFactoryConfig())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ calculator.DetailedAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(random.NextDouble(),
+ random.NextEnumValue());
+
+ // Call
+ IEnumerable features = GrassCoverErosionInwardsAssemblyMapDataFeaturesFactory.CreateDetailedAssemblyFeatures(failureMechanism,
+ assessmentSection);
+
+ // Assert
+ Assert.AreEqual(failureMechanism.Sections.Count(), features.Count());
+
+ for (var i = 0; i < features.Count(); i++)
+ {
+ FailureMechanismSection section = failureMechanism.Sections.ElementAt(i);
+ Assert.AreEqual(1, features.ElementAt(i).MapGeometries.Count());
+ CollectionAssert.AreEqual(section.Points, features.ElementAt(i).MapGeometries.Single().PointCollections.Single());
+ Assert.AreEqual(2, features.ElementAt(i).MetaData.Keys.Count);
+ Assert.AreEqual(new EnumDisplayWrapper(
+ DisplayFailureMechanismSectionAssemblyCategoryGroupConverter.Convert(calculator.DetailedAssessmentAssemblyOutput.Group)).DisplayName,
+ features.ElementAt(i).MetaData[categoryMetaData]);
+ Assert.AreEqual(calculator.DetailedAssessmentAssemblyOutput.Probability,
+ features.ElementAt(i).MetaData[probabilityMetaData]);
+ }
+ }
+ }
+
+ [Test]
+ public void CreateTailorMadeAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => GrassCoverErosionInwardsAssemblyMapDataFeaturesFactory.CreateTailorMadeAssemblyFeatures(null, assessmentSection);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("failureMechanism", paramName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CreateTailorMadeAssemblyFeatures_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => GrassCoverErosionInwardsAssemblyMapDataFeaturesFactory.CreateTailorMadeAssemblyFeatures(new GrassCoverErosionInwardsFailureMechanism(), null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("assessmentSection", paramName);
+ }
+
+ [Test]
+ public void CreateTailorMadeAssemblyFeatures_WithValidData_ReturnsFeaturesCollection()
+ {
+ // Setup
+ var random = new Random(39);
+ var assessmentSection = new AssessmentSectionStub();
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(0, 10));
+
+ using (new AssemblyToolCalculatorFactoryConfig())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ calculator.TailorMadeAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(random.NextDouble(),
+ random.NextEnumValue());
+
+ // Call
+ IEnumerable features = GrassCoverErosionInwardsAssemblyMapDataFeaturesFactory.CreateTailorMadeAssemblyFeatures(failureMechanism,
+ assessmentSection);
+
+ // Assert
+ Assert.AreEqual(failureMechanism.Sections.Count(), features.Count());
+
+ for (var i = 0; i < features.Count(); i++)
+ {
+ FailureMechanismSection section = failureMechanism.Sections.ElementAt(i);
+ Assert.AreEqual(1, features.ElementAt(i).MapGeometries.Count());
+ CollectionAssert.AreEqual(section.Points, features.ElementAt(i).MapGeometries.Single().PointCollections.Single());
+ Assert.AreEqual(2, features.ElementAt(i).MetaData.Keys.Count);
+ Assert.AreEqual(new EnumDisplayWrapper(
+ DisplayFailureMechanismSectionAssemblyCategoryGroupConverter.Convert(calculator.TailorMadeAssessmentAssemblyOutput.Group)).DisplayName,
+ features.ElementAt(i).MetaData[categoryMetaData]);
+ Assert.AreEqual(calculator.TailorMadeAssessmentAssemblyOutput.Probability,
+ features.ElementAt(i).MetaData[probabilityMetaData]);
+ }
+ }
+ }
+
+ [Test]
+ public void CreateCombinedAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => GrassCoverErosionInwardsAssemblyMapDataFeaturesFactory.CreateCombinedAssemblyFeatures(null, assessmentSection);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("failureMechanism", paramName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CreateCombinedAssemblyFeatures_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => GrassCoverErosionInwardsAssemblyMapDataFeaturesFactory.CreateCombinedAssemblyFeatures(new GrassCoverErosionInwardsFailureMechanism(), null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("assessmentSection", paramName);
+ }
+
+ [Test]
+ public void CreateCombinedAssemblyFeatures_WithValidData_ReturnsFeaturesCollection()
+ {
+ // Setup
+ var random = new Random(39);
+ var assessmentSection = new AssessmentSectionStub();
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+ FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(0, 10));
+
+ using (new AssemblyToolCalculatorFactoryConfig())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+
+ calculator.CombinedAssemblyOutput = new FailureMechanismSectionAssembly(random.NextDouble(),
+ random.NextEnumValue());
+
+ // Call
+ IEnumerable features = GrassCoverErosionInwardsAssemblyMapDataFeaturesFactory.CreateCombinedAssemblyFeatures(failureMechanism,
+ assessmentSection);
+
+ // Assert
+ Assert.AreEqual(failureMechanism.Sections.Count(), features.Count());
+
+ for (var i = 0; i < features.Count(); i++)
+ {
+ FailureMechanismSection section = failureMechanism.Sections.ElementAt(i);
+ Assert.AreEqual(1, features.ElementAt(i).MapGeometries.Count());
+ CollectionAssert.AreEqual(section.Points, features.ElementAt(i).MapGeometries.Single().PointCollections.Single());
+ Assert.AreEqual(2, features.ElementAt(i).MetaData.Keys.Count);
+ Assert.AreEqual(new EnumDisplayWrapper(
+ DisplayFailureMechanismSectionAssemblyCategoryGroupConverter.Convert(calculator.CombinedAssemblyOutput.Group)).DisplayName,
+ features.ElementAt(i).MetaData[categoryMetaData]);
+ Assert.AreEqual(calculator.CombinedAssemblyOutput.Probability,
+ features.ElementAt(i).MetaData[probabilityMetaData]);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj
===================================================================
diff -u -r21ee838997690c7f1cdc9eaf5089e309aa4291d6 -r7d945fdf7703ac34381e37b9215e647328930fc6
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj) (revision 21ee838997690c7f1cdc9eaf5089e309aa4291d6)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj) (revision 7d945fdf7703ac34381e37b9215e647328930fc6)
@@ -24,6 +24,7 @@
+
@@ -110,6 +111,10 @@
{420ED9C3-0C33-47EA-B893-121A9C0DB4F1}
Ringtoets.AssemblyTool.Data
+
+ {22C5DDB8-2491-4BC6-BDC6-2A7B7EBF40C1}
+ Ringtoets.AssemblyTool.Forms
+
{358B6DA2-A1DF-477F-B6AC-C30204265CB0}
Ringtoets.AssemblyTool.KernelWrapper