Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj
===================================================================
diff -u -r7585d2fd78627d94d55ffa16423af90a91e4efd4 -r96764c996a0c059b15ccfd968ba165a0ede1b1e3
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj (.../Ringtoets.MacroStabilityInwards.Data.csproj) (revision 7585d2fd78627d94d55ffa16423af90a91e4efd4)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj (.../Ringtoets.MacroStabilityInwards.Data.csproj) (revision 96764c996a0c059b15ccfd968ba165a0ede1b1e3)
@@ -77,7 +77,7 @@
-
+
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelper.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelper.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelper.cs (revision 96764c996a0c059b15ccfd968ba165a0ede1b1e3)
@@ -0,0 +1,65 @@
+// 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;
+using Ringtoets.MacroStabilityInwards.Primitives;
+
+namespace Ringtoets.MacroStabilityInwards.Data.SoilProfile
+{
+ ///
+ /// Helper methods for dealing with 2D layers in .
+ ///
+ public static class MacroStabilityInwardsSoilProfile2DLayersHelper
+ {
+ ///
+ /// 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
Fisheye: Tag 96764c996a0c059b15ccfd968ba165a0ede1b1e3 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/SoilProfile/MacroStabilityInwardsSoilProfileUnderSurfaceLineExtensions.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsInputView.cs
===================================================================
diff -u -r7585d2fd78627d94d55ffa16423af90a91e4efd4 -r96764c996a0c059b15ccfd968ba165a0ede1b1e3
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsInputView.cs (.../MacroStabilityInwardsInputView.cs) (revision 7585d2fd78627d94d55ffa16423af90a91e4efd4)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsInputView.cs (.../MacroStabilityInwardsInputView.cs) (revision 96764c996a0c059b15ccfd968ba165a0ede1b1e3)
@@ -297,7 +297,10 @@
private IEnumerable GetSoilLayers()
{
- return data?.InputParameters.SoilProfileUnderSurfaceLine?.GetLayersRecursively() ?? new List();
+ IEnumerable layers = data?.InputParameters.SoilProfileUnderSurfaceLine?.Layers;
+ return layers != null
+ ? MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(layers)
+ : new List();
}
}
}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputChartControl.cs
===================================================================
diff -u -r7585d2fd78627d94d55ffa16423af90a91e4efd4 -r96764c996a0c059b15ccfd968ba165a0ede1b1e3
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputChartControl.cs (.../MacroStabilityInwardsOutputChartControl.cs) (revision 7585d2fd78627d94d55ffa16423af90a91e4efd4)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputChartControl.cs (.../MacroStabilityInwardsOutputChartControl.cs) (revision 96764c996a0c059b15ccfd968ba165a0ede1b1e3)
@@ -221,7 +221,10 @@
private IEnumerable GetSoilLayers()
{
- return data?.InputParameters.SoilProfileUnderSurfaceLine?.GetLayersRecursively() ?? new List();
+ IEnumerable layers = data?.InputParameters.SoilProfileUnderSurfaceLine?.Layers;
+ return layers != null
+ ? MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(layers)
+ : new List();
}
}
}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj
===================================================================
diff -u -r7585d2fd78627d94d55ffa16423af90a91e4efd4 -r96764c996a0c059b15ccfd968ba165a0ede1b1e3
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.Test.csproj) (revision 7585d2fd78627d94d55ffa16423af90a91e4efd4)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.Test.csproj) (revision 96764c996a0c059b15ccfd968ba165a0ede1b1e3)
@@ -87,6 +87,7 @@
+
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelperTest.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelperTest.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelperTest.cs (revision 96764c996a0c059b15ccfd968ba165a0ede1b1e3)
@@ -0,0 +1,110 @@
+// 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;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Ringtoets.MacroStabilityInwards.Data.SoilProfile;
+using Ringtoets.MacroStabilityInwards.Primitives;
+
+namespace Ringtoets.MacroStabilityInwards.Data.Test.SoilProfile
+{
+ [TestFixture]
+ public class MacroStabilityInwardsSoilProfile2DLayersHelperTest
+ {
+ [Test]
+ public void GetLayersRecursively_LayersNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("layers", paramName);
+ }
+
+ [Test]
+ public void GetLayersRecursively_WithLayers_ReturnsAllTopLevelAndNestedLayers()
+ {
+ // Setup
+ var topLevelLayer1 = new MacroStabilityInwardsSoilLayer2D(new Ring(new List
+ {
+ new Point2D(0.0, 1.0),
+ new Point2D(2.0, 4.0)
+ }), new List())
+ {
+ NestedLayers = Enumerable.Empty()
+ };
+
+ var doubleNestedLayer = new MacroStabilityInwardsSoilLayer2D(new Ring(new List
+ {
+ new Point2D(4.0, 2.0),
+ new Point2D(0.0, 2.5)
+ }), new List())
+ {
+ NestedLayers = Enumerable.Empty()
+ };
+
+ var nestedLayer = new MacroStabilityInwardsSoilLayer2D(new Ring(new List
+ {
+ new Point2D(4.0, 2.0),
+ new Point2D(0.0, 2.5)
+ }), new List())
+ {
+ NestedLayers = new[]
+ {
+ doubleNestedLayer
+ }
+ };
+
+ var topLevelLayer2 = new MacroStabilityInwardsSoilLayer2D(new Ring(new List
+ {
+ new Point2D(3.0, 1.0),
+ new Point2D(8.0, 3.0)
+ }), new List())
+ {
+ NestedLayers = new[]
+ {
+ nestedLayer
+ }
+ };
+ var layers = new[]
+ {
+ topLevelLayer1,
+ topLevelLayer2
+ };
+
+ // Call
+ IEnumerable flatLayers = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(layers);
+
+ // Assert
+ CollectionAssert.AreEqual(new []
+ {
+ topLevelLayer1,
+ topLevelLayer2,
+ nestedLayer,
+ doubleNestedLayer
+ }, flatLayers);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DPropertiesTest.cs
===================================================================
diff -u -r353cb6e4be6475bbbc9ec71d867582bf3e9cee7d -r96764c996a0c059b15ccfd968ba165a0ede1b1e3
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DPropertiesTest.cs (.../MacroStabilityInwardsSoilLayer2DPropertiesTest.cs) (revision 353cb6e4be6475bbbc9ec71d867582bf3e9cee7d)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DPropertiesTest.cs (.../MacroStabilityInwardsSoilLayer2DPropertiesTest.cs) (revision 96764c996a0c059b15ccfd968ba165a0ede1b1e3)
@@ -68,11 +68,6 @@
public void GetProperties_WithData_ReturnExpectedValues()
{
// Setup
- var nestedLayer = new MacroStabilityInwardsSoilLayer2D(new Ring(new[]
- {
- new Point2D(12.987, 12.821),
- new Point2D(4.23, 1.02)
- }), new Ring[0]);
var layer = new MacroStabilityInwardsSoilLayer2D(new Ring(new[]
{
new Point2D(20.210230, 26.00001),
@@ -87,7 +82,11 @@
},
NestedLayers = new[]
{
- nestedLayer
+ new MacroStabilityInwardsSoilLayer2D(new Ring(new[]
+ {
+ new Point2D(12.987, 12.821),
+ new Point2D(4.23, 1.02)
+ }), new Ring[0])
}
};
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.TestUtil/MacroStabilityInwardsViewChartDataAssert.cs
===================================================================
diff -u -r7585d2fd78627d94d55ffa16423af90a91e4efd4 -r96764c996a0c059b15ccfd968ba165a0ede1b1e3
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.TestUtil/MacroStabilityInwardsViewChartDataAssert.cs (.../MacroStabilityInwardsViewChartDataAssert.cs) (revision 7585d2fd78627d94d55ffa16423af90a91e4efd4)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.TestUtil/MacroStabilityInwardsViewChartDataAssert.cs (.../MacroStabilityInwardsViewChartDataAssert.cs) (revision 96764c996a0c059b15ccfd968ba165a0ede1b1e3)
@@ -67,7 +67,9 @@
Assert.IsInstanceOf(actual);
var soilProfileChartData = (ChartDataCollection) actual;
- IMacroStabilityInwardsSoilLayer2D[] layers = soilProfileUnderSurface?.GetLayersRecursively().ToArray() ?? new IMacroStabilityInwardsSoilLayer2D[0];
+ IMacroStabilityInwardsSoilLayer2D[] layers = soilProfileUnderSurface?.Layers != null
+ ? MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfileUnderSurface.Layers).ToArray()
+ : new IMacroStabilityInwardsSoilLayer2D[0];
int expectedLayerCount = layers.Length;
Assert.AreEqual(expectedLayerCount, soilProfileChartData.Collection.Count());