Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/MapFeaturesTestHelper.cs =================================================================== diff -u -r3162e23b463387eb282a33e090921244a33224aa -r6c65d8a1845a668be0982ce1d53f607a9766b1d0 --- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/MapFeaturesTestHelper.cs (.../MapFeaturesTestHelper.cs) (revision 3162e23b463387eb282a33e090921244a33224aa) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/MapFeaturesTestHelper.cs (.../MapFeaturesTestHelper.cs) (revision 6c65d8a1845a668be0982ce1d53f607a9766b1d0) @@ -136,6 +136,39 @@ } } + /// + /// Asserts whether contains the data that is representative for the data + /// in and . + /// + /// The expected . + /// The failure mechanism that contains the sections. + /// The features that need to be asserted. + /// Thrown when: + /// + /// the number of sections and features are not the same; + /// the properties of a section and the are not the same as + /// the one in the features. + /// + /// + public static void AssertAssemblyCategoryGroupMapFeatures(FailureMechanismSectionAssemblyCategoryGroup expectedCategoryGroup, + IFailureMechanism failureMechanism, + IEnumerable features) + { + IEnumerable sections = failureMechanism.Sections; + Assert.AreEqual(sections.Count(), features.Count()); + + for (var i = 0; i < features.Count(); i++) + { + FailureMechanismSection section = sections.ElementAt(i); + Assert.AreEqual(1, features.ElementAt(i).MapGeometries.Count()); + CollectionAssert.AreEqual(section.Points, features.ElementAt(i).MapGeometries.Single().PointCollections.Single()); + Assert.AreEqual(1, features.ElementAt(i).MetaData.Keys.Count); + Assert.AreEqual(new EnumDisplayWrapper( + DisplayFailureMechanismSectionAssemblyCategoryGroupConverter.Convert(expectedCategoryGroup)).DisplayName, + features.ElementAt(i).MetaData[categoryMetaData]); + } + } + private static string GetExpectedResult(IEnumerable calculations, HydraulicBoundaryLocation hydraulicBoundaryLocation) { Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Factories/StabilityStoneCoverAssemblyMapDataFeaturesFactory.cs =================================================================== diff -u --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Factories/StabilityStoneCoverAssemblyMapDataFeaturesFactory.cs (revision 0) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Factories/StabilityStoneCoverAssemblyMapDataFeaturesFactory.cs (revision 6c65d8a1845a668be0982ce1d53f607a9766b1d0) @@ -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.StabilityStoneCover.Data; + +namespace Ringtoets.StabilityStoneCover.Forms.Factories +{ + /// + /// Factory for creating collections of for assembly results in a . + /// + public static class StabilityStoneCoverAssemblyMapDataFeaturesFactory + { + /// + /// 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(StabilityStoneCoverFailureMechanism failureMechanism) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures( + failureMechanism, + StabilityStoneCoverFailureMechanismAssemblyFactory.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(StabilityStoneCoverFailureMechanism failureMechanism) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures( + failureMechanism, + StabilityStoneCoverFailureMechanismAssemblyFactory.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(StabilityStoneCoverFailureMechanism failureMechanism) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures( + failureMechanism, + StabilityStoneCoverFailureMechanismAssemblyFactory.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(StabilityStoneCoverFailureMechanism failureMechanism) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures( + failureMechanism, + StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment); + } + } +} \ No newline at end of file Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Ringtoets.StabilityStoneCover.Forms.csproj =================================================================== diff -u -rca9e746d966292fe024987a59d144060d1920704 -r6c65d8a1845a668be0982ce1d53f607a9766b1d0 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Ringtoets.StabilityStoneCover.Forms.csproj (.../Ringtoets.StabilityStoneCover.Forms.csproj) (revision ca9e746d966292fe024987a59d144060d1920704) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Ringtoets.StabilityStoneCover.Forms.csproj (.../Ringtoets.StabilityStoneCover.Forms.csproj) (revision 6c65d8a1845a668be0982ce1d53f607a9766b1d0) @@ -13,6 +13,7 @@ + Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Factories/StabilityStoneCoverAssemblyMapDataFeaturesFactoryTest.cs =================================================================== diff -u --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Factories/StabilityStoneCoverAssemblyMapDataFeaturesFactoryTest.cs (revision 0) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Factories/StabilityStoneCoverAssemblyMapDataFeaturesFactoryTest.cs (revision 6c65d8a1845a668be0982ce1d53f607a9766b1d0) @@ -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.StabilityStoneCover.Data; +using Ringtoets.StabilityStoneCover.Forms.Factories; + +namespace Ringtoets.StabilityStoneCover.Forms.Test.Factories +{ + [TestFixture] + public class StabilityStoneCoverAssemblyMapDataFeaturesFactoryTest + { + [Test] + public void CreateSimpleAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StabilityStoneCoverAssemblyMapDataFeaturesFactory.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 StabilityStoneCoverFailureMechanism(); + 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 = StabilityStoneCoverAssemblyMapDataFeaturesFactory.CreateSimpleAssemblyFeatures(failureMechanism); + + // Assert + MapFeaturesTestHelper.AssertAssemblyCategoryGroupMapFeatures(calculator.SimpleAssessmentAssemblyOutput.Group, failureMechanism, features); + } + } + + [Test] + public void CreateDetailedAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StabilityStoneCoverAssemblyMapDataFeaturesFactory.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 StabilityStoneCoverFailureMechanism(); + 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 = StabilityStoneCoverAssemblyMapDataFeaturesFactory.CreateDetailedAssemblyFeatures(failureMechanism); + + // Assert + MapFeaturesTestHelper.AssertAssemblyCategoryGroupMapFeatures(calculator.DetailedAssessmentAssemblyGroupOutput.Value, failureMechanism, features); + } + } + + [Test] + public void CreateTailorMadeAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StabilityStoneCoverAssemblyMapDataFeaturesFactory.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 StabilityStoneCoverFailureMechanism(); + 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 = StabilityStoneCoverAssemblyMapDataFeaturesFactory.CreateTailorMadeAssemblyFeatures(failureMechanism); + + // Assert + MapFeaturesTestHelper.AssertAssemblyCategoryGroupMapFeatures(calculator.TailorMadeAssemblyCategoryOutput.Value, failureMechanism, features); + } + } + + [Test] + public void CreateCombinedAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => StabilityStoneCoverAssemblyMapDataFeaturesFactory.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 StabilityStoneCoverFailureMechanism(); + 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 = StabilityStoneCoverAssemblyMapDataFeaturesFactory.CreateCombinedAssemblyFeatures(failureMechanism); + + // Assert + MapFeaturesTestHelper.AssertAssemblyCategoryGroupMapFeatures(calculator.CombinedAssemblyCategoryOutput.Value, failureMechanism, features); + } + } + } +} \ No newline at end of file Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Ringtoets.StabilityStoneCover.Forms.Test.csproj =================================================================== diff -u -rca9e746d966292fe024987a59d144060d1920704 -r6c65d8a1845a668be0982ce1d53f607a9766b1d0 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Ringtoets.StabilityStoneCover.Forms.Test.csproj (.../Ringtoets.StabilityStoneCover.Forms.Test.csproj) (revision ca9e746d966292fe024987a59d144060d1920704) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Ringtoets.StabilityStoneCover.Forms.Test.csproj (.../Ringtoets.StabilityStoneCover.Forms.Test.csproj) (revision 6c65d8a1845a668be0982ce1d53f607a9766b1d0) @@ -30,6 +30,7 @@ +