Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/MacroStabilityInwardsSoilCreator.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/MacroStabilityInwardsSoilCreator.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/MacroStabilityInwardsSoilCreator.cs (revision 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d) @@ -0,0 +1,87 @@ +// 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.Linq; +using Deltares.WTIStability.Data.Geo; +using Ringtoets.MacroStabilityInwards.Primitives; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Creators +{ + /// + /// Creates instances which are required by the . + /// + internal static class MacroStabilityInwardsSoilCreator + { + /// + /// Creates a based on information contained in the profiled , + /// which can be used in the . + /// + /// The from + /// which to take the information. + /// A new with information taken from the . + /// Thrown when is null. + /// Thrown when + /// has an type that can't be converted to . + public static Soil[] Create(MacroStabilityInwardsSoilProfileUnderSurfaceLine profile) + { + if (profile == null) + { + throw new ArgumentNullException(nameof(profile)); + } + + return profile.LayersUnderSurfaceLine.Select(l => + { + MacroStabilityInwardsSoilLayerPropertiesUnderSurfaceLine properties = l.Properties; + + return new Soil(properties.MaterialName) + { + UsePop = properties.UsePop, + ShearStrengthModel = ConvertShearStrengthModel(properties.ShearStrengthModel), + AbovePhreaticLevel = properties.AbovePhreaticLevelDesignVariable, + BelowPhreaticLevel = properties.BelowPhreaticLevelDesignVariable, + Cohesion = properties.CohesionDesignVariable, + FrictionAngle = properties.FrictionAngleDesignVariable, + RatioCuPc = properties.ShearStrengthRatioDesignVariable, + StrengthIncreaseExponent = properties.StrengthIncreaseExponentDesignVariable, + PoP = properties.PopDesignVariable + }; + }).ToArray(); + } + + private static ShearStrengthModel ConvertShearStrengthModel(MacroStabilityInwardsShearStrengthModel shearStrengthModel) + { + switch (shearStrengthModel) + { + case MacroStabilityInwardsShearStrengthModel.None: + return ShearStrengthModel.None; + case MacroStabilityInwardsShearStrengthModel.SuCalculated: + return ShearStrengthModel.CuCalculated; + case MacroStabilityInwardsShearStrengthModel.CPhi: + return ShearStrengthModel.CPhi; + case MacroStabilityInwardsShearStrengthModel.CPhiOrSuCalculated: + return ShearStrengthModel.CPhiOrCuCalculated; + default: + throw new NotSupportedException(); + } + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/MacroStabilityInwardsSoilModelCreator.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/MacroStabilityInwardsSoilModelCreator.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/MacroStabilityInwardsSoilModelCreator.cs (revision 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d) @@ -0,0 +1,52 @@ +// 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 Deltares.WTIStability.Data.Geo; +using Deltares.WTIStability.Data.Standard; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Creators +{ + /// + /// Creates instances which are required by the . + /// + internal static class MacroStabilityInwardsSoilModelCreator + { + /// + /// Creates a with the given + /// which can be used in the . + /// + /// The array of to use in the . + /// A new with the . + /// Thrown when is null. + public static SoilModel Create(Soil[] soils) + { + if (soils == null) + { + throw new ArgumentNullException(nameof(soils)); + } + + var soilModel = new SoilModel(); + soilModel.Soils.AddRange(soils); + return soilModel; + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/MacroStabilityInwardsCalculator.cs =================================================================== diff -u -rf7b1b88b405ba24f2baeaec0cfe3697c64755d70 -r0ecc2eb11789b230484e87fd6109bc61dc8d9b2d --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/MacroStabilityInwardsCalculator.cs (.../MacroStabilityInwardsCalculator.cs) (revision f7b1b88b405ba24f2baeaec0cfe3697c64755d70) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/MacroStabilityInwardsCalculator.cs (.../MacroStabilityInwardsCalculator.cs) (revision 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d) @@ -24,6 +24,7 @@ using System.Linq; using Deltares.WTIStability.Data.Geo; using Deltares.WTIStability.Data.Standard; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Creators; using Ringtoets.MacroStabilityInwards.KernelWrapper.SubCalculator; using Ringtoets.MacroStabilityInwards.Primitives; Fisheye: Tag 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/MacroStabilityInwardsSoilCreator.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/MacroStabilityInwardsSoilModelCreator.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj =================================================================== diff -u -rf7b1b88b405ba24f2baeaec0cfe3697c64755d70 -r0ecc2eb11789b230484e87fd6109bc61dc8d9b2d --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.csproj) (revision f7b1b88b405ba24f2baeaec0cfe3697c64755d70) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.csproj) (revision 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d) @@ -46,8 +46,8 @@ - - + + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/MacroStabilityInwardsSoilCreatorTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/MacroStabilityInwardsSoilCreatorTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/MacroStabilityInwardsSoilCreatorTest.cs (revision 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d) @@ -0,0 +1,162 @@ +// 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.Linq; +using Core.Common.TestUtil; +using Deltares.WTIStability.Data.Geo; +using NUnit.Framework; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Creators; +using Ringtoets.MacroStabilityInwards.Primitives; +using Point2D = Core.Common.Base.Geometry.Point2D; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Test.Creators +{ + [TestFixture] + public class MacroStabilityInwardsSoilCreatorTest + { + [Test] + public void Create_ProfileNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityInwardsSoilCreator.Create(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("profile", exception.ParamName); + } + + [Test] + public void Create_ProfileWithLayers_ReturnsProfileWithLayers() + { + // Setup + var profile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(new[] + { + new MacroStabilityInwardsSoilLayerUnderSurfaceLine(new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + }, new TestMacroStabilityInwardsSoilLayerPropertiesUnderSurfaceLine( + new MacroStabilityInwardsSoilLayerPropertiesUnderSurfaceLine.ConstructionProperties + { + UsePop = true, + ShearStrengthModel = MacroStabilityInwardsShearStrengthModel.CPhi, + MaterialName = "Sand", + })), + new MacroStabilityInwardsSoilLayerUnderSurfaceLine(new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + }, new TestMacroStabilityInwardsSoilLayerPropertiesUnderSurfaceLine( + new MacroStabilityInwardsSoilLayerPropertiesUnderSurfaceLine.ConstructionProperties + { + UsePop = false, + ShearStrengthModel = MacroStabilityInwardsShearStrengthModel.None, + MaterialName = "Mud" + })), + new MacroStabilityInwardsSoilLayerUnderSurfaceLine(new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + }, new TestMacroStabilityInwardsSoilLayerPropertiesUnderSurfaceLine( + new MacroStabilityInwardsSoilLayerPropertiesUnderSurfaceLine.ConstructionProperties + { + UsePop = true, + ShearStrengthModel = MacroStabilityInwardsShearStrengthModel.CPhiOrSuCalculated, + MaterialName = "Clay" + })), + new MacroStabilityInwardsSoilLayerUnderSurfaceLine(new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + }, new TestMacroStabilityInwardsSoilLayerPropertiesUnderSurfaceLine( + new MacroStabilityInwardsSoilLayerPropertiesUnderSurfaceLine.ConstructionProperties + { + UsePop = true, + ShearStrengthModel = MacroStabilityInwardsShearStrengthModel.SuCalculated, + MaterialName = "Grass" + })) + }); + + // Call + Soil[] soils = MacroStabilityInwardsSoilCreator.Create(profile); + + // Assert + Assert.AreEqual(4, soils.Length); + + CollectionAssert.AreEqual(profile.LayersUnderSurfaceLine.Select(l => l.Properties.UsePop), soils.Select(s => s.UsePop)); + CollectionAssert.AreEqual(profile.LayersUnderSurfaceLine.Select(l => l.Properties.MaterialName), soils.Select(s => s.Name)); + CollectionAssert.AreEqual(new[] + { + ShearStrengthModel.CPhi, + ShearStrengthModel.None, + ShearStrengthModel.CPhiOrCuCalculated, + ShearStrengthModel.CuCalculated + }, soils.Select(s => s.ShearStrengthModel)); + CollectionAssert.AreEqual(profile.LayersUnderSurfaceLine.Select(l => l.Properties.AbovePhreaticLevelDesignVariable.Value), soils.Select(s => s.AbovePhreaticLevel)); + CollectionAssert.AreEqual(profile.LayersUnderSurfaceLine.Select(l => l.Properties.BelowPhreaticLevelDesignVariable.Value), soils.Select(s => s.BelowPhreaticLevel)); + CollectionAssert.AreEqual(profile.LayersUnderSurfaceLine.Select(l => l.Properties.CohesionDesignVariable.Value), soils.Select(s => s.Cohesion)); + CollectionAssert.AreEqual(profile.LayersUnderSurfaceLine.Select(l => l.Properties.FrictionAngleDesignVariable.Value), soils.Select(s => s.FrictionAngle)); + CollectionAssert.AreEqual(profile.LayersUnderSurfaceLine.Select(l => l.Properties.ShearStrengthRatioDesignVariable.Value), soils.Select(s => s.RatioCuPc)); + CollectionAssert.AreEqual(profile.LayersUnderSurfaceLine.Select(l => l.Properties.StrengthIncreaseExponentDesignVariable.Value), soils.Select(s => s.StrengthIncreaseExponent)); + CollectionAssert.AreEqual(profile.LayersUnderSurfaceLine.Select(l => l.Properties.PopDesignVariable.Value), soils.Select(s => s.PoP)); + } + + [Test] + public void Create_InvalidShearStrengthModel_ThrowNotSupportedException() + { + // Setup + var profile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(new[] + { + new MacroStabilityInwardsSoilLayerUnderSurfaceLine(new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + }, new MacroStabilityInwardsSoilLayerPropertiesUnderSurfaceLine(new MacroStabilityInwardsSoilLayerPropertiesUnderSurfaceLine.ConstructionProperties + { + ShearStrengthModel = (MacroStabilityInwardsShearStrengthModel) 99 + })) + }); + + // Call + TestDelegate test = () => MacroStabilityInwardsSoilCreator.Create(profile); + + // Assert + Assert.Throws(test); + } + + private class TestMacroStabilityInwardsSoilLayerPropertiesUnderSurfaceLine : MacroStabilityInwardsSoilLayerPropertiesUnderSurfaceLine + { + public TestMacroStabilityInwardsSoilLayerPropertiesUnderSurfaceLine(ConstructionProperties properties) + : base(properties) + { + var random = new Random(21); + AbovePhreaticLevelDesignVariable = random.NextRoundedDouble(); + BelowPhreaticLevelDesignVariable = random.NextRoundedDouble(); + CohesionDesignVariable = random.NextRoundedDouble(); + FrictionAngleDesignVariable = random.NextRoundedDouble(); + ShearStrengthRatioDesignVariable = random.NextRoundedDouble(); + StrengthIncreaseExponentDesignVariable = random.NextRoundedDouble(); + PopDesignVariable = random.NextRoundedDouble(); + } + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/MacroStabilityInwardsSoilModelCreatorTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/MacroStabilityInwardsSoilModelCreatorTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/MacroStabilityInwardsSoilModelCreatorTest.cs (revision 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d) @@ -0,0 +1,60 @@ +// 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 Deltares.WTIStability.Data.Geo; +using NUnit.Framework; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Creators; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Test.Creators +{ + [TestFixture] + public class MacroStabilityInwardsSoilModelCreatorTest + { + [Test] + public void Create_SoilsNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityInwardsSoilModelCreator.Create(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("soils", exception.ParamName); + } + + [Test] + public void Create_WithSoils_ReturnSoilModelWithSoils() + { + // Setup + var soils = new[] + { + new Soil("soil 1"), + new Soil("soil 2") + }; + + // Call + SoilModel soilModel = MacroStabilityInwardsSoilModelCreator.Create(soils); + + // Assert + CollectionAssert.AreEqual(soils, soilModel.Soils); + } + } +} \ No newline at end of file Fisheye: Tag 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/MacroStabilityInwardsSoilCreatorTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/MacroStabilityInwardsSoilModelCreatorTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj =================================================================== diff -u -rf7b1b88b405ba24f2baeaec0cfe3697c64755d70 -r0ecc2eb11789b230484e87fd6109bc61dc8d9b2d --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj) (revision f7b1b88b405ba24f2baeaec0cfe3697c64755d70) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj) (revision 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d) @@ -63,8 +63,8 @@ - - + + Index: Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/Creators/PipingProfileCreator.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/Creators/PipingProfileCreator.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/Creators/PipingProfileCreator.cs (revision 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d) @@ -0,0 +1,58 @@ +// 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 Deltares.WTIPiping; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.KernelWrapper.Creators +{ + /// + /// Creates instances which are required by the . + /// + internal static class PipingProfileCreator + { + /// + /// Creates a based on information contained in the provided , + /// which can then be used in the . + /// + /// The from which to take the information. + /// A new with information taken from the . + public static PipingProfile Create(PipingSoilProfile soilProfile) + { + var profile = new PipingProfile + { + BottomLevel = soilProfile.Bottom + }; + foreach (PipingSoilLayer layer in soilProfile.Layers) + { + var pipingLayer = new PipingLayer + { + TopLevel = layer.Top, + IsAquifer = layer.IsAquifer + }; + + profile.Layers.Add(pipingLayer); + } + + return profile; + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/Creators/PipingProfileCreatorException.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/Creators/PipingProfileCreatorException.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/Creators/PipingProfileCreatorException.cs (revision 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d) @@ -0,0 +1,68 @@ +// 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.Runtime.Serialization; + +namespace Ringtoets.Piping.KernelWrapper.Creators +{ + /// + /// Exception thrown when something went wrong in the + /// + [Serializable] + public class PipingProfileCreatorException : Exception + { + /// + /// Initializes a new instance of the class. + /// + public PipingProfileCreatorException() {} + + /// + /// Initializes a new instance of the class + /// with a specified error message. + /// + /// The message that describes the error. + public PipingProfileCreatorException(string message) + : base(message) {} + + /// + /// Initializes a new instance of the class with + /// a specified error message and a reference to the inner exception that is the cause of this exception. + /// + /// The error message that explains the reason for the exception. + /// The exception that is the cause of the current exception, + /// or null if no inner exception is specified. + public PipingProfileCreatorException(string message, Exception innerException) : base(message, innerException) {} + + /// + /// Initializes a new instance of with + /// serialized data. + /// The that holds the serialized + /// object data about the exception being thrown. + /// The that contains contextual + /// information about the source or destination. + /// The parameter is + /// null. + /// The class name is null or + /// is zero (0). + protected PipingProfileCreatorException(SerializationInfo info, StreamingContext context) : base(info, context) {} + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/Creators/PipingSurfaceLineCreator.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/Creators/PipingSurfaceLineCreator.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/Creators/PipingSurfaceLineCreator.cs (revision 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d) @@ -0,0 +1,112 @@ +// 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.Generic; +using System.Linq; +using Core.Common.Base.Geometry; +using Deltares.WTIPiping; +using PipingSurfaceLine = Ringtoets.Piping.Primitives.PipingSurfaceLine; + +namespace Ringtoets.Piping.KernelWrapper.Creators +{ + /// + /// Creates instances which are required by the . + /// + internal static class PipingSurfaceLineCreator + { + /// + /// Creates a for the kernel + /// given different surface line. + /// + /// The surface line configured in the Ringtoets application. + /// The surface line to be consumed by the kernel. + public static Deltares.WTIPiping.PipingSurfaceLine Create(PipingSurfaceLine line) + { + var surfaceLine = new Deltares.WTIPiping.PipingSurfaceLine + { + Name = line.Name + }; + if (line.Points.Any()) + { + surfaceLine.Points.AddRange(CreatePoints(line)); + } + + return surfaceLine; + } + + private static IEnumerable CreatePoints(PipingSurfaceLine line) + { + Point2D[] projectedPoints = line.LocalGeometry.ToArray(); + var pipingPoints = new List(); + + for (var i = 0; i < line.Points.Length; i++) + { + IEnumerable newPoints = CreatePoint(line, projectedPoints, i); + pipingPoints.AddRange(newPoints); + } + return pipingPoints; + } + + private static IEnumerable CreatePoint(PipingSurfaceLine line, Point2D[] projectedPoints, int index) + { + Point3D surfaceLinePoint = line.Points[index]; + Point2D projectedPoint = projectedPoints[index]; + + IList pipingPoints = new List(); + + if (ReferenceEquals(line.DitchPolderSide, surfaceLinePoint)) + { + pipingPoints.Add(CreatePipingPointOfType(projectedPoint, PipingCharacteristicPointType.DitchPolderSide)); + } + if (ReferenceEquals(line.BottomDitchPolderSide, surfaceLinePoint)) + { + pipingPoints.Add(CreatePipingPointOfType(projectedPoint, PipingCharacteristicPointType.BottomDitchPolderSide)); + } + if (ReferenceEquals(line.BottomDitchDikeSide, surfaceLinePoint)) + { + pipingPoints.Add(CreatePipingPointOfType(projectedPoint, PipingCharacteristicPointType.BottomDitchDikeSide)); + } + if (ReferenceEquals(line.DitchDikeSide, surfaceLinePoint)) + { + pipingPoints.Add(CreatePipingPointOfType(projectedPoint, PipingCharacteristicPointType.DitchDikeSide)); + } + if (ReferenceEquals(line.DikeToeAtPolder, surfaceLinePoint)) + { + pipingPoints.Add(CreatePipingPointOfType(projectedPoint, PipingCharacteristicPointType.DikeToeAtPolder)); + } + if (!pipingPoints.Any()) + { + pipingPoints.Add(CreatePipingPointOfType(projectedPoint, PipingCharacteristicPointType.None)); + } + + return pipingPoints; + } + + private static PipingPoint CreatePipingPointOfType(Point2D projectedPoint, PipingCharacteristicPointType pointType) + { + var pipingPoint = new PipingPoint(projectedPoint.X, 0.0, projectedPoint.Y) + { + Type = pointType + }; + return pipingPoint; + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/PipingCalculator.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r0ecc2eb11789b230484e87fd6109bc61dc8d9b2d --- Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/PipingCalculator.cs (.../PipingCalculator.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/PipingCalculator.cs (.../PipingCalculator.cs) (revision 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d) @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.Linq; using Deltares.WTIPiping; +using Ringtoets.Piping.KernelWrapper.Creators; using Ringtoets.Piping.KernelWrapper.SubCalculator; using EffectiveThicknessCalculator = Ringtoets.Piping.KernelWrapper.SubCalculator.EffectiveThicknessCalculator; using HeaveCalculator = Ringtoets.Piping.KernelWrapper.SubCalculator.HeaveCalculator; Fisheye: Tag 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/PipingProfileCreator.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/PipingProfileCreatorException.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/PipingSurfaceLineCreator.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/Ringtoets.Piping.KernelWrapper.csproj =================================================================== diff -u -rb04ee63f77708d3e30dd18f07dbb8ab31d548edb -r0ecc2eb11789b230484e87fd6109bc61dc8d9b2d --- Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/Ringtoets.Piping.KernelWrapper.csproj (.../Ringtoets.Piping.KernelWrapper.csproj) (revision b04ee63f77708d3e30dd18f07dbb8ab31d548edb) +++ Ringtoets/Piping/src/Ringtoets.Piping.KernelWrapper/Ringtoets.Piping.KernelWrapper.csproj (.../Ringtoets.Piping.KernelWrapper.csproj) (revision 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d) @@ -46,9 +46,9 @@ - - - + + + Index: Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/Creators/PipingProfileCreatorExceptionTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/Creators/PipingProfileCreatorExceptionTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/Creators/PipingProfileCreatorExceptionTest.cs (revision 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d) @@ -0,0 +1,32 @@ +// 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 Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Piping.KernelWrapper.Creators; + +namespace Ringtoets.Piping.KernelWrapper.Test.Creators +{ + [TestFixture] + public class PipingProfileCreatorExceptionTest : + CustomExceptionDesignGuidelinesTestFixture {} +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/Creators/PipingProfileCreatorTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/Creators/PipingProfileCreatorTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/Creators/PipingProfileCreatorTest.cs (revision 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d) @@ -0,0 +1,158 @@ +// 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; +using System.Collections.Generic; +using System.Linq; +using Deltares.WTIPiping; +using NUnit.Framework; +using Ringtoets.Piping.KernelWrapper.Creators; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.KernelWrapper.Test.Creators +{ + [TestFixture] + public class PipingProfileCreatorTest + { + [Test] + public void Create_ProfileWithOneLayer_ReturnsProfileWithSingleLayer() + { + // Setup + var random = new Random(22); + double expectedTop = random.NextDouble(); + double expectedBottom = expectedTop - random.NextDouble(); + + var layers = new[] + { + new PipingSoilLayer(expectedTop) + { + IsAquifer = true + } + }; + var soilProfile = new PipingSoilProfile(string.Empty, expectedBottom, layers, SoilProfileType.SoilProfile1D); + + // Call + PipingProfile actual = PipingProfileCreator.Create(soilProfile); + + // Assert + Assert.IsNotNull(actual.Layers); + Assert.IsNotNull(actual.BottomAquiferLayer); + Assert.IsNotNull(actual.TopAquiferLayer); + Assert.AreEqual(1, actual.Layers.Count); + Assert.AreEqual(expectedTop, actual.Layers[0].TopLevel); + Assert.AreEqual(expectedTop, actual.TopLevel); + Assert.AreEqual(expectedBottom, actual.BottomLevel); + + PipingLayer pipingLayer = actual.Layers.First(); + Assert.IsTrue(pipingLayer.IsAquifer); + } + + [Test] + public void Create_ProfileWithDecreasingTops_ReturnsProfileWithMultipleLayers() + { + // Setup + var random = new Random(22); + double expectedTopA = random.NextDouble(); + double expectedTopB = expectedTopA - random.NextDouble(); + double expectedTopC = expectedTopB - random.NextDouble(); + double expectedBottom = expectedTopC - random.NextDouble(); + var layers = new[] + { + new PipingSoilLayer(expectedTopA) + { + IsAquifer = true + }, + new PipingSoilLayer(expectedTopB), + new PipingSoilLayer(expectedTopC) + }; + + var soilProfile = new PipingSoilProfile(string.Empty, expectedBottom, layers, SoilProfileType.SoilProfile1D); + + // Call + PipingProfile actual = PipingProfileCreator.Create(soilProfile); + + // Assert + Assert.AreEqual(3, actual.Layers.Count); + IEnumerable expectedAquifers = new[] + { + true, + false, + false + }; + CollectionAssert.AreEqual(expectedAquifers, actual.Layers.Select(l => l.IsAquifer)); + CollectionAssert.AreEqual(new[] + { + expectedTopA, + expectedTopB, + expectedTopC + }, actual.Layers.Select(l => l.TopLevel)); + Assert.AreEqual(expectedBottom, actual.BottomLevel); + } + + [Test] + public void Create_ProfileWithMultipleLayers_ReturnsProfileWithOrderedMultipleLayers() + { + // Setup + var random = new Random(22); + double expectedTopA = random.NextDouble(); + double expectedTopB = random.NextDouble() + expectedTopA; + double expectedTopC = random.NextDouble() + expectedTopB; + double expectedBottom = expectedTopA - random.NextDouble(); + var layers = new[] + { + new PipingSoilLayer(expectedTopA) + { + IsAquifer = true + }, + new PipingSoilLayer(expectedTopB), + new PipingSoilLayer(expectedTopC) + }; + var soilProfile = new PipingSoilProfile(string.Empty, expectedBottom, layers, SoilProfileType.SoilProfile1D); + + // Precondition + CollectionAssert.AreNotEqual(layers, layers.OrderByDescending(l => l.Top), "Layer collection should not be in descending order by the Top property."); + + // Call + PipingProfile actual = PipingProfileCreator.Create(soilProfile); + + // Assert + IEnumerable ordered = actual.Layers.OrderByDescending(l => l.TopLevel); + CollectionAssert.AreEqual(ordered, actual.Layers); + + Assert.AreEqual(3, actual.Layers.Count); + IEnumerable expectedAquifers = new[] + { + false, + false, + true + }; + CollectionAssert.AreEqual(expectedAquifers, actual.Layers.Select(l => l.IsAquifer)); + CollectionAssert.AreEqual(new[] + { + expectedTopC, + expectedTopB, + expectedTopA + }, actual.Layers.Select(l => l.TopLevel)); + Assert.AreEqual(expectedBottom, actual.BottomLevel); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/Creators/PipingSurfaceLineCreatorTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/Creators/PipingSurfaceLineCreatorTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/Creators/PipingSurfaceLineCreatorTest.cs (revision 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d) @@ -0,0 +1,338 @@ +// 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.Linq; +using Core.Common.Base.Geometry; +using Core.Common.TestUtil; +using Deltares.WTIPiping; +using NUnit.Framework; +using Ringtoets.Piping.KernelWrapper.Creators; +using PipingSurfaceLine = Ringtoets.Piping.Primitives.PipingSurfaceLine; + +namespace Ringtoets.Piping.KernelWrapper.Test.Creators +{ + [TestFixture] + public class PipingSurfaceLineCreatorTest + { + [Test] + public void Create_NormalizedLocalSurfaceLine_ReturnsSurfaceLineWithIdenticalPoints() + { + // Setup + const string name = "Local coordinate surface line"; + var surfaceLine = new PipingSurfaceLine(name); + surfaceLine.SetGeometry(new[] + { + new Point3D(0.0, 0.0, 1.1), + new Point3D(2.2, 0.0, 3.3), + new Point3D(4.4, 0.0, 5.5) + }); + + // Call + Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + Assert.AreEqual(name, actual.Name); + CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.X).ToArray(), actual.Points.Select(p => p.X).ToArray()); + CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Y).ToArray(), actual.Points.Select(p => p.Y).ToArray()); + CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z).ToArray(), actual.Points.Select(p => p.Z).ToArray()); + CollectionAssert.AreEqual(Enumerable.Repeat(PipingCharacteristicPointType.None, surfaceLine.Points.Length), actual.Points.Select(p => p.Type)); + } + + [Test] + public void Create_LocalSurfaceLineNotNormalized_TranslateAllPointsToMakeFirstCoordinateZeroX() + { + // Setup + const string name = "Local coordinate surface line"; + const double firstX = 4.6; + var surfaceLine = new PipingSurfaceLine(name); + surfaceLine.SetGeometry(new[] + { + new Point3D(firstX, 0.0, 1.1), + new Point3D(7.8, 0.0, 3.3), + new Point3D(9.9, 0.0, 5.5) + }); + + // Call + Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + double[] expectedCoordinatesX = surfaceLine.Points.Select(p => p.X - firstX).ToArray(); + Assert.AreEqual(name, actual.Name); + CollectionAssert.AreEqual(expectedCoordinatesX, actual.Points.Select(p => p.X).ToArray(), new DoubleWithToleranceComparer(1e-2)); + CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Y).ToArray(), actual.Points.Select(p => p.Y).ToArray()); + CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z).ToArray(), actual.Points.Select(p => p.Z).ToArray()); + CollectionAssert.AreEqual(Enumerable.Repeat(PipingCharacteristicPointType.None, surfaceLine.Points.Length), actual.Points.Select(p => p.Type)); + } + + [Test] + public void Create_GlobalSurfaceLine_ProjectSurfaceLineIntoLZPlaneSpannedByFirstAndLastPoint() + { + // Setup + const string name = "Global coordinate surface line"; + var surfaceLine = new PipingSurfaceLine(name); + surfaceLine.SetGeometry(new[] + { + new Point3D(1.0, 1.0, 2.2), + new Point3D(2.0, 3.0, 4.4), // Outlier from line specified by extrema + new Point3D(3.0, 4.0, 7.7) + }); + + // Call + Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + double length = Math.Sqrt(2 * 2 + 3 * 3); + const double secondCoordinateFactor = (2.0 * 1.0 + 3.0 * 2.0) / (2.0 * 2.0 + 3.0 * 3.0); + double[] expectedCoordinatesX = + { + 0.0, + secondCoordinateFactor * length, + length + }; + Assert.AreEqual(name, actual.Name); + CollectionAssert.AreEqual(expectedCoordinatesX, actual.Points.Select(p => p.X).ToArray(), new DoubleWithToleranceComparer(1e-2)); + CollectionAssert.AreEqual(Enumerable.Repeat(0, surfaceLine.Points.Length).ToArray(), actual.Points.Select(p => p.Y).ToArray()); + CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z).ToArray(), actual.Points.Select(p => p.Z).ToArray()); + CollectionAssert.AreEqual(Enumerable.Repeat(PipingCharacteristicPointType.None, surfaceLine.Points.Length), actual.Points.Select(p => p.Type)); + } + + [Test] + public void Create_SurfaceLineWithOnlyOnePoint_CreatePipingSurfaceLineWithOnePoint() + { + // Setup + const string name = "Global coordinate surface line"; + var surfaceLine = new PipingSurfaceLine(name); + surfaceLine.SetGeometry(new[] + { + new Point3D(1.0, 1.0, 2.2) + }); + + // Call + Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + double[] expectedCoordinatesX = + { + 0.0 + }; + Assert.AreEqual(name, actual.Name); + CollectionAssert.AreEqual(expectedCoordinatesX, actual.Points.Select(p => p.X).ToArray()); + CollectionAssert.AreEqual(Enumerable.Repeat(0, surfaceLine.Points.Length).ToArray(), actual.Points.Select(p => p.Y).ToArray()); + CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z).ToArray(), actual.Points.Select(p => p.Z).ToArray()); + CollectionAssert.AreEqual(Enumerable.Repeat(PipingCharacteristicPointType.None, surfaceLine.Points.Length), actual.Points.Select(p => p.Type)); + } + + [Test] + public void Create_SurfaceLineWithoutPoints_CreateSurfaceLineWithoutPoints() + { + // Setup + const string name = "Surface line without points"; + var surfaceLine = new PipingSurfaceLine(name); + + // Call + Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + Assert.AreEqual(name, actual.Name); + CollectionAssert.IsEmpty(actual.Points); + } + + [Test] + public void Create_SurfaceLineWithDikeToePolderSide_CreateSurfaceLineWithDikeToePolderSideSet() + { + // Setup + const string name = "Surface line without points"; + var point = new Point3D(1.0, 1.0, 2.2); + var surfaceLine = new PipingSurfaceLine(name); + surfaceLine.SetGeometry(new[] + { + point + }); + surfaceLine.SetDikeToeAtPolderAt(point); + + // Call + Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + Assert.AreEqual(name, actual.Name); + Assert.AreEqual(1, actual.Points.Count); + AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.DikeToeAtPolder); + } + + [Test] + public void Create_SurfaceLineWithDitchDikeSide_CreateSurfaceLineWithDitchDikeSideSet() + { + // Setup + const string name = "Surface line without points"; + var point = new Point3D(1.0, 1.0, 2.2); + var surfaceLine = new PipingSurfaceLine(name); + surfaceLine.SetGeometry(new[] + { + point + }); + surfaceLine.SetDitchDikeSideAt(point); + + // Call + Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + Assert.AreEqual(name, actual.Name); + Assert.AreEqual(1, actual.Points.Count); + AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.DitchDikeSide); + } + + [Test] + public void Create_SurfaceLineWithDitchDikeSideAndDikeToeAtPolder_CreateSurfaceLineWithDitchDikeSideAndDikeToeAtPolderSet() + { + // Setup + const string name = "Surface line without points"; + var point = new Point3D(1.0, 1.0, 2.2); + var surfaceLine = new PipingSurfaceLine(name); + surfaceLine.SetGeometry(new[] + { + point + }); + surfaceLine.SetDitchDikeSideAt(point); + + // Call + Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + Assert.AreEqual(name, actual.Name); + Assert.AreEqual(1, actual.Points.Count); + AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.DitchDikeSide); + } + + [Test] + public void Create_SurfaceLineWithBottomDitchDikeSide_CreateSurfaceLineWithBottomDitchDikeSideSet() + { + // Setup + const string name = "Surface line without points"; + var point = new Point3D(1.0, 1.0, 2.2); + var surfaceLine = new PipingSurfaceLine(name); + surfaceLine.SetGeometry(new[] + { + point + }); + surfaceLine.SetBottomDitchDikeSideAt(point); + + // Call + Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + Assert.AreEqual(name, actual.Name); + Assert.AreEqual(1, actual.Points.Count); + AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.BottomDitchDikeSide); + } + + [Test] + public void Create_SurfaceLineWithBottomPolderDikeSide_CreateSurfaceLineWithBottomDitchPolderSideSet() + { + // Setup + const string name = "Surface line without points"; + var point = new Point3D(1.0, 1.0, 2.2); + var surfaceLine = new PipingSurfaceLine(name); + surfaceLine.SetGeometry(new[] + { + point + }); + surfaceLine.SetBottomDitchPolderSideAt(point); + + // Call + Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + Assert.AreEqual(name, actual.Name); + Assert.AreEqual(1, actual.Points.Count); + AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.BottomDitchPolderSide); + } + + [Test] + public void Create_SurfaceLineWithPolderDikeSide_CreateSurfaceLineWithDitchPolderSideSet() + { + // Setup + const string name = "Surface line without points"; + var point = new Point3D(1.0, 1.0, 2.2); + var surfaceLine = new PipingSurfaceLine(name); + surfaceLine.SetGeometry(new[] + { + point + }); + surfaceLine.SetDitchPolderSideAt(point); + + // Call + Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + Assert.AreEqual(name, actual.Name); + Assert.AreEqual(1, actual.Points.Count); + AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.DitchPolderSide); + } + + [Test] + public void Create_SurfaceLineWithMultipleCharacteristicTypesForOnePoint_CreateSurfaceLineWithPointsForEachType() + { + // Setup + const string name = "Surface line without points"; + var point = new Point3D(1.0, 1.0, 2.2); + var surfaceLine = new PipingSurfaceLine(name); + surfaceLine.SetGeometry(new[] + { + point + }); + surfaceLine.SetDikeToeAtRiverAt(point); + surfaceLine.SetDikeToeAtPolderAt(point); + surfaceLine.SetDitchDikeSideAt(point); + surfaceLine.SetBottomDitchPolderSideAt(point); + surfaceLine.SetBottomDitchDikeSideAt(point); + surfaceLine.SetDitchPolderSideAt(point); + + // Call + Deltares.WTIPiping.PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + Assert.AreEqual(name, actual.Name); + Assert.AreEqual(5, actual.Points.Count); + AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.DikeToeAtPolder); + AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.DitchDikeSide); + AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.BottomDitchPolderSide); + AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.BottomDitchDikeSide); + AssertPointsAreEqual(new Point3D(0.0, 0.0, 2.2), actual.DitchPolderSide); + } + + private void AssertPointsAreEqual(Point3D point, PipingPoint otherPoint) + { + if (point == null) + { + Assert.IsNull(otherPoint); + return; + } + if (otherPoint == null) + { + Assert.Fail("Expected value for otherPoint."); + } + Assert.AreEqual(point.X, otherPoint.X); + Assert.AreEqual(point.Y, otherPoint.Y); + Assert.AreEqual(point.Z, otherPoint.Z); + } + } +} \ No newline at end of file Fisheye: Tag 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/PipingProfileCreatorExceptionTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/PipingProfileCreatorTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/PipingSurfaceLineCreatorTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/Ringtoets.Piping.KernelWrapper.Test.csproj =================================================================== diff -u -r6a5a5c3c47792446311ea872b8626382aecaad11 -r0ecc2eb11789b230484e87fd6109bc61dc8d9b2d --- Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/Ringtoets.Piping.KernelWrapper.Test.csproj (.../Ringtoets.Piping.KernelWrapper.Test.csproj) (revision 6a5a5c3c47792446311ea872b8626382aecaad11) +++ Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/Ringtoets.Piping.KernelWrapper.Test.csproj (.../Ringtoets.Piping.KernelWrapper.Test.csproj) (revision 0ecc2eb11789b230484e87fd6109bc61dc8d9b2d) @@ -59,14 +59,14 @@ - - + + - +