Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Factories/MacroStabilityOutwardsAssemblyMapDataFeaturesFactory.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Factories/MacroStabilityOutwardsAssemblyMapDataFeaturesFactory.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Factories/MacroStabilityOutwardsAssemblyMapDataFeaturesFactory.cs (revision affe257dd529713fe3efe5af0dacbb9898217afb) @@ -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.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.AssemblyFactories; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Forms.Factories +{ + /// + /// Factory for creating collections of for assembly results in a . + /// + public static class MacroStabilityOutwardsAssemblyMapDataFeaturesFactory + { + /// + /// 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(MacroStabilityOutwardsFailureMechanism failureMechanism) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures( + failureMechanism, + MacroStabilityOutwardsFailureMechanismAssemblyFactory.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(MacroStabilityOutwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures( + failureMechanism, + sectionResult => MacroStabilityOutwardsFailureMechanismAssemblyFactory.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(MacroStabilityOutwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures( + failureMechanism, + sectionResult => MacroStabilityOutwardsFailureMechanismAssemblyFactory.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(MacroStabilityOutwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures( + failureMechanism, + sectionResult => MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment( + sectionResult, + failureMechanism, + assessmentSection)); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj =================================================================== diff -u -rb8b024eb53a66982983e881cdf054ee64f4cee46 -raffe257dd529713fe3efe5af0dacbb9898217afb --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision b8b024eb53a66982983e881cdf054ee64f4cee46) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision affe257dd529713fe3efe5af0dacbb9898217afb) @@ -18,6 +18,7 @@ + Form Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Factories/MacroStabilityOutwardsAssemblyMapDataFeaturesFactoryTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Factories/MacroStabilityOutwardsAssemblyMapDataFeaturesFactoryTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Factories/MacroStabilityOutwardsAssemblyMapDataFeaturesFactoryTest.cs (revision affe257dd529713fe3efe5af0dacbb9898217afb) @@ -0,0 +1,239 @@ +// 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 Rhino.Mocks; +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.AssessmentSection; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.TestUtil; +using Ringtoets.Integration.Data.StandAlone; +using Ringtoets.Integration.Forms.Factories; + +namespace Ringtoets.Integration.Forms.Test.Factories +{ + [TestFixture] + public class MacroStabilityOutwardsAssemblyMapDataFeaturesFactoryTest + { + [Test] + public void CreateSimpleAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityOutwardsAssemblyMapDataFeaturesFactory.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 MacroStabilityOutwardsFailureMechanism(); + 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 = MacroStabilityOutwardsAssemblyMapDataFeaturesFactory.CreateSimpleAssemblyFeatures(failureMechanism); + + // Assert + MapFeaturesTestHelper.AssertAssemblyCategoryGroupMapFeatures(calculator.SimpleAssessmentAssemblyOutput.Group, failureMechanism, features); + } + } + + [Test] + public void CreateDetailedAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityOutwardsAssemblyMapDataFeaturesFactory.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 = () => MacroStabilityOutwardsAssemblyMapDataFeaturesFactory.CreateDetailedAssemblyFeatures(new MacroStabilityOutwardsFailureMechanism(), 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 MacroStabilityOutwardsFailureMechanism(); + 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 = MacroStabilityOutwardsAssemblyMapDataFeaturesFactory.CreateDetailedAssemblyFeatures(failureMechanism, + assessmentSection); + + // Assert + MapFeaturesTestHelper.AssertAssemblyCategoryGroupMapFeatures(calculator.DetailedAssessmentAssemblyOutput.Group, failureMechanism, features); + } + } + + [Test] + public void CreateTailorMadeAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityOutwardsAssemblyMapDataFeaturesFactory.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 = () => MacroStabilityOutwardsAssemblyMapDataFeaturesFactory.CreateTailorMadeAssemblyFeatures(new MacroStabilityOutwardsFailureMechanism(), 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 MacroStabilityOutwardsFailureMechanism(); + 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 = MacroStabilityOutwardsAssemblyMapDataFeaturesFactory.CreateTailorMadeAssemblyFeatures(failureMechanism, + assessmentSection); + + // Assert + MapFeaturesTestHelper.AssertAssemblyCategoryGroupMapFeatures(calculator.TailorMadeAssessmentAssemblyOutput.Group, failureMechanism, features); + } + } + + [Test] + public void CreateCombinedAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => MacroStabilityOutwardsAssemblyMapDataFeaturesFactory.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 = () => MacroStabilityOutwardsAssemblyMapDataFeaturesFactory.CreateCombinedAssemblyFeatures(new MacroStabilityOutwardsFailureMechanism(), 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 MacroStabilityOutwardsFailureMechanism(); + 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 = MacroStabilityOutwardsAssemblyMapDataFeaturesFactory.CreateCombinedAssemblyFeatures(failureMechanism, + assessmentSection); + + // Assert + MapFeaturesTestHelper.AssertAssemblyCategoryGroupMapFeatures(calculator.CombinedAssemblyCategoryOutput.Value, failureMechanism, features); + } + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj =================================================================== diff -u -rb8b024eb53a66982983e881cdf054ee64f4cee46 -raffe257dd529713fe3efe5af0dacbb9898217afb --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision b8b024eb53a66982983e881cdf054ee64f4cee46) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision affe257dd529713fe3efe5af0dacbb9898217afb) @@ -33,6 +33,7 @@ +