Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Factories/GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Factories/GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Factories/GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory.cs (revision d4e30ae8f65243ad5c200a22f9c9d7e171bf179f) @@ -0,0 +1,111 @@ +// 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.Forms.Factories; +using Ringtoets.GrassCoverErosionOutwards.Data; + +namespace Ringtoets.GrassCoverErosionOutwards.Forms.Factories +{ + /// + /// Factory for creating collections of for assembly results in a . + /// + public static class GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory + { + /// + /// 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(GrassCoverErosionOutwardsFailureMechanism failureMechanism) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures( + failureMechanism, + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment); + } + + /// + /// Creates features for the detailed assembly results in . + /// + /// The to create the features for. + /// A collection of . + /// Thrown when + /// is null. + public static IEnumerable CreateDetailedAssemblyFeatures(GrassCoverErosionOutwardsFailureMechanism failureMechanism) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures( + failureMechanism, + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment); + } + + /// + /// Creates features for the tailor made assembly results in . + /// + /// The to create the features for. + /// A collection of . + /// Thrown when + /// is null. + public static IEnumerable CreateTailorMadeAssemblyFeatures(GrassCoverErosionOutwardsFailureMechanism failureMechanism) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures( + failureMechanism, + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment); + } + + /// + /// Creates features for the combined assembly results in . + /// + /// The to create the features for. + /// A collection of . + /// Thrown when + /// is null. + public static IEnumerable CreateCombinedAssemblyFeatures(GrassCoverErosionOutwardsFailureMechanism failureMechanism) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures( + failureMechanism, + GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment); + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj =================================================================== diff -u -r433fc2ade8570da2d39f3e93ea7ae895cd88fa74 -rd4e30ae8f65243ad5c200a22f9c9d7e171bf179f --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.csproj) (revision 433fc2ade8570da2d39f3e93ea7ae895cd88fa74) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.csproj) (revision d4e30ae8f65243ad5c200a22f9c9d7e171bf179f) @@ -13,6 +13,7 @@ + Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Factories/GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactoryTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Factories/GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactoryTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Factories/GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactoryTest.cs (revision d4e30ae8f65243ad5c200a22f9c9d7e171bf179f) @@ -0,0 +1,178 @@ +// 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.Common.TestUtil; +using Core.Components.Gis.Features; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.TestUtil; +using Ringtoets.GrassCoverErosionOutwards.Data; +using Ringtoets.GrassCoverErosionOutwards.Forms.Factories; + +namespace Ringtoets.GrassCoverErosionOutwards.Forms.Test.Factories +{ + [TestFixture] + public class GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactoryTest + { + [Test] + public void CreateSimpleAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory.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 GrassCoverErosionOutwardsFailureMechanism(); + 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 = GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory.CreateSimpleAssemblyFeatures(failureMechanism); + + // Assert + MapFeaturesTestHelper.AssertAssemblyCategoryGroupMapFeatures(calculator.SimpleAssessmentAssemblyOutput.Group, failureMechanism, features); + } + } + + [Test] + public void CreateDetailedAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory.CreateDetailedAssemblyFeatures(null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("failureMechanism", paramName); + } + + [Test] + public void CreateDetailedAssemblyFeatures_WithValidData_ReturnsFeaturesCollection() + { + // Setup + var random = new Random(39); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(0, 10)); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + calculator.DetailedAssessmentAssemblyGroupOutput = random.NextEnumValue(); + + // Call + IEnumerable features = GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory.CreateDetailedAssemblyFeatures(failureMechanism); + + // Assert + MapFeaturesTestHelper.AssertAssemblyCategoryGroupMapFeatures(calculator.DetailedAssessmentAssemblyGroupOutput.Value, failureMechanism, features); + } + } + + [Test] + public void CreateTailorMadeAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory.CreateTailorMadeAssemblyFeatures(null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("failureMechanism", paramName); + } + + [Test] + public void CreateTailorMadeAssemblyFeatures_WithValidData_ReturnsFeaturesCollection() + { + // Setup + var random = new Random(39); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(0, 10)); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + calculator.TailorMadeAssemblyCategoryOutput = random.NextEnumValue(); + + // Call + IEnumerable features = GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory.CreateTailorMadeAssemblyFeatures(failureMechanism); + + // Assert + MapFeaturesTestHelper.AssertAssemblyCategoryGroupMapFeatures(calculator.TailorMadeAssemblyCategoryOutput.Value, failureMechanism, features); + } + } + + [Test] + public void CreateCombinedAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory.CreateCombinedAssemblyFeatures(null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("failureMechanism", paramName); + } + + [Test] + public void CreateCombinedAssemblyFeatures_WithValidData_ReturnsFeaturesCollection() + { + // Setup + var random = new Random(39); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(0, 10)); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + calculator.CombinedAssemblyCategoryOutput = random.NextEnumValue(); + + // Call + IEnumerable features = GrassCoverErosionOutwardsAssemblyMapDataFeaturesFactory.CreateCombinedAssemblyFeatures(failureMechanism); + + // Assert + MapFeaturesTestHelper.AssertAssemblyCategoryGroupMapFeatures(calculator.CombinedAssemblyCategoryOutput.Value, failureMechanism, features); + } + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj =================================================================== diff -u -r88616ecff5aaeddc6b5f75daad6ad07f60d9cff4 -rd4e30ae8f65243ad5c200a22f9c9d7e171bf179f --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj) (revision 88616ecff5aaeddc6b5f75daad6ad07f60d9cff4) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj) (revision d4e30ae8f65243ad5c200a22f9c9d7e171bf179f) @@ -24,6 +24,7 @@ +