Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj =================================================================== diff -u -r96764c996a0c059b15ccfd968ba165a0ede1b1e3 -rbcc66e2160dd443e08145f036176875f0fc87b62 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj (.../Ringtoets.MacroStabilityInwards.Data.csproj) (revision 96764c996a0c059b15ccfd968ba165a0ede1b1e3) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj (.../Ringtoets.MacroStabilityInwards.Data.csproj) (revision bcc66e2160dd443e08145f036176875f0fc87b62) @@ -77,7 +77,6 @@ - Fisheye: Tag bcc66e2160dd443e08145f036176875f0fc87b62 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelper.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsStochasticSoilProfileProperties.cs =================================================================== diff -u -r0950c1a469810e87b914ad0bc0cebbca32850a4e -rbcc66e2160dd443e08145f036176875f0fc87b62 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsStochasticSoilProfileProperties.cs (.../MacroStabilityInwardsStochasticSoilProfileProperties.cs) (revision 0950c1a469810e87b914ad0bc0cebbca32850a4e) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsStochasticSoilProfileProperties.cs (.../MacroStabilityInwardsStochasticSoilProfileProperties.cs) (revision bcc66e2160dd443e08145f036176875f0fc87b62) @@ -109,7 +109,7 @@ { IEnumerable layers = (data.SoilProfile as MacroStabilityInwardsSoilProfile2D)?.Layers; IEnumerable macroStabilityInwardsSoilLayers2D = layers != null - ? MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(layers) + ? MacroStabilityInwardsSoilProfile2DLayerHelper.GetLayersRecursively(layers) : new List(); return macroStabilityInwardsSoilLayers2D?.Select(layer => new MacroStabilityInwardsSoilLayer2DTopLevelProperties(layer)).ToArray() ?? new MacroStabilityInwardsSoilLayer2DTopLevelProperties[0]; Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsInputView.cs =================================================================== diff -u -rda004b349d777118e3fdf7dddca87c7e1fc5b596 -rbcc66e2160dd443e08145f036176875f0fc87b62 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsInputView.cs (.../MacroStabilityInwardsInputView.cs) (revision da004b349d777118e3fdf7dddca87c7e1fc5b596) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsInputView.cs (.../MacroStabilityInwardsInputView.cs) (revision bcc66e2160dd443e08145f036176875f0fc87b62) @@ -322,7 +322,7 @@ { IEnumerable layers = data?.InputParameters.SoilProfileUnderSurfaceLine?.Layers; return layers != null - ? MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(layers) + ? MacroStabilityInwardsSoilProfile2DLayerHelper.GetLayersRecursively(layers) : new List(); } } Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputChartControl.cs =================================================================== diff -u -r187efa574b622ec8fd7d3f82f367974e17dbf138 -rbcc66e2160dd443e08145f036176875f0fc87b62 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputChartControl.cs (.../MacroStabilityInwardsOutputChartControl.cs) (revision 187efa574b622ec8fd7d3f82f367974e17dbf138) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputChartControl.cs (.../MacroStabilityInwardsOutputChartControl.cs) (revision bcc66e2160dd443e08145f036176875f0fc87b62) @@ -19,7 +19,6 @@ // 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 System.Windows.Forms; @@ -250,7 +249,7 @@ { IEnumerable layers = data?.InputParameters.SoilProfileUnderSurfaceLine?.Layers; return layers != null - ? MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(layers) + ? MacroStabilityInwardsSoilProfile2DLayerHelper.GetLayersRecursively(layers) : new List(); } Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsSoilProfile2DLayerHelper.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsSoilProfile2DLayerHelper.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsSoilProfile2DLayerHelper.cs (revision bcc66e2160dd443e08145f036176875f0fc87b62) @@ -0,0 +1,64 @@ +// Copyright (C) Stichting Deltares 2017. 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; + +namespace Ringtoets.MacroStabilityInwards.Primitives +{ + /// + /// Helper methods for dealing with 2D layers. + /// + public static class MacroStabilityInwardsSoilProfile2DLayerHelper + { + /// + /// Method for obtaining all in recursively. + /// + /// The collection of layers to recursively get the layers from. + /// An enumerable with . + /// Thrown when is null. + public static IEnumerable GetLayersRecursively(IEnumerable layers) + { + if (layers == null) + { + throw new ArgumentNullException(nameof(layers)); + } + + return layers.SelectMany(GetLayersRecursively); + } + + private static IEnumerable GetLayersRecursively(IMacroStabilityInwardsSoilLayer2D layer) + { + var layers = new List + { + layer + }; + + foreach (IMacroStabilityInwardsSoilLayer2D nestedLayer in layer.NestedLayers) + { + layers.AddRange(GetLayersRecursively(nestedLayer)); + } + + return layers; + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/Ringtoets.MacroStabilityInwards.Primitives.csproj =================================================================== diff -u -r7585d2fd78627d94d55ffa16423af90a91e4efd4 -rbcc66e2160dd443e08145f036176875f0fc87b62 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/Ringtoets.MacroStabilityInwards.Primitives.csproj (.../Ringtoets.MacroStabilityInwards.Primitives.csproj) (revision 7585d2fd78627d94d55ffa16423af90a91e4efd4) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/Ringtoets.MacroStabilityInwards.Primitives.csproj (.../Ringtoets.MacroStabilityInwards.Primitives.csproj) (revision bcc66e2160dd443e08145f036176875f0fc87b62) @@ -55,6 +55,7 @@ + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj =================================================================== diff -u -r96764c996a0c059b15ccfd968ba165a0ede1b1e3 -rbcc66e2160dd443e08145f036176875f0fc87b62 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.Test.csproj) (revision 96764c996a0c059b15ccfd968ba165a0ede1b1e3) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.Test.csproj) (revision bcc66e2160dd443e08145f036176875f0fc87b62) @@ -87,7 +87,6 @@ - Fisheye: Tag bcc66e2160dd443e08145f036176875f0fc87b62 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelperTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.TestUtil/MacroStabilityInwardsViewChartDataAssert.cs =================================================================== diff -u -rda004b349d777118e3fdf7dddca87c7e1fc5b596 -rbcc66e2160dd443e08145f036176875f0fc87b62 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.TestUtil/MacroStabilityInwardsViewChartDataAssert.cs (.../MacroStabilityInwardsViewChartDataAssert.cs) (revision da004b349d777118e3fdf7dddca87c7e1fc5b596) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.TestUtil/MacroStabilityInwardsViewChartDataAssert.cs (.../MacroStabilityInwardsViewChartDataAssert.cs) (revision bcc66e2160dd443e08145f036176875f0fc87b62) @@ -19,11 +19,9 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System.Collections.Generic; using System.Linq; using Core.Components.Chart.Data; using NUnit.Framework; -using Ringtoets.MacroStabilityInwards.Data.SoilProfile; using Ringtoets.MacroStabilityInwards.Primitives; namespace Ringtoets.MacroStabilityInwards.Forms.TestUtil @@ -69,7 +67,7 @@ var soilProfileChartData = (ChartDataCollection) actual; IMacroStabilityInwardsSoilLayer2D[] layers = soilProfileUnderSurface?.Layers != null - ? MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfileUnderSurface.Layers).ToArray() + ? MacroStabilityInwardsSoilProfile2DLayerHelper.GetLayersRecursively(soilProfileUnderSurface.Layers).ToArray() : new IMacroStabilityInwardsSoilLayer2D[0]; int expectedLayerCount = layers.Length; @@ -107,13 +105,13 @@ { if (i < phreaticLines.Length) { - ChartLineData phreaticLineChartData = (ChartLineData) waternetChartData[i]; + var phreaticLineChartData = (ChartLineData) waternetChartData[i]; Assert.AreEqual(phreaticLines[i].Name, phreaticLineChartData.Name); Assert.AreEqual(phreaticLines[i].Geometry, phreaticLineChartData.Points); } else { - ChartMultipleAreaData waternetLineChartData = (ChartMultipleAreaData) waternetChartData[i]; + var waternetLineChartData = (ChartMultipleAreaData) waternetChartData[i]; MacroStabilityInwardsWaternetLine waternetLine = waternetLines[i - waternetLines.Length]; Assert.AreEqual(waternetLine.Name, waternetLineChartData.Name); Assert.IsTrue(waternetLineChartData.HasData); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSoilProfile2DLayerHelperTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSoilProfile2DLayerHelperTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSoilProfile2DLayerHelperTest.cs (revision bcc66e2160dd443e08145f036176875f0fc87b62) @@ -0,0 +1,114 @@ +// Copyright (C) Stichting Deltares 2017. 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.Base.Geometry; +using NUnit.Framework; +using Ringtoets.MacroStabilityInwards.Data.SoilProfile; + +namespace Ringtoets.MacroStabilityInwards.Primitives.Test +{ + [TestFixture] + public class MacroStabilityInwardsSoilProfile2DLayerHelperTest + { + [Test] + public void GetLayersRecursively_LayersNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityInwardsSoilProfile2DLayerHelper.GetLayersRecursively(null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("layers", paramName); + } + + [Test] + public void GetLayersRecursively_WithLayers_ReturnsAllTopLevelAndNestedLayers() + { + // Setup + var nestedLayer1 = new MacroStabilityInwardsSoilLayer2D(new Ring(new List + { + new Point2D(4.0, 2.0), + new Point2D(0.0, 2.5) + }), new List()); + + var topLevelLayer1 = new MacroStabilityInwardsSoilLayer2D(new Ring(new List + { + new Point2D(0.0, 1.0), + new Point2D(2.0, 4.0) + }), + new List(), + new MacroStabilityInwardsSoilLayerData(), + new[] + { + nestedLayer1 + }); + + var doubleNestedLayer = new MacroStabilityInwardsSoilLayer2D(new Ring(new List + { + new Point2D(4.0, 2.0), + new Point2D(0.0, 2.5) + }), new List()); + + var nestedLayer2 = new MacroStabilityInwardsSoilLayer2D(new Ring(new List + { + new Point2D(4.0, 2.0), + new Point2D(0.0, 2.5) + }), + new List(), + new MacroStabilityInwardsSoilLayerData(), + new[] + { + doubleNestedLayer + }); + + var topLevelLayer2 = new MacroStabilityInwardsSoilLayer2D(new Ring(new List + { + new Point2D(3.0, 1.0), + new Point2D(8.0, 3.0) + }), new List(), + new MacroStabilityInwardsSoilLayerData(), + new[] + { + nestedLayer2 + }); + var layers = new[] + { + topLevelLayer1, + topLevelLayer2 + }; + + // Call + IEnumerable flatLayers = MacroStabilityInwardsSoilProfile2DLayerHelper.GetLayersRecursively(layers); + + // Assert + CollectionAssert.AreEqual(new[] + { + topLevelLayer1, + nestedLayer1, + topLevelLayer2, + nestedLayer2, + doubleNestedLayer + }, flatLayers); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/Ringtoets.MacroStabilityInwards.Primitives.Test.csproj =================================================================== diff -u -rcfa7dc2bce5e37f5677d9c8772b68599f9e26a0c -rbcc66e2160dd443e08145f036176875f0fc87b62 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/Ringtoets.MacroStabilityInwards.Primitives.Test.csproj (.../Ringtoets.MacroStabilityInwards.Primitives.Test.csproj) (revision cfa7dc2bce5e37f5677d9c8772b68599f9e26a0c) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/Ringtoets.MacroStabilityInwards.Primitives.Test.csproj (.../Ringtoets.MacroStabilityInwards.Primitives.Test.csproj) (revision bcc66e2160dd443e08145f036176875f0fc87b62) @@ -55,6 +55,7 @@ +