Index: doc/dsoilmodel/queries/All1d2dProfilesAndLayersAndMaterialProperties.sql =================================================================== diff -u -rcc4d576f4e819e0ace71c57eae13b54cfdafc069 -r30c4782361bd6f897f02df74461a73b60bc4a085 --- doc/dsoilmodel/queries/All1d2dProfilesAndLayersAndMaterialProperties.sql (.../All1d2dProfilesAndLayersAndMaterialProperties.sql) (revision cc4d576f4e819e0ace71c57eae13b54cfdafc069) +++ doc/dsoilmodel/queries/All1d2dProfilesAndLayersAndMaterialProperties.sql (.../All1d2dProfilesAndLayersAndMaterialProperties.sql) (revision 30c4782361bd6f897f02df74461a73b60bc4a085) @@ -1,7 +1,9 @@ SELECT + 2 as Dimensions, p.SP2D_Name as ProfileName, l.GeometrySurface as LayerGeometry, mpl.X as IntersectionX, + null as Bottom, sum(case when mat.PN_Name = 'AbovePhreaticLevel' then mat.PV_Value end) AbovePhreaticLevel, sum(case when mat.PN_Name = 'BelowPhreaticLevel' then mat.PV_Value end) BelowPhreaticLevel, sum(case when mat.PN_Name = 'PermeabKx' then mat.PV_Value end) PermeabKx, @@ -21,9 +23,11 @@ GROUP BY l.SL2D_ID UNION SELECT + 1 as Dimensions, p.SP1D_Name as ProfileName, null as LayerGeometry, null as IntersectionX, + p.BottomLevel as Bottom, sum(case when mat.PN_Name = "AbovePhreaticLevel" then mat.PV_Value end) AbovePhreaticLevel, sum(case when mat.PN_Name = "BelowPhreaticLevel" then mat.PV_Value end) BelowPhreaticLevel, sum(case when mat.PN_Name = "PermeabKx" then mat.PV_Value end) PermeabKx, Index: src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/ISoilProfileBuilder.cs =================================================================== diff -u --- src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/ISoilProfileBuilder.cs (revision 0) +++ src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/ISoilProfileBuilder.cs (revision 30c4782361bd6f897f02df74461a73b60bc4a085) @@ -0,0 +1,13 @@ +using Ringtoets.Piping.Data; + +namespace Ringtoets.Piping.IO.Builders +{ + public interface ISoilProfileBuilder + { + /// + /// Creates a new instances of the based on the layer definitions. + /// + /// A new . + PipingSoilProfile Build(); + } +} \ No newline at end of file Index: src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer2D.cs =================================================================== diff -u -r300a33d9acf653458b834b296becbf9ae552de8e -r30c4782361bd6f897f02df74461a73b60bc4a085 --- src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer2D.cs (.../SoilLayer2D.cs) (revision 300a33d9acf653458b834b296becbf9ae552de8e) +++ src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer2D.cs (.../SoilLayer2D.cs) (revision 30c4782361bd6f897f02df74461a73b60bc4a085) @@ -11,7 +11,8 @@ namespace Ringtoets.Piping.IO.Builders { /// - /// This class represents objects which were imported from a DSoilModel database. This class + /// This class represents objects which were imported from a DSoilModel database. Instances of this class are transient and are not to be used + /// once the DSoilModel database has been imported. /// internal class SoilLayer2D { Fisheye: Tag 30c4782361bd6f897f02df74461a73b60bc4a085 refers to a dead (removed) revision in file `src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder1D.cs =================================================================== diff -u --- src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder1D.cs (revision 0) +++ src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder1D.cs (revision 30c4782361bd6f897f02df74461a73b60bc4a085) @@ -0,0 +1,38 @@ +using System.Collections.ObjectModel; +using Ringtoets.Piping.Data; + +namespace Ringtoets.Piping.IO.Builders +{ + /// + /// Helps in the creation of a . + /// + public class SoilProfileBuilder1D : ISoilProfileBuilder + { + internal SoilProfileBuilder1D(string name, double bottom) + { + Name = name; + Bottom = bottom; + Layers = new Collection(); + } + + private Collection Layers { get; set; } + + private string Name { get; set; } + + private double Bottom { get; set; } + + public PipingSoilProfile Build() + { + return new PipingSoilProfile(Name, Bottom, Layers); + } + + /// + /// Adds a new , which will be added to the . + /// + /// + internal void Add(PipingSoilLayer soilLayer) + { + Layers.Add(soilLayer); + } + } +} \ No newline at end of file Index: src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder2D.cs =================================================================== diff -u --- src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder2D.cs (revision 0) +++ src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder2D.cs (revision 30c4782361bd6f897f02df74461a73b60bc4a085) @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +using Ringtoets.Piping.Data; + +using Ringtoets.Piping.IO.Properties; + +namespace Ringtoets.Piping.IO.Builders +{ + /// + /// Constructs a 1d Soil Profile based on definitions of . + /// + internal class SoilProfileBuilder2D : ISoilProfileBuilder + { + private readonly ICollection layers = new Collection(); + + /// + /// Creates a new instance of with the supposed name for the new + /// and the point at which a 1D profile should be obtained from the 2D profile. + /// + /// The name for the constructed by the . + /// The x position from which to obtain a 1D profile. + internal SoilProfileBuilder2D(string profileName, double atX) + { + if (double.IsNaN(atX)) + { + throw new ArgumentException(Resources.Error_SoilProfileBuilderCantDetermineIntersectAtDoubleNaN); + } + ProfileName = profileName; + AtX = atX; + Bottom = double.MaxValue; + } + + /// + /// Adds a new to the profile. + /// + /// The to add to the profile. + /// The . + internal SoilProfileBuilder2D Add(SoilLayer2D soilLayer) + { + double bottom; + foreach (PipingSoilLayer layer in soilLayer.AsPipingSoilLayers(AtX, out bottom)) + { + layers.Add(layer); + } + Bottom = Math.Min(Bottom, bottom); + return this; + } + + /// + /// Creates a new instance of . + /// + /// A new . + public PipingSoilProfile Build() + { + return new PipingSoilProfile(ProfileName, Bottom, layers); + } + + private double Bottom { get; set; } + + private double AtX { get; set; } + + private string ProfileName { get; set; } + } +} \ No newline at end of file Index: src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/PipingSoilProfileReader.cs =================================================================== diff -u -rcc4d576f4e819e0ace71c57eae13b54cfdafc069 -r30c4782361bd6f897f02df74461a73b60bc4a085 --- src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision cc4d576f4e819e0ace71c57eae13b54cfdafc069) +++ src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision 30c4782361bd6f897f02df74461a73b60bc4a085) @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Data; using System.Data.SQLite; using System.IO; @@ -26,13 +27,15 @@ private SQLiteDataReader dataReader; private const string profileNameColumn = "ProfileName"; private const string intersectionXColumn = "IntersectionX"; + private const string bottomColumn = "Bottom"; private const string layerGeometryColumn = "LayerGeometry"; private const string abovePhreaticLevelColumn = "AbovePhreaticLevel"; private const string belowPhreaticLevelColumn = "BelowPhreaticLevel"; private const string permeabKxColumn = "PermeabKx"; private const string diameterD70Column = "DiameterD70"; private const string whitesConstantColumn = "WhitesConstant"; private const string beddingAngleColumn = "BeddingAngle"; + private const string dimensionsColumn = "Dimensions"; /// /// Creates a new instance of which will use the @@ -62,28 +65,57 @@ /// Thrown when parsing the geometry of a soil layer failed. public IEnumerable Read() { - var pipingSoilProfiles = new Dictionary(); + var pipingSoilProfileBuilders = new Dictionary(); CreateDataReader(); while (dataReader.Read()) { var profileName = (string)dataReader[profileNameColumn]; - var intersectionX = dataReader[intersectionXColumn] as double?; - if (intersectionX != null) + var dimensions = (long) dataReader[dimensionsColumn]; + if (dimensions == 2) { - if (!pipingSoilProfiles.ContainsKey(profileName)) + var intersectionX = (double) dataReader[intersectionXColumn]; + if (!pipingSoilProfileBuilders.ContainsKey(profileName)) { - pipingSoilProfiles.Add(profileName, new SoilProfileBuilder(profileName, intersectionX.Value)); + pipingSoilProfileBuilders.Add(profileName, new SoilProfileBuilder2D(profileName, intersectionX)); } - pipingSoilProfiles[profileName].Add(ReadPiping2DSoilLayer()); + var soilProfile2DBuilder = pipingSoilProfileBuilders[profileName] as SoilProfileBuilder2D; + + if(soilProfile2DBuilder == null) + { + throw new PipingSoilProfileReadException(Resources.Error_CannotCombine2DAnd1DLayersInProfile); + } + + soilProfile2DBuilder.Add(ReadPiping2DSoilLayer()); } + else + { + var bottom = (double)dataReader[bottomColumn]; + if (!pipingSoilProfileBuilders.ContainsKey(profileName)) + { + pipingSoilProfileBuilders.Add(profileName, new SoilProfileBuilder1D(profileName, bottom)); + } + var soilProfile1DBuilder = pipingSoilProfileBuilders[profileName] as SoilProfileBuilder1D; + + if (soilProfile1DBuilder == null) + { + throw new PipingSoilProfileReadException(Resources.Error_CannotCombine2DAnd1DLayersInProfile); + } + soilProfile1DBuilder.Add(ReadPipingSoilLayer()); + } } - return pipingSoilProfiles.Select(keyValue => keyValue.Value.Build()); + return pipingSoilProfileBuilders.Select(keyValue => keyValue.Value.Build()); } + private PipingSoilLayer ReadPipingSoilLayer() + { + var columnValue = (double) dataReader[bottomColumn]; + return new PipingSoilLayer(columnValue); + } + public void Dispose() { dataReader.Dispose(); @@ -136,12 +168,14 @@ "p.SP2D_Name as {0},", "l.GeometrySurface as {1},", "mpl.X as {2},", - "sum(case when mat.PN_Name = 'AbovePhreaticLevel' then mat.PV_Value end) {3},", - "sum(case when mat.PN_Name = 'BelowPhreaticLevel' then mat.PV_Value end) {4},", - "sum(case when mat.PN_Name = 'PermeabKx' then mat.PV_Value end) {5},", - "sum(case when mat.PN_Name = 'DiameterD70' then mat.PV_Value end) {6},", - "sum(case when mat.PN_Name = 'WhitesConstant' then mat.PV_Value end) {7},", - "sum(case when mat.PN_Name = 'BeddingAngle' then mat.PV_Value end) {8}", + "null as {3},", + "sum(case when mat.PN_Name = 'AbovePhreaticLevel' then mat.PV_Value end) {4},", + "sum(case when mat.PN_Name = 'BelowPhreaticLevel' then mat.PV_Value end) {5},", + "sum(case when mat.PN_Name = 'PermeabKx' then mat.PV_Value end) {6},", + "sum(case when mat.PN_Name = 'DiameterD70' then mat.PV_Value end) {7},", + "sum(case when mat.PN_Name = 'WhitesConstant' then mat.PV_Value end) {8},", + "sum(case when mat.PN_Name = 'BeddingAngle' then mat.PV_Value end) {9},", + "2 as {10}", "FROM MechanismPointLocation as m", "JOIN MechanismPointLocation as mpl ON p.SP2D_ID = mpl.SP2D_ID", "JOIN SoilProfile2D as p ON m.SP2D_ID = p.SP2D_ID", @@ -151,19 +185,21 @@ "FROM ParameterNames as pn", "JOIN ParameterValues as pv ON pn.PN_ID = pv.PN_ID", "JOIN Materials as m ON m.MA_ID = pv.MA_ID) as mat ON l.MA_ID = mat.MA_ID", - "WHERE m.ME_ID = @{9}", + "WHERE m.ME_ID = @{11}", "GROUP BY l.SL2D_ID", "UNION", "SELECT", "p.SP1D_Name as {0},", "null as {1},", "null as {2},", - "sum(case when mat.PN_Name = 'AbovePhreaticLevel' then mat.PV_Value end) {3},", - "sum(case when mat.PN_Name = 'BelowPhreaticLevel' then mat.PV_Value end) {4},", - "sum(case when mat.PN_Name = 'PermeabKx' then mat.PV_Value end) {5},", - "sum(case when mat.PN_Name = 'DiameterD70' then mat.PV_Value end) {6},", - "sum(case when mat.PN_Name = 'WhitesConstant' then mat.PV_Value end) {7},", - "sum(case when mat.PN_Name = 'BeddingAngle' then mat.PV_Value end) {8}", + "p.BottomLevel as {3},", + "sum(case when mat.PN_Name = 'AbovePhreaticLevel' then mat.PV_Value end) {4},", + "sum(case when mat.PN_Name = 'BelowPhreaticLevel' then mat.PV_Value end) {5},", + "sum(case when mat.PN_Name = 'PermeabKx' then mat.PV_Value end) {6},", + "sum(case when mat.PN_Name = 'DiameterD70' then mat.PV_Value end) {7},", + "sum(case when mat.PN_Name = 'WhitesConstant' then mat.PV_Value end) {8},", + "sum(case when mat.PN_Name = 'BeddingAngle' then mat.PV_Value end) {9},", + "1 as {10}", "FROM SoilProfile1D as p", "JOIN SoilLayer1D as l ON l.SP1D_ID = p.SP1D_ID", "JOIN (", @@ -177,12 +213,14 @@ profileNameColumn, layerGeometryColumn, intersectionXColumn, + bottomColumn, abovePhreaticLevelColumn, belowPhreaticLevelColumn, permeabKxColumn, diameterD70Column, whitesConstantColumn, beddingAngleColumn, + dimensionsColumn, mechanismParameterName) }; query.Parameters.Add(new SQLiteParameter Index: src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r300a33d9acf653458b834b296becbf9ae552de8e -r30c4782361bd6f897f02df74461a73b60bc4a085 --- src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 300a33d9acf653458b834b296becbf9ae552de8e) +++ src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 30c4782361bd6f897f02df74461a73b60bc4a085) @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18444 +// Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -61,6 +61,15 @@ } /// + /// Looks up a localized string similar to Kan geen 2D en 1D lagen combineren in een profiel.. + /// + public static string Error_CannotCombine2DAnd1DLayersInProfile { + get { + return ResourceManager.GetString("Error_CannotCombine2DAnd1DLayersInProfile", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Kan geen 1D profiel bepalen wanneer segmenten in een 2D laag verticaal lopen op de gekozen positie: x = {0}.. /// public static string Error_CanNotDetermine1DProfileWithVerticalSegmentsAtX { Index: src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx =================================================================== diff -u -rb3fa1606efddd3bed496c2844a495ff92347fa44 -r30c4782361bd6f897f02df74461a73b60bc4a085 --- src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision b3fa1606efddd3bed496c2844a495ff92347fa44) +++ src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision 30c4782361bd6f897f02df74461a73b60bc4a085) @@ -171,4 +171,7 @@ Kan geen 1D profiel bepalen wanneer segmenten in een 2D laag verticaal lopen op de gekozen positie: x = {0}. + + Kan geen 2D en 1D lagen combineren in een profiel. + \ No newline at end of file Index: src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj =================================================================== diff -u -r300a33d9acf653458b834b296becbf9ae552de8e -r30c4782361bd6f897f02df74461a73b60bc4a085 --- src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 300a33d9acf653458b834b296becbf9ae552de8e) +++ src/Plugins/Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 30c4782361bd6f897f02df74461a73b60bc4a085) @@ -39,9 +39,11 @@ Properties\GlobalAssembly.cs + - + + Index: src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilProfileBuilder1DTest.cs =================================================================== diff -u --- src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilProfileBuilder1DTest.cs (revision 0) +++ src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilProfileBuilder1DTest.cs (revision 30c4782361bd6f897f02df74461a73b60bc4a085) @@ -0,0 +1,70 @@ +using System; +using System.Linq; +using NUnit.Framework; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.IO.Builders; + +namespace Ringtoets.Piping.IO.Test.Builders +{ + public class SoilProfileBuilder1DTest + { + [Test] + public void Build_WithOutLayers_ThrowsArgumentException() + { + // Setup + var profileName = "SomeProfile"; + var builder = new SoilProfileBuilder1D(profileName, 0.0); + + // Call + TestDelegate test = () => builder.Build(); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Build_WithSingleLayer_ReturnsProfileWithBottomAndALayer() + { + // Setup + var profileName = "SomeProfile"; + var random = new Random(22); + var bottom = random.NextDouble(); + var top = random.NextDouble(); + var builder = new SoilProfileBuilder1D(profileName, bottom); + builder.Add(new PipingSoilLayer(top)); + + // Call + PipingSoilProfile soilProfile = builder.Build(); + + // Assert + Assert.AreEqual(profileName, soilProfile.Name); + Assert.AreEqual(1, soilProfile.Layers.Count()); + Assert.AreEqual(top, soilProfile.Layers.ToArray()[0].Top); + Assert.AreEqual(bottom, soilProfile.Bottom); + } + + [Test] + public void Build_WithMultipleLayers_ReturnsProfileWithBottomAndALayer() + { + // Setup + var profileName = "SomeProfile"; + var random = new Random(22); + var bottom = random.NextDouble(); + var top = random.NextDouble(); + var top2 = random.NextDouble(); + + var builder = new SoilProfileBuilder1D(profileName, bottom); + builder.Add(new PipingSoilLayer(top)); + builder.Add(new PipingSoilLayer(top2)); + + // Call + PipingSoilProfile soilProfile = builder.Build(); + + // Assert + Assert.AreEqual(profileName, soilProfile.Name); + Assert.AreEqual(2, soilProfile.Layers.Count()); + CollectionAssert.AreEquivalent(new [] {top,top2}, soilProfile.Layers.Select(l => l.Top)); + Assert.AreEqual(bottom, soilProfile.Bottom); + } + } +} \ No newline at end of file Index: src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilProfileBuilder2DTest.cs =================================================================== diff -u --- src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilProfileBuilder2DTest.cs (revision 0) +++ src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilProfileBuilder2DTest.cs (revision 30c4782361bd6f897f02df74461a73b60bc4a085) @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using NUnit.Framework; + +using Ringtoets.Piping.Data; + +using Ringtoets.Piping.Data.TestUtil; +using Ringtoets.Piping.IO.Builders; +using Ringtoets.Piping.IO.Properties; + +namespace Ringtoets.Piping.IO.Test.Builders +{ + public class SoilProfileBuilder2DTest + { + [Test] + [TestCase(null)] + [TestCase("name")] + public void Constructor_WithNameInvalidX_ThrowsArgumentExcpetion(string name) + { + // Call + TestDelegate test = () => new SoilProfileBuilder2D(name, double.NaN); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual(Resources.Error_SoilProfileBuilderCantDetermineIntersectAtDoubleNaN, exception.Message); + } + + [Test] + [TestCase(null)] + [TestCase("name")] + public void Constructor_WithNameValidX_ReturnsNewInstance(string name) + { + // Call + var builder = new SoilProfileBuilder2D(name, 0.0); + + // Assert + Assert.NotNull(builder); + } + + [Test] + public void Build_WithOutLayers_ThrowsArgumentException() + { + // Setup + var profileName = "SomeProfile"; + var builder = new SoilProfileBuilder2D(profileName, 0.0); + + // Call + TestDelegate test = () => builder.Build(); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Build_WithSingleLayerOnlyOuterLoop_ReturnsProfileWithBottomAndALayer() + { + // Setup + var profileName = "SomeProfile"; + var builder = new SoilProfileBuilder2D(profileName, 0.0); + builder.Add(new SoilLayer2D + { + OuterLoop = new HashSet + { + new Point3D + { + X = -0.5, Z = 1.0 + }, + new Point3D + { + X = 0.5, Z = 1.0 + }, + new Point3D + { + X = 0.5, Z = -1.0 + }, + new Point3D + { + X = -0.5, Z = -1.0 + } + } + }); + + // Call + PipingSoilProfile soilProfile = builder.Build(); + + // Assert + Assert.AreEqual(profileName, soilProfile.Name); + Assert.AreEqual(1, soilProfile.Layers.Count()); + Assert.AreEqual(1.0, soilProfile.Layers.ToArray()[0].Top); + Assert.AreEqual(-1.0, soilProfile.Bottom); + } + + [Test] + public void Build_WithMultipleLayersOnlyOuterLoop_ReturnsProfileWithBottomAndALayers() + { + // Setup + var profileName = "SomeProfile"; + var builder = new SoilProfileBuilder2D(profileName, 1.0); + builder.Add(new SoilLayer2D + { + OuterLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine, + "10", + "...", + "...", + "...", + "...", + "...", + "...", + "...", + "1.2", + "4.3", + "..." + )) + }).Add(new SoilLayer2D + { + OuterLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine, + "10", + "...", + "...", + "...", + "...", + "...", + "4.3", + "...", + "1.2", + "...", + "..." + )) + }).Add(new SoilLayer2D + { + OuterLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine, + "10", + "...", + "1.2", + "...", + "...", + "...", + "4.3", + "...", + "...", + "...", + "..." + )) + }); + + // Call + PipingSoilProfile soilProfile = builder.Build(); + + // Assert + Assert.AreEqual(profileName, soilProfile.Name); + Assert.AreEqual(3, soilProfile.Layers.Count()); + CollectionAssert.AreEquivalent(new[] { 2.0, 4.0, 8.0 }, soilProfile.Layers.Select(rl => rl.Top)); + Assert.AreEqual(1.0, soilProfile.Bottom); + } + + + [Test] + public void Build_WithLayerFilledWithOtherLayer_ReturnsProfileWithBottomAndALayers() + { + // Setup + var profileName = "SomeProfile"; + var builder = new SoilProfileBuilder2D(profileName, 2.0); + var loopHole = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine, + "5", + ".....", + ".4.1.", + ".3.2.", + ".....", + "....." + )); + builder.Add(new SoilLayer2D + { + OuterLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine, + "5", + "2...3", + ".....", + ".....", + ".....", + "1...4" + )), + InnerLoops = + { + loopHole + } + }).Add(new SoilLayer2D + { + OuterLoop = loopHole + }); + + // Call + PipingSoilProfile soilProfile = builder.Build(); + + // Assert + Assert.AreEqual(profileName, soilProfile.Name); + Assert.AreEqual(3, soilProfile.Layers.Count()); + CollectionAssert.AreEquivalent(new[] { 4.0, 3.0, 2.0 }, soilProfile.Layers.Select(rl => rl.Top)); + Assert.AreEqual(0.0, soilProfile.Bottom); + } + } +} \ No newline at end of file Fisheye: Tag 30c4782361bd6f897f02df74461a73b60bc4a085 refers to a dead (removed) revision in file `src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilProfileBuilderTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/PipingSoilProfileReaderTest.cs =================================================================== diff -u -r300a33d9acf653458b834b296becbf9ae552de8e -r30c4782361bd6f897f02df74461a73b60bc4a085 --- src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/PipingSoilProfileReaderTest.cs (.../PipingSoilProfileReaderTest.cs) (revision 300a33d9acf653458b834b296becbf9ae552de8e) +++ src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/PipingSoilProfileReaderTest.cs (.../PipingSoilProfileReaderTest.cs) (revision 30c4782361bd6f897f02df74461a73b60bc4a085) @@ -98,12 +98,98 @@ PipingSoilProfile[] result = pipingSoilProfilesReader.Read().ToArray(); // Assert - Assert.AreEqual(2, result.Length); - var firstProfile = result.SingleOrDefault(psp => psp.Name == "10Y_005_STBI"); - Assert.NotNull(firstProfile); + Assert.AreEqual(36, result.Length); + CollectionAssert.AreEquivalent(new [] + { + "10Y_005_STBI_p", + "10Y_024_STBI_p", + "10Y_041_STBI_p", + "10Y_042_STBI_p", + "10Y_043_STBI_p", + "10Y_054_STBI_p", + "10Y_066_STBI_p", + "10Y_090_STBI_p", + "10Y_102_STBI_p", + "10Y_117_STBI_p", + "10Y_130_STBI_p", + "10Y_149_STBI_p", + "10Z_157_STBI_p", + "10Z_165_STBI_p", + "10Z_181_STBI_p", + "10Z_186_STBI_p", + "10Z_199_STBI_p", + "10Z_228_STBI_p", + "10Z_258_STBI_p", + "10Z_275_STBI_p", + "10Z_282_STBI_p", + "10Z_286_STBI_p", + "10Z_311_STBI_p", + "10Z_327_STBI_p", + "10Z_352_STBI_p", + "10Z_358_STBI_p", + "10Z_369_STBI_p", + "10Z_380_STBI_p", + "10Z_390_STBI_p", + "10Z_400_STBI_p", + "10Z_421_STBI_p", + "10Z_432_STBI_p", + "10Z_460_STBI_p", + "10Y_091_STBI_p", + "10Y_005_STBI", + "10Y_041_STBI" + },result.Select(p => p.Name)); - Assert.AreEqual(-10, firstProfile.Bottom); - Assert.AreEqual(6, firstProfile.Layers.Count()); + CollectionAssert.AreEquivalent(new[] + { + -10, + -12.0, + -10.8, + -10, + -21.5, + -21.5, + -21.5, + -22.0, + -24.0, + -21.5, + -21.5, + -22.0, + -24.17, + -24.8, + -25.0, + -24.0, + -22.8, + -23.8, + -24.2, + -24.5, + -24.0, + -23.7, + -24.4, + -24.0, + -31.5, + -23.2, + -23.9, + -23.1, + -23.5, + -23.125, + -22.5, + -21.88, + -22.0, + 40.0, + 40.0, + 40.0 + }, result.Select(p => p.Bottom)); + + foreach (var l in result.Select(p => p.Layers.Count())) + { + Console.WriteLine(l); + } + CollectionAssert.AreEquivalent(new[] + { + 6,3,2,3,2,2,2,2,3,2,2,2,2,3,3,3,2,2,2,2,3,2,3,3,2,2,3,2,2,2,2,2,2,1,1,1 + }, result.Select(p => p.Layers.Count())); + + var firstProfile = result.FirstOrDefault(l => l.Name == "10Y_005_STBI"); + Assert.NotNull(firstProfile); var expected = new[] { -3.5, Index: src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj =================================================================== diff -u -r300a33d9acf653458b834b296becbf9ae552de8e -r30c4782361bd6f897f02df74461a73b60bc4a085 --- src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 300a33d9acf653458b834b296becbf9ae552de8e) +++ src/Plugins/Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 30c4782361bd6f897f02df74461a73b60bc4a085) @@ -45,7 +45,8 @@ - + +