Index: Core/Common/test/Core.Common.TestUtil.Test/TestHelperTest.cs =================================================================== diff -u -r669e99259a7cc575b5df2be2c0ea7105d9edcbcf -r564a695798dd77c0b90bba14c902c6caefb7786f --- Core/Common/test/Core.Common.TestUtil.Test/TestHelperTest.cs (.../TestHelperTest.cs) (revision 669e99259a7cc575b5df2be2c0ea7105d9edcbcf) +++ Core/Common/test/Core.Common.TestUtil.Test/TestHelperTest.cs (.../TestHelperTest.cs) (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -948,7 +948,7 @@ } [Test] - public void AssertCollectionAreEqual_ExpectedCollectionShorterThanActual_ThrowsException() + public void AssertCollectionsAreEqual_ExpectedCollectionShorterThanActual_ThrowsException() { // Setup var objectA = new object(); @@ -962,7 +962,7 @@ mocks.ReplayAll(); // Call - TestDelegate test = () => TestHelper.AssertCollectionAreEqual(new[] + TestDelegate test = () => TestHelper.AssertCollectionsAreEqual(new[] { objectA, objectB, @@ -981,7 +981,7 @@ } [Test] - public void AssertCollectionAreEqual_ExpectedCollectionLongerThanActual_ThrowsException() + public void AssertCollectionsAreEqual_ExpectedCollectionLongerThanActual_ThrowsException() { // Setup var objectA = new object(); @@ -995,7 +995,7 @@ mocks.ReplayAll(); // Call - TestDelegate test = () => TestHelper.AssertCollectionAreEqual(new[] + TestDelegate test = () => TestHelper.AssertCollectionsAreEqual(new[] { objectA, objectB, @@ -1014,7 +1014,7 @@ } [Test] - public void AssertCollectionAreEqual_CollectionsCompletelyEqual_DoesNotThrowException() + public void AssertCollectionsAreEqual_CollectionsCompletelyEqual_DoesNotThrowException() { // Setup var objectA = new object(); @@ -1027,7 +1027,7 @@ mocks.ReplayAll(); // Call - TestDelegate test = () => TestHelper.AssertCollectionAreEqual(new[] + TestDelegate test = () => TestHelper.AssertCollectionsAreEqual(new[] { objectA, objectB, @@ -1045,7 +1045,7 @@ } [Test] - public void AssertCollectionAreEqual_CollectionsPartiallyEqual_ThrowsException() + public void AssertCollectionsAreEqual_CollectionsPartiallyEqual_ThrowsException() { // Setup var objectA = new object(); @@ -1061,7 +1061,7 @@ mocks.ReplayAll(); // Call - TestDelegate test = () => TestHelper.AssertCollectionAreEqual(new[] + TestDelegate test = () => TestHelper.AssertCollectionsAreEqual(new[] { objectA, objectB, @@ -1081,7 +1081,7 @@ } [Test] - public void AssertCollectionAreEqual_ExpectedCollectionNull_ThrowsException() + public void AssertCollectionsAreEqual_ExpectedCollectionNull_ThrowsException() { // Setup var objectA = new object(); @@ -1094,7 +1094,7 @@ mocks.ReplayAll(); // Call - TestDelegate test = () => TestHelper.AssertCollectionAreEqual(null, + TestDelegate test = () => TestHelper.AssertCollectionsAreEqual(null, new[] { objectA, @@ -1109,7 +1109,7 @@ } [Test] - public void AssertCollectionAreEqual_ActualCollectionNull_ThrowsException() + public void AssertCollectionsAreEqual_ActualCollectionNull_ThrowsException() { // Setup var objectA = new object(); @@ -1122,7 +1122,7 @@ mocks.ReplayAll(); // Call - TestDelegate test = () => TestHelper.AssertCollectionAreEqual(new[] + TestDelegate test = () => TestHelper.AssertCollectionsAreEqual(new[] { objectA, objectB, @@ -1136,7 +1136,7 @@ } [Test] - public void AssertCollectionAreEqual_ComparerNull_ThrowsException() + public void AssertCollectionsAreEqual_ComparerNull_ThrowsException() { // Setup var objectA = new object(); @@ -1145,7 +1145,7 @@ var objectD = new object(); // Call - TestDelegate test = () => TestHelper.AssertCollectionAreEqual(new[] + TestDelegate test = () => TestHelper.AssertCollectionsAreEqual(new[] { objectA, objectB, Index: Core/Common/test/Core.Common.TestUtil/TestHelper.cs =================================================================== diff -u -rdf853f988ad99b935860c361bc000f6aba9876a7 -r564a695798dd77c0b90bba14c902c6caefb7786f --- Core/Common/test/Core.Common.TestUtil/TestHelper.cs (.../TestHelper.cs) (revision df853f988ad99b935860c361bc000f6aba9876a7) +++ Core/Common/test/Core.Common.TestUtil/TestHelper.cs (.../TestHelper.cs) (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -499,7 +499,7 @@ /// element in at that position. /// /// - public static void AssertCollectionAreEqual(IEnumerable expected, IEnumerable actual, IEqualityComparer equalityComparer) + public static void AssertCollectionsAreEqual(IEnumerable expected, IEnumerable actual, IEqualityComparer equalityComparer) { Assert.NotNull(expected, "Expect collection is not expected to be null."); Assert.NotNull(actual, "Actual collection is not expected to be null."); Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/StochasticSoilModel.cs =================================================================== diff -u -rd47809e3a8fadff2be5b10056b79b16dc27eeca2 -r564a695798dd77c0b90bba14c902c6caefb7786f --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/StochasticSoilModel.cs (.../StochasticSoilModel.cs) (revision d47809e3a8fadff2be5b10056b79b16dc27eeca2) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/StochasticSoilModel.cs (.../StochasticSoilModel.cs) (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -112,7 +112,7 @@ } foreach (StochasticSoilProfile profileToRemove in StochasticSoilProfiles.Where( - sp => !newSoilProfiles.Any(newSp => IsSame(newSp as MacroStabilityInwardsSoilProfile1D, sp.SoilProfile as MacroStabilityInwardsSoilProfile1D))).ToArray()) + sp => !newSoilProfiles.Any(newSp => IsSame(newSp, sp.SoilProfile))).ToArray()) { StochasticSoilProfiles.Remove(profileToRemove); removedProfiles.Add(profileToRemove); @@ -126,15 +126,16 @@ return Name; } - private static bool IsSame(MacroStabilityInwardsSoilProfile1D macroStabilityInwardsSoilProfile, MacroStabilityInwardsSoilProfile1D otherMacroStabilityInwardsSoilProfile) + private static bool IsSame(ISoilProfile soilProfile, ISoilProfile otherSoilProfile) { - return macroStabilityInwardsSoilProfile.Name.Equals(otherMacroStabilityInwardsSoilProfile.Name) - && macroStabilityInwardsSoilProfile.SoilProfileType.Equals(otherMacroStabilityInwardsSoilProfile.SoilProfileType); + bool equalNames = soilProfile.Name.Equals(otherSoilProfile.Name); + bool equalTypes = soilProfile.GetType() == otherSoilProfile.GetType(); + return equalNames && equalTypes; } private static bool IsSame(StochasticSoilProfile stochasticSoilProfile, StochasticSoilProfile otherStochasticSoilProfile) { - return IsSame(stochasticSoilProfile.SoilProfile as MacroStabilityInwardsSoilProfile1D, otherStochasticSoilProfile.SoilProfile as MacroStabilityInwardsSoilProfile1D); + return IsSame(stochasticSoilProfile.SoilProfile, otherStochasticSoilProfile.SoilProfile); } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsSoilLayer2D.cs =================================================================== diff -u -r376649a985f9523e6ecac956b3abd39ed1a64369 -r564a695798dd77c0b90bba14c902c6caefb7786f --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsSoilLayer2D.cs (.../MacroStabilityInwardsSoilLayer2D.cs) (revision 376649a985f9523e6ecac956b3abd39ed1a64369) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsSoilLayer2D.cs (.../MacroStabilityInwardsSoilLayer2D.cs) (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -19,6 +19,8 @@ // 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 @@ -32,10 +34,20 @@ /// /// Creates a new instance of . /// - /// - /// - public MacroStabilityInwardsSoilLayer2D(Ring outerRing, Ring[] holes) + /// The ring describing the outer boundaries of the layer. + /// The rings describing the holes within the outer boundaries of + /// the layer. + /// Thrown when any parameter is null. + public MacroStabilityInwardsSoilLayer2D(Ring outerRing, IEnumerable holes) { + if (outerRing == null) + { + throw new ArgumentNullException(nameof(outerRing)); + } + if (holes == null) + { + throw new ArgumentNullException(nameof(holes)); + } Properties = new SoilLayerProperties(); OuterRing = outerRing; Holes = holes.ToArray(); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj =================================================================== diff -u -rcd90ebf744fb74f0d4b0dd6ee06f9c39b5faf213 -r564a695798dd77c0b90bba14c902c6caefb7786f --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.Test.csproj) (revision cd90ebf744fb74f0d4b0dd6ee06f9c39b5faf213) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.Test.csproj) (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -61,7 +61,7 @@ - + Fisheye: Tag 564a695798dd77c0b90bba14c902c6caefb7786f refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/SoilProfileUnderSurfaceLineFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/SoilProfileUnderSurfaceLineFactoryTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/SoilProfileUnderSurfaceLineFactoryTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/SoilProfileUnderSurfaceLineFactoryTest.cs (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -0,0 +1,369 @@ +// 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 Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.MacroStabilityInwards.Primitives; + +namespace Ringtoets.MacroStabilityInwards.Data.Test +{ + [TestFixture] + public class SoilProfileUnderSurfaceLineFactoryTest + { + [Test] + public void Create_SoilProfile1DNull_ThrowArgumentNullException() + { + // Setup + var surfaceLine = new MacroStabilityInwardsSurfaceLine(); + + // Call + TestDelegate test = () => SoilProfileUnderSurfaceLineFactory.Create(null, surfaceLine); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("soilProfile", exception.ParamName); + } + + [Test] + public void Create_SurfaceLineNull_ThrowArgumentNullException() + { + // Setup + var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", 2.0, new[] + { + new MacroStabilityInwardsSoilLayer1D(2) + }, SoilProfileType.SoilProfile1D, 0); + + // Call + TestDelegate test = () => SoilProfileUnderSurfaceLineFactory.Create(soilProfile, null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("surfaceLine", exception.ParamName); + } + + [Test] + public void Create_SoilProfile2DNull_ThrowArgumentNullException() + { + // Call + TestDelegate test = () => SoilProfileUnderSurfaceLineFactory.Create(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("soilProfile", exception.ParamName); + } + + [Test] + public void Create_SurfaceLineOnTopOrAboveSoilLayer_ReturnsSoilLayerPointsAsRectangle() + { + // Setup + var surfaceLine = new MacroStabilityInwardsSurfaceLine(); + surfaceLine.SetGeometry(new[] + { + new Point3D(0, 0, 4), + new Point3D(0, 0, 3.2), + new Point3D(2, 0, 4) + }); + var soilLayer = new MacroStabilityInwardsSoilLayer1D(3.2); + var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", 2.0, new[] + { + soilLayer + }, SoilProfileType.SoilProfile1D, 0); + + // Call + SoilProfileUnderSurfaceLine areas = SoilProfileUnderSurfaceLineFactory.Create(soilProfile, surfaceLine); + + // Assert + Assert.AreEqual(1, areas.LayersUnderSurfaceLine.Count()); + CollectionAssert.AreEqual(new[] + { + new Point2D(2, 3.2), + new Point2D(2, 2), + new Point2D(0, 2), + new Point2D(0, 3.2) + }, areas.LayersUnderSurfaceLine.ElementAt(0).OuterRing); + } + + [Test] + public void Create_SurfaceLineBelowSoilLayer_ReturnsEmptyAreasCollection() + { + // Setup + var surfaceLine = new MacroStabilityInwardsSurfaceLine(); + surfaceLine.SetGeometry(new[] + { + new Point3D(0, 0, 2.0), + new Point3D(2, 0, 2.0) + }); + var soilLayer = new MacroStabilityInwardsSoilLayer1D(3.2); + var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", 2.0, new[] + { + soilLayer + }, SoilProfileType.SoilProfile1D, 0); + + // Call + SoilProfileUnderSurfaceLine areas = SoilProfileUnderSurfaceLineFactory.Create(soilProfile, surfaceLine); + + // Assert + CollectionAssert.IsEmpty(areas.LayersUnderSurfaceLine); + } + + [Test] + public void Create_SurfaceLineThroughMiddleLayerButNotSplittingIt_ReturnsSoilLayerPointsAsRectangleFollowingSurfaceLine() + { + // Setup + var surfaceLine = new MacroStabilityInwardsSurfaceLine(); + surfaceLine.SetGeometry(new[] + { + new Point3D(0, 0, 3.0), + new Point3D(1, 0, 2.0), + new Point3D(2, 0, 3.0) + }); + const double bottom = 1.5; + const double top = 2.5; + var soilLayer = new MacroStabilityInwardsSoilLayer1D(top); + var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", bottom, new[] + { + soilLayer + }, SoilProfileType.SoilProfile1D, 0); + + // Call + SoilProfileUnderSurfaceLine areas = SoilProfileUnderSurfaceLineFactory.Create(soilProfile, surfaceLine); + + // Assert + Assert.AreEqual(1, areas.LayersUnderSurfaceLine.Count()); + CollectionAssert.AreEqual(new[] + { + new Point2D(0.5, top), + new Point2D(1, 2.0), + new Point2D(1.5, top), + new Point2D(2, top), + new Point2D(2, bottom), + new Point2D(0, bottom), + new Point2D(0, top) + }, areas.LayersUnderSurfaceLine.ElementAt(0).OuterRing); + } + + [Test] + public void Create_SurfaceLineThroughMiddleLayerButNotSplittingItIntersectionOnTopLevel_ReturnsSoilLayerPointsAsRectangleFollowingSurfaceLine() + { + // Setup + var surfaceLine = new MacroStabilityInwardsSurfaceLine(); + surfaceLine.SetGeometry(new[] + { + new Point3D(0, 0, 3.0), + new Point3D(0.5, 0, 2.5), + new Point3D(1, 0, 2.0), + new Point3D(1.5, 0, 2.5), + new Point3D(2, 0, 3.0) + }); + const double bottom = 1.5; + const double top = 2.5; + var soilLayer = new MacroStabilityInwardsSoilLayer1D(top); + var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", bottom, new[] + { + soilLayer + }, SoilProfileType.SoilProfile1D, 0); + + // Call + SoilProfileUnderSurfaceLine areas = SoilProfileUnderSurfaceLineFactory.Create(soilProfile, surfaceLine); + + // Assert + Assert.AreEqual(1, areas.LayersUnderSurfaceLine.Count()); + CollectionAssert.AreEqual(new[] + { + new Point2D(0.5, top), + new Point2D(1, 2.0), + new Point2D(1.5, top), + new Point2D(2, top), + new Point2D(2, bottom), + new Point2D(0, bottom), + new Point2D(0, top) + }, areas.LayersUnderSurfaceLine.ElementAt(0).OuterRing); + } + + [Test] + public void Create_SurfaceLineStartsBelowLayerTopButAboveBottom_ReturnsSoilLayerPointsAsRectangleFollowingSurfaceLine() + { + // Setup + var surfaceLine = new MacroStabilityInwardsSurfaceLine(); + surfaceLine.SetGeometry(new[] + { + new Point3D(0, 0, 2.0), + new Point3D(1, 0, 2.0), + new Point3D(2, 0, 3.0) + }); + const double bottom = 1.5; + const double top = 2.5; + var soilLayer = new MacroStabilityInwardsSoilLayer1D(top); + var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", bottom, new[] + { + soilLayer + }, SoilProfileType.SoilProfile1D, 0); + + // Call + SoilProfileUnderSurfaceLine areas = SoilProfileUnderSurfaceLineFactory.Create(soilProfile, surfaceLine); + + // Assert + Assert.AreEqual(1, areas.LayersUnderSurfaceLine.Count()); + CollectionAssert.AreEqual(new[] + { + new Point2D(0, 2.0), + new Point2D(1, 2.0), + new Point2D(1.5, top), + new Point2D(2, top), + new Point2D(2, bottom), + new Point2D(0, bottom) + }, areas.LayersUnderSurfaceLine.ElementAt(0).OuterRing); + } + + [Test] + public void Create_SurfaceLineEndsBelowLayerTopButAboveBottom_ReturnsSoilLayerPointsAsRectangleFollowingSurfaceLine() + { + // Setup + var surfaceLine = new MacroStabilityInwardsSurfaceLine(); + surfaceLine.SetGeometry(new[] + { + new Point3D(0, 0, 3.0), + new Point3D(1, 0, 2.0), + new Point3D(2, 0, 2.0) + }); + const double bottom = 1.5; + const double top = 2.5; + var soilLayer = new MacroStabilityInwardsSoilLayer1D(top); + var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", bottom, new[] + { + soilLayer + }, SoilProfileType.SoilProfile1D, 0); + + // Call + SoilProfileUnderSurfaceLine areas = SoilProfileUnderSurfaceLineFactory.Create(soilProfile, surfaceLine); + + // Assert + Assert.AreEqual(1, areas.LayersUnderSurfaceLine.Count()); + CollectionAssert.AreEqual(new[] + { + new Point2D(0.5, top), + new Point2D(1, 2.0), + new Point2D(2, 2.0), + new Point2D(2, bottom), + new Point2D(0, bottom), + new Point2D(0, top) + }, areas.LayersUnderSurfaceLine.ElementAt(0).OuterRing); + } + + [Test] + public void Create_SurfaceLineZigZagsThroughSoilLayer_ReturnsSoilLayerPointsSplitInMultipleAreas() + { + // Setup + var surfaceLine = new MacroStabilityInwardsSurfaceLine(); + surfaceLine.SetGeometry(new[] + { + new Point3D(0, 0, 4.0), + new Point3D(4, 0, 0.0), + new Point3D(8, 0, 4.0) + }); + const int bottom = 1; + const int top = 3; + var soilLayer = new MacroStabilityInwardsSoilLayer1D(top); + var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", bottom, new[] + { + soilLayer + }, SoilProfileType.SoilProfile1D, 0); + + // Call + SoilProfileUnderSurfaceLine areas = SoilProfileUnderSurfaceLineFactory.Create(soilProfile, surfaceLine); + + // Assert + Assert.AreEqual(2, areas.LayersUnderSurfaceLine.Count()); + CollectionAssert.AreEqual(new[] + { + new Point2D(1, top), + new Point2D(3, bottom), + new Point2D(0, bottom), + new Point2D(0, top) + }, areas.LayersUnderSurfaceLine.ElementAt(0).OuterRing); + CollectionAssert.AreEqual(new[] + { + new Point2D(5, bottom), + new Point2D(7, top), + new Point2D(8, top), + new Point2D(8, bottom) + }, areas.LayersUnderSurfaceLine.ElementAt(1).OuterRing); + } + + [Test] + public void Create_SoilProfile2DWithOuterRingAndHoles_ReturnsEqualGeometries() + { + // Setup + Ring outerRingA = CreateRing(21); + Ring outerRingB = CreateRing(12); + var holesA = new[] + { + CreateRing(4), + CreateRing(7) + }; + var holesB = new[] + { + CreateRing(4), + CreateRing(7), + CreateRing(2) + }; + IEnumerable layers = new[] + { + new MacroStabilityInwardsSoilLayer2D(outerRingA, holesA), + new MacroStabilityInwardsSoilLayer2D(outerRingB, holesB) + }; + var profile = new MacroStabilityInwardsSoilProfile2D("name", layers, SoilProfileType.SoilProfile2D, 0); + + // Call + SoilProfileUnderSurfaceLine profileUnderSurfaceLine = SoilProfileUnderSurfaceLineFactory.Create(profile); + + // Assert + Assert.AreEqual(2, profileUnderSurfaceLine.LayersUnderSurfaceLine.Count()); + CollectionAssert.AreEqual(new [] { outerRingA.Points, outerRingB.Points }, profileUnderSurfaceLine.LayersUnderSurfaceLine.Select(layer => layer.OuterRing)); + CollectionAssert.AreEqual(new [] { holesA.Select(h => h.Points), holesB.Select(h => h.Points) }, profileUnderSurfaceLine.LayersUnderSurfaceLine.Select(layer => layer.Holes)); + } + + private static Ring CreateRing(int seed) + { + var random = new Random(seed); + int x1 = random.Next(); + int y1 = random.Next(); + int x2 = x1; + int y2 = y1 + random.Next(); + int x3 = x2 + random.Next(); + int y3 = y2; + double x4 = x1 + (x3 - x1) * random.NextDouble(); + int y4 = y1; + + return new Ring(new[] + { + new Point2D(x1, y1), + new Point2D(x2, y2), + new Point2D(x3, y3), + new Point2D(x4, y4) + }); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/StochasticSoilModelTest.cs =================================================================== diff -u -rd47809e3a8fadff2be5b10056b79b16dc27eeca2 -r564a695798dd77c0b90bba14c902c6caefb7786f --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/StochasticSoilModelTest.cs (.../StochasticSoilModelTest.cs) (revision d47809e3a8fadff2be5b10056b79b16dc27eeca2) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/StochasticSoilModelTest.cs (.../StochasticSoilModelTest.cs) (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -21,10 +21,13 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; using Core.Common.Base; using Core.Common.Base.Geometry; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.MacroStabilityInwards.Data; using Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil; using Ringtoets.MacroStabilityInwards.Primitives; @@ -140,7 +143,7 @@ StochasticSoilModel otherModel = CreateEmptyModel(); var expectedAddedProfile = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 3) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile() + SoilProfile = new TestSoilProfile() }; otherModel.StochasticSoilProfiles.Add(expectedAddedProfile); @@ -166,14 +169,14 @@ const string profileName = "A"; var expectedUpdatedProfile = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 3) { - SoilProfile = new MacroStabilityInwardsSoilProfile1D(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile1D, -5) + SoilProfile = new MacroStabilityInwardsSoilProfile1D(profileName, -2, CreateLayers1D(), SoilProfileType.SoilProfile1D, -5) }; StochasticSoilModel model = CreateEmptyModel(); model.StochasticSoilProfiles.Add(expectedUpdatedProfile); StochasticSoilModel otherModel = CreateEmptyModel(); otherModel.StochasticSoilProfiles.Add(new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 3) { - SoilProfile = new MacroStabilityInwardsSoilProfile1D(profileName, -1, CreateLayers(), SoilProfileType.SoilProfile1D, -5) + SoilProfile = new MacroStabilityInwardsSoilProfile1D(profileName, -1, CreateLayers1D(), SoilProfileType.SoilProfile1D, -5) }); // Call @@ -196,7 +199,7 @@ { // Setup const string profileName = "A"; - var soilProfile = new MacroStabilityInwardsSoilProfile1D(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile1D, -5); + var soilProfile = new MacroStabilityInwardsSoilProfile1D(profileName, -2, CreateLayers1D(), SoilProfileType.SoilProfile1D, -5); var expectedUpdatedProfile = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 3) { SoilProfile = soilProfile @@ -227,7 +230,7 @@ { // Setup const string profileName = "A"; - var soilProfile = new MacroStabilityInwardsSoilProfile1D(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile1D, -5); + var soilProfile = new MacroStabilityInwardsSoilProfile1D(profileName, -2, CreateLayers1D(), SoilProfileType.SoilProfile1D, -5); var expectedRemovedProfile = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 3) { SoilProfile = soilProfile @@ -254,14 +257,14 @@ { // Setup const string profileName = "A"; - var soilProfile = new MacroStabilityInwardsSoilProfile1D(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile1D, -5); + var soilProfile = new MacroStabilityInwardsSoilProfile1D(profileName, -2, CreateLayers1D(), SoilProfileType.SoilProfile1D, -5); var expectedRemovedProfile = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 3) { SoilProfile = soilProfile }; var newProfile = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile2D, 3) { - SoilProfile = new MacroStabilityInwardsSoilProfile1D(profileName, -2, CreateLayers(), SoilProfileType.SoilProfile2D, -5) + SoilProfile = new MacroStabilityInwardsSoilProfile2D(profileName, CreateLayers2D(), SoilProfileType.SoilProfile2D, -5) }; StochasticSoilModel model = CreateEmptyModel(); model.StochasticSoilProfiles.Add(expectedRemovedProfile); @@ -293,11 +296,11 @@ var stochasticProfileA = new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, -11) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile(equalProfileName) + SoilProfile = CreateMacroStabilityInwardsSoilProfile1D(equalProfileName) }; var stochasticProfileB = new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, -52) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile("nameB") + SoilProfile = CreateMacroStabilityInwardsSoilProfile1D("nameB") }; model.StochasticSoilProfiles.Add(stochasticProfileA); model.StochasticSoilProfiles.Add(stochasticProfileB); @@ -319,7 +322,7 @@ }; var otherStochasticProfileB = new StochasticSoilProfile(0.3, SoilProfileType.SoilProfile1D, -2) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile("other profile name") + SoilProfile = CreateMacroStabilityInwardsSoilProfile1D("other profile name") }; otherModel.StochasticSoilProfiles.Add(otherStochasticProfileA); otherModel.StochasticSoilProfiles.Add(otherStochasticProfileB); @@ -351,20 +354,31 @@ }, difference.AddedProfiles); } + private static ISoilProfile CreateMacroStabilityInwardsSoilProfile1D(string name) + { + return new MacroStabilityInwardsSoilProfile1D(name, 0.0, new Collection + { + new MacroStabilityInwardsSoilLayer1D(0.0) + { + IsAquifer = true + } + }, SoilProfileType.SoilProfile1D, 0); + } + [Test] public void Update_ModelsWithAddedProfilesWithSameNames_ThrowsInvalidOperationException() { // Setup var addedProfile = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 3) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile() + SoilProfile = new TestMacroStabilityInwardsSoilProfile1D() }; StochasticSoilModel otherModel = CreateEmptyModel(); otherModel.StochasticSoilProfiles.Add(addedProfile); var existingProfile = new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, 3) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile() + SoilProfile = new TestMacroStabilityInwardsSoilProfile1D() }; StochasticSoilModel model = CreateEmptyModel(); model.StochasticSoilProfiles.Add(existingProfile); @@ -400,16 +414,34 @@ Assert.AreEqual(name, stochasticSoilModel.ToString()); } - private IEnumerable CreateLayers() + private class TestSoilProfile : ISoilProfile { + public string Name { get; } = ""; + } + + private static IEnumerable CreateLayers1D() + { return new[] { new MacroStabilityInwardsSoilLayer1D(2) }; } - private StochasticSoilModel CreateEmptyModel() + private static IEnumerable CreateLayers2D() { + var outerRing = new Ring(new[] + { + new Point2D(3, 2), + new Point2D(3, 5) + }); + return new[] + { + new MacroStabilityInwardsSoilLayer2D(outerRing, Enumerable.Empty().ToArray()) + }; + } + + private static StochasticSoilModel CreateEmptyModel() + { var model = new StochasticSoilModel("name"); return model; } Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/StochasticSoilProfileTest.cs =================================================================== diff -u -r4ab7b653ebbf2ff9962d1e6a326029d07c225548 -r564a695798dd77c0b90bba14c902c6caefb7786f --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/StochasticSoilProfileTest.cs (.../StochasticSoilProfileTest.cs) (revision 4ab7b653ebbf2ff9962d1e6a326029d07c225548) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/StochasticSoilProfileTest.cs (.../StochasticSoilProfileTest.cs) (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -20,12 +20,9 @@ // All rights reserved. using System; -using System.Drawing; using Core.Common.Base; using Core.Common.TestUtil; using NUnit.Framework; -using Rhino.Mocks; -using Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil; using Ringtoets.MacroStabilityInwards.Primitives; namespace Ringtoets.MacroStabilityInwards.Data.Test @@ -139,7 +136,7 @@ { // Setup const double probability = 1.0; - var profile = new TestMacroStabilityInwardsSoilProfile(); + var profile = new TestSoilProfile(); var stochasticProfile = new StochasticSoilProfile(probability, SoilProfileType.SoilProfile1D, 0) { SoilProfile = profile @@ -206,39 +203,27 @@ [Test] [TestCase("")] [TestCase("some name")] - public void ToString_WithName_ReturnsName(string name) + public void ToString_WithProfile_ReturnsToStringResultOfProfile(string name) { // Setup + var profile = new TestSoilProfile(); var stochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) { - SoilProfile = new MacroStabilityInwardsSoilProfile1D(name, 0.0, new[] - { - new MacroStabilityInwardsSoilLayer1D(0.0) - }, SoilProfileType.SoilProfile1D, 0) + SoilProfile = profile }; // Call string text = stochasticSoilProfile.ToString(); // Assert - Assert.AreEqual(name, text); + Assert.AreEqual(profile.ToString(), text); } private static TestCaseData[] StochasticProfileUnequalCombinations() { - const string profileName = "newProfile"; - var stochasticSoilProfile = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new TestMacroStabilityInwardsSoilProfile(profileName, SoilProfileType.SoilProfile1D) - }; - var otherStochasticSoilProfileA = new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, 0) - { - SoilProfile = new TestMacroStabilityInwardsSoilProfile(profileName, SoilProfileType.SoilProfile1D) - }; - var otherStochasticSoilProfileB = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile2D, 0) - { - SoilProfile = new TestMacroStabilityInwardsSoilProfile(profileName, SoilProfileType.SoilProfile2D) - }; + var stochasticSoilProfile = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 0); + var otherStochasticSoilProfileA = new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, 0); + var otherStochasticSoilProfileB = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile2D, 0); return new[] { @@ -287,22 +272,37 @@ }; } - private static MacroStabilityInwardsSoilProfile1D CreateRandomProfile(Random random) + private static TestSoilProfile CreateRandomProfile(Random random) { - return new MacroStabilityInwardsSoilProfile1D(GetRandomName(random), -1.0 - random.NextDouble(), new[] - { - new MacroStabilityInwardsSoilLayer1D(random.NextDouble()) - { - MaterialName = GetRandomName(random), - Color = Color.FromKnownColor(random.NextEnumValue()), - IsAquifer = random.NextBoolean() - } - }, random.NextEnumValue(), random.Next()); + return new TestSoilProfile(GetRandomName(random)); } private static string GetRandomName(Random random) { return new string('x', random.Next(0, 40)); } + + private class TestSoilProfile : ISoilProfile + { + public TestSoilProfile() {} + + public TestSoilProfile(string name) + { + Name = name; + } + + public string Name { get; } + + public override int GetHashCode() + { + return 0; + } + + public override bool Equals(object obj) + { + var other = obj as ISoilProfile; + return other != null && Name.Equals(other.Name); + } + } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/TestStochasticSoilModel.cs =================================================================== diff -u -r07783a47e1cfb0bd793eaba29c7567cb17e0b367 -r564a695798dd77c0b90bba14c902c6caefb7786f --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/TestStochasticSoilModel.cs (.../TestStochasticSoilModel.cs) (revision 07783a47e1cfb0bd793eaba29c7567cb17e0b367) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/TestStochasticSoilModel.cs (.../TestStochasticSoilModel.cs) (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -39,11 +39,11 @@ { new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, 0) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile("A") + SoilProfile = new TestMacroStabilityInwardsSoilProfile1D("A") }, new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, 0) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile("B") + SoilProfile = new TestMacroStabilityInwardsSoilProfile1D("B") } }); } Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsInputContextPropertiesTest.cs =================================================================== diff -u -rcd90ebf744fb74f0d4b0dd6ee06f9c39b5faf213 -r564a695798dd77c0b90bba14c902c6caefb7786f --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsInputContextPropertiesTest.cs (.../MacroStabilityInwardsInputContextPropertiesTest.cs) (revision cd90ebf744fb74f0d4b0dd6ee06f9c39b5faf213) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsInputContextPropertiesTest.cs (.../MacroStabilityInwardsInputContextPropertiesTest.cs) (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -710,7 +710,7 @@ inputParameters.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile() + SoilProfile = new TestMacroStabilityInwardsSoilProfile1D() }; // Call @@ -734,7 +734,7 @@ MacroStabilityInwardsSurfaceLine testSurfaceLine = ValidSurfaceLine(0, 2); var stochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile() + SoilProfile = new TestMacroStabilityInwardsSoilProfile1D() }; var stochasticSoilModel = new StochasticSoilModel("StochasticSoilModelName"); stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfile); @@ -779,7 +779,7 @@ var soilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile() + SoilProfile = new TestMacroStabilityInwardsSoilProfile1D() }; var stochasticSoilModel = new StochasticSoilModel("StochasticSoilModelName"); stochasticSoilModel.StochasticSoilProfiles.Add(soilProfile); @@ -834,14 +834,14 @@ MacroStabilityInwardsSurfaceLine testSurfaceLine = ValidSurfaceLine(0, 2); var stochasticSoilProfile1 = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile() + SoilProfile = new TestMacroStabilityInwardsSoilProfile1D() }; var stochasticSoilModel1 = new StochasticSoilModel("StochasticSoilModel1Name"); stochasticSoilModel1.StochasticSoilProfiles.Add(stochasticSoilProfile1); var stochasticSoilProfile2 = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile() + SoilProfile = new TestMacroStabilityInwardsSoilProfile1D() }; var stochasticSoilModel2 = new StochasticSoilModel("StochasticSoilModel2Name"); stochasticSoilModel1.StochasticSoilProfiles.Add(stochasticSoilProfile2); @@ -1487,7 +1487,7 @@ var stochasticSoilModel = new StochasticSoilModel("StochasticSoilModelName"); stochasticSoilModel.StochasticSoilProfiles.Add(new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 1234) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile() + SoilProfile = new TestMacroStabilityInwardsSoilProfile1D() }); stochasticSoilModel.Geometry.Add(new Point2D(xMin, 1.0)); stochasticSoilModel.Geometry.Add(new Point2D(xMax, 0.0)); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/UITypeEditors/MacroStabilityInwardsInputContextStochasticSoilModelSelectionEditorTest.cs =================================================================== diff -u -rcd90ebf744fb74f0d4b0dd6ee06f9c39b5faf213 -r564a695798dd77c0b90bba14c902c6caefb7786f --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/UITypeEditors/MacroStabilityInwardsInputContextStochasticSoilModelSelectionEditorTest.cs (.../MacroStabilityInwardsInputContextStochasticSoilModelSelectionEditorTest.cs) (revision cd90ebf744fb74f0d4b0dd6ee06f9c39b5faf213) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/UITypeEditors/MacroStabilityInwardsInputContextStochasticSoilModelSelectionEditorTest.cs (.../MacroStabilityInwardsInputContextStochasticSoilModelSelectionEditorTest.cs) (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -104,7 +104,7 @@ var stochasticSoilProfile = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 0) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile() + SoilProfile = new TestMacroStabilityInwardsSoilProfile1D() }; var stochasticSoilModel = new StochasticSoilModel("Model") { Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/UITypeEditors/MacroStabilityInwardsInputContextStochasticSoilProfileSelectionEditorTest.cs =================================================================== diff -u -rcd90ebf744fb74f0d4b0dd6ee06f9c39b5faf213 -r564a695798dd77c0b90bba14c902c6caefb7786f --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/UITypeEditors/MacroStabilityInwardsInputContextStochasticSoilProfileSelectionEditorTest.cs (.../MacroStabilityInwardsInputContextStochasticSoilProfileSelectionEditorTest.cs) (revision cd90ebf744fb74f0d4b0dd6ee06f9c39b5faf213) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/UITypeEditors/MacroStabilityInwardsInputContextStochasticSoilProfileSelectionEditorTest.cs (.../MacroStabilityInwardsInputContextStochasticSoilProfileSelectionEditorTest.cs) (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -60,7 +60,7 @@ { StochasticSoilProfile = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 2) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile() + SoilProfile = new TestMacroStabilityInwardsSoilProfile1D() } }; var inputContext = new MacroStabilityInwardsInputContext(input, @@ -107,7 +107,7 @@ var stochasticSoilProfile = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 0) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile() + SoilProfile = new TestMacroStabilityInwardsSoilProfile1D() }; var stochasticSoilModel = new StochasticSoilModel("Model") { Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Test/TestMacroStabilityInwardsSoilProfileTest.cs =================================================================== diff -u -r650fc7b43cb6729baee51d079f0377df8d7a3de9 -r564a695798dd77c0b90bba14c902c6caefb7786f --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Test/TestMacroStabilityInwardsSoilProfileTest.cs (.../TestMacroStabilityInwardsSoilProfileTest.cs) (revision 650fc7b43cb6729baee51d079f0377df8d7a3de9) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Test/TestMacroStabilityInwardsSoilProfileTest.cs (.../TestMacroStabilityInwardsSoilProfileTest.cs) (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -34,7 +34,7 @@ public void DefaultConstructor_ExpectedPropertiesSet() { // Call - var profile = new TestMacroStabilityInwardsSoilProfile(); + var profile = new TestMacroStabilityInwardsSoilProfile1D(); // Assert Assert.IsEmpty(profile.Name); @@ -57,7 +57,7 @@ const string name = "some name"; // Call - var profile = new TestMacroStabilityInwardsSoilProfile(name); + var profile = new TestMacroStabilityInwardsSoilProfile1D(name); // Assert Assert.AreEqual(name, profile.Name); @@ -81,7 +81,7 @@ var soilProfileType = new Random(6543).NextEnumValue(); // Call - var profile = new TestMacroStabilityInwardsSoilProfile(name, soilProfileType); + var profile = new TestMacroStabilityInwardsSoilProfile1D(name, soilProfileType); // Assert Assert.AreEqual(name, profile.Name); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.csproj =================================================================== diff -u -r650fc7b43cb6729baee51d079f0377df8d7a3de9 -r564a695798dd77c0b90bba14c902c6caefb7786f --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.csproj) (revision 650fc7b43cb6729baee51d079f0377df8d7a3de9) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.csproj) (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -52,7 +52,7 @@ - + Fisheye: Tag 564a695798dd77c0b90bba14c902c6caefb7786f refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/TestMacroStabilityInwardsSoilProfile.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/TestMacroStabilityInwardsSoilProfile1D.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/TestMacroStabilityInwardsSoilProfile1D.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/TestMacroStabilityInwardsSoilProfile1D.cs (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -0,0 +1,81 @@ +// 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.Collections.ObjectModel; +using Ringtoets.MacroStabilityInwards.Primitives; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil +{ + /// + /// A configured to be usable immediately for testing + /// purposes. + /// + public class TestMacroStabilityInwardsSoilProfile1D : MacroStabilityInwardsSoilProfile1D + { + /// + /// Creates a new instance of , which is a + /// which has: + /// + /// set to + /// set to 0.0 + /// set to a collection with a single + /// with set to 0.0. + /// set to . + /// + /// + public TestMacroStabilityInwardsSoilProfile1D() : this("") {} + + /// + /// Creates a new instance of , which is a + /// which has: + /// + /// set to + /// set to 0.0 + /// set to a collection with a single + /// with set to 0.0. + /// set to . + /// + /// + /// The name for the profile. + public TestMacroStabilityInwardsSoilProfile1D(string name) : this(name, SoilProfileType.SoilProfile1D) {} + + /// + /// Creates a new instance of , which is a + /// which has: + /// + /// set to + /// set to 0.0 + /// set to a collection with a single + /// with set to 0.0. + /// set to . + /// + /// + /// The name for the profile. + /// The type of the profile. + public TestMacroStabilityInwardsSoilProfile1D(string name, SoilProfileType soilProfileType) : base(name, 0.0, new Collection + { + new MacroStabilityInwardsSoilLayer1D(0.0) + { + IsAquifer = true + } + }, soilProfileType, 0) {} + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs =================================================================== diff -u -rd47809e3a8fadff2be5b10056b79b16dc27eeca2 -r564a695798dd77c0b90bba14c902c6caefb7786f --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs (.../StochasticSoilModelUpdateDataStrategyTest.cs) (revision d47809e3a8fadff2be5b10056b79b16dc27eeca2) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/FileImporter/StochasticSoilModelUpdateDataStrategyTest.cs (.../StochasticSoilModelUpdateDataStrategyTest.cs) (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -314,7 +314,7 @@ { // Setup const string modelsName = "same model"; - var existingModel = new TestStochasticSoilModel(modelsName); + StochasticSoilModel existingModel = CreateStochasticSoilModel(modelsName); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); StochasticSoilModelCollection targetCollection = failureMechanism.StochasticSoilModels; @@ -323,7 +323,7 @@ existingModel }, sourceFilePath); - StochasticSoilModel readModel = new TestStochasticSoilModel(modelsName); + StochasticSoilModel readModel = CreateStochasticSoilModel(modelsName); StochasticSoilProfile changedProfile = CloneAndSlightlyModify(readModel.StochasticSoilProfiles.ElementAt(0)); readModel.StochasticSoilProfiles[0] = changedProfile; @@ -467,6 +467,40 @@ }, affectedObjects); } + private static StochasticSoilModel CreateStochasticSoilModel(string modelsName) + { + var model = new StochasticSoilModel(modelsName); + + model.StochasticSoilProfiles.AddRange(new[] + { + new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, 0) + { + SoilProfile = new MacroStabilityInwardsSoilProfile1D( + "A", + 0.0, + new[] + { + new MacroStabilityInwardsSoilLayer1D(0.0) + }, + SoilProfileType.SoilProfile1D, + 0) + }, + new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, 0) + { + SoilProfile = new MacroStabilityInwardsSoilProfile1D( + "B", + 0.0, + new[] + { + new MacroStabilityInwardsSoilLayer1D(0.0) + }, + SoilProfileType.SoilProfile1D, + 0) + } + }); + return model; + } + /// /// Creates a simple model with names for the model and profiles in the model set as specified. /// @@ -481,7 +515,7 @@ model.StochasticSoilProfiles.Add( new StochasticSoilProfile(1.0 / profileNames.Length, SoilProfileType.SoilProfile1D, -1) { - SoilProfile = new TestMacroStabilityInwardsSoilProfile(profileName) + SoilProfile = new TestMacroStabilityInwardsSoilProfile1D(profileName) }); } return model; Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSoilLayer2DTest.cs =================================================================== diff -u -rec27d9f02dc27c2829ed45788fae7d5923d63d3d -r564a695798dd77c0b90bba14c902c6caefb7786f --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSoilLayer2DTest.cs (.../MacroStabilityInwardsSoilLayer2DTest.cs) (revision ec27d9f02dc27c2829ed45788fae7d5923d63d3d) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSoilLayer2DTest.cs (.../MacroStabilityInwardsSoilLayer2DTest.cs) (revision 564a695798dd77c0b90bba14c902c6caefb7786f) @@ -32,14 +32,53 @@ public class MacroStabilityInwardsSoilLayer2DTest { [Test] - public void DefaultConstructor_ReturnsNewInstance() + public void Constructor_WithoutOuterRing_ArgumentNullException() { // Setup + var holes = new[] + { + new Ring(new[] + { + new Point2D(0, 2), + new Point2D(2, 2) + }) + }; + + // Call + TestDelegate test= () => new MacroStabilityInwardsSoilLayer2D(null, holes); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("outerRing", exception.ParamName); + } + + [Test] + public void Constructor_WithoutHoles_ReturnsNewInstance() + { + // Setup var outerRing = new Ring(new[] { new Point2D(0, 2), new Point2D(2, 2) }); + + // Call + TestDelegate test = () => new MacroStabilityInwardsSoilLayer2D(outerRing, null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("holes", exception.ParamName); + } + + [Test] + public void Constructor_WithOuterRingAndHoles_ReturnsNewInstance() + { + // Setup + var outerRing = new Ring(new[] + { + new Point2D(0, 2), + new Point2D(2, 2) + }); var holes = new[] { new Ring(new[] @@ -56,7 +95,7 @@ Assert.NotNull(layer); Assert.AreSame(outerRing, layer.OuterRing); Assert.AreNotSame(holes, layer.Holes); - TestHelper.AssertCollectionAreEqual(holes, layer.Holes, new ReferenceEqualityComparer()); + TestHelper.AssertCollectionsAreEqual(holes, layer.Holes, new ReferenceEqualityComparer()); Assert.NotNull(layer.Properties); }