Index: Core/Common/src/Core.Common.IO/Readers/IRowBasedDatabaseReader.cs =================================================================== diff -u -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 -r49f905d3363336d44ef828259692644dcf5f9edc --- Core/Common/src/Core.Common.IO/Readers/IRowBasedDatabaseReader.cs (.../IRowBasedDatabaseReader.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) +++ Core/Common/src/Core.Common.IO/Readers/IRowBasedDatabaseReader.cs (.../IRowBasedDatabaseReader.cs) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -49,12 +49,13 @@ /// /// Reads the value in the column with name from the - /// current row that's being pointed at. + /// current row that's being pointed at. If the column has a value of , + /// then the default value for is returned. /// /// The type of object to read. /// The name of the column to read from. /// The value in the column, or null if the value was . /// Thrown when the value in the column could not be casted to type . - T? ReadOrNull(string columnName) where T : struct; + T ReadOrDefault(string columnName); } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer1D.cs =================================================================== diff -u -rd82fa09fe9ae053ce7702ba89ef23ae029640d1b -r49f905d3363336d44ef828259692644dcf5f9edc --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer1D.cs (.../SoilLayer1D.cs) (revision d82fa09fe9ae053ce7702ba89ef23ae029640d1b) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer1D.cs (.../SoilLayer1D.cs) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Drawing; using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.IO.Builders @@ -65,6 +66,16 @@ public double? DryUnitWeight { get; set; } /// + /// Gets or sets the name of the material that was assigned to the . + /// + public string MaterialName { get; set; } + + /// + /// Gets or sets the value representing a color that was used to represent the . + /// + public double? Color { get; set; } + + /// /// Constructs a (1D) based on the properties set for the . /// /// The with properties corresponding to those set on the . @@ -75,7 +86,9 @@ AbovePhreaticLevel = AbovePhreaticLevel, BelowPhreaticLevel = BelowPhreaticLevel, DryUnitWeight = DryUnitWeight, - IsAquifer = IsAquifer.HasValue && IsAquifer.Value.Equals(1.0) + IsAquifer = IsAquifer.HasValue && IsAquifer.Value.Equals(1.0), + MaterialName = MaterialName, + Color = SoilLayerColorConversionHelper.ColorFromNullableDouble(Color) }; } } Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer2D.cs =================================================================== diff -u -red0efdcfe1c041f58f65ac59a18c42bd1df9f1ff -r49f905d3363336d44ef828259692644dcf5f9edc --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer2D.cs (.../SoilLayer2D.cs) (revision ed0efdcfe1c041f58f65ac59a18c42bd1df9f1ff) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer2D.cs (.../SoilLayer2D.cs) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Drawing; using System.Linq; using Core.Common.Base.Geometry; @@ -70,6 +71,16 @@ public double? DryUnitWeight { get; set; } /// + /// Gets or sets the name of the material that was assigned to the . + /// + public string MaterialName { get; set; } + + /// + /// Gets or sets the value representing a color that was used to represent the . + /// + public double? Color { get; set; } + + /// /// Gets the outer loop of the as a of , /// for which each of the segments are connected to the next. /// @@ -148,7 +159,9 @@ IsAquifer = IsAquifer.HasValue && IsAquifer.Value.Equals(1.0), BelowPhreaticLevel = BelowPhreaticLevel, AbovePhreaticLevel = AbovePhreaticLevel, - DryUnitWeight = DryUnitWeight + DryUnitWeight = DryUnitWeight, + MaterialName = MaterialName, + Color = SoilLayerColorConversionHelper.ColorFromNullableDouble(Color) }); } bottom = EnsureBottomOutsideInnerLoop(innerLoopIntersectionHeightPairs, currentBottom); Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayerColorConversionHelper.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayerColorConversionHelper.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayerColorConversionHelper.cs (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -0,0 +1,26 @@ +using System; +using System.Drawing; + +namespace Ringtoets.Piping.IO.Builders +{ + /// + /// This class provides helpers for converting double values from the DSoilModel database into + /// . + /// + public static class SoilLayerColorConversionHelper + { + /// + /// Converts a nullable to a . + /// + /// The value to convert. + /// A instance based on the . + public static Color ColorFromNullableDouble(double? colorValue) + { + if (colorValue == null) + { + return Color.Empty; + } + return Color.FromArgb(Convert.ToInt32(colorValue)); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj =================================================================== diff -u -rdc338e85283e37af4984f737a9f7ae0d213596be -r49f905d3363336d44ef828259692644dcf5f9edc --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision dc338e85283e37af4984f737a9f7ae0d213596be) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -43,6 +43,7 @@ Properties\GlobalAssembly.cs + @@ -112,6 +113,10 @@ + + + + C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll @@ -121,6 +126,8 @@ True False + + C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.XML.dll Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs =================================================================== diff -u -r7e53fcef8411be3bba8f9a7daeae64bbdc491077 -r49f905d3363336d44ef828259692644dcf5f9edc --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision 7e53fcef8411be3bba8f9a7daeae64bbdc491077) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -126,12 +126,12 @@ /// The name of the column to read from. /// The value in the column, or null if the value was . /// Thrown when the value in the column could not be casted to type . - public T? ReadOrNull(string columnName) where T : struct + public T ReadOrDefault(string columnName) { var valueObject = dataReader[columnName]; if (valueObject.Equals(DBNull.Value)) { - return null; + return default(T); } return (T)valueObject; } Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile1DReader.cs =================================================================== diff -u -rd82fa09fe9ae053ce7702ba89ef23ae029640d1b -r49f905d3363336d44ef828259692644dcf5f9edc --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile1DReader.cs (.../SoilProfile1DReader.cs) (revision d82fa09fe9ae053ce7702ba89ef23ae029640d1b) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile1DReader.cs (.../SoilProfile1DReader.cs) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -95,7 +95,9 @@ IsAquifer = properties.IsAquifer, BelowPhreaticLevel = properties.BelowPhreaticLevel, AbovePhreaticLevel = properties.AbovePhreaticLevel, - DryUnitWeight = properties.DryUnitWeight + DryUnitWeight = properties.DryUnitWeight, + MaterialName = properties.MaterialName, + Color = properties.Color }; return pipingSoilLayer; } @@ -107,6 +109,8 @@ internal readonly double? BelowPhreaticLevel; internal readonly double? AbovePhreaticLevel; internal readonly double? DryUnitWeight; + internal readonly string MaterialName; + internal readonly double? Color; /// /// Creates a new instance of , which contains properties @@ -125,16 +129,22 @@ Top = reader.Read(readColumn); readColumn = SoilProfileDatabaseColumns.IsAquifer; - IsAquifer = reader.ReadOrNull(readColumn); + IsAquifer = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.BelowPhreaticLevel; - BelowPhreaticLevel = reader.ReadOrNull(readColumn); + BelowPhreaticLevel = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.AbovePhreaticLevel; - AbovePhreaticLevel = reader.ReadOrNull(readColumn); + AbovePhreaticLevel = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.DryUnitWeight; - DryUnitWeight = reader.ReadOrNull(readColumn); + DryUnitWeight = reader.ReadOrDefault(readColumn); + + readColumn = SoilProfileDatabaseColumns.MaterialName; + MaterialName = reader.ReadOrDefault(readColumn); + + readColumn = SoilProfileDatabaseColumns.Color; + Color = reader.ReadOrDefault(readColumn); } catch (InvalidCastException e) { Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs =================================================================== diff -u -rd82fa09fe9ae053ce7702ba89ef23ae029640d1b -r49f905d3363336d44ef828259692644dcf5f9edc --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs (.../SoilProfile2DReader.cs) (revision d82fa09fe9ae053ce7702ba89ef23ae029640d1b) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs (.../SoilProfile2DReader.cs) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -21,6 +21,7 @@ using System; using System.Data.SQLite; +using System.Drawing; using Core.Common.IO.Readers; using Core.Common.Utils.Builders; using Ringtoets.Piping.IO.Builders; @@ -111,6 +112,8 @@ pipingSoilLayer.BelowPhreaticLevel = properties.BelowPhreaticLevel; pipingSoilLayer.AbovePhreaticLevel = properties.AbovePhreaticLevel; pipingSoilLayer.DryUnitWeight = properties.DryUnitWeight; + pipingSoilLayer.MaterialName = properties.MaterialName; + pipingSoilLayer.Color = properties.Color; } return pipingSoilLayer; } @@ -155,6 +158,8 @@ internal readonly double? BelowPhreaticLevel; internal readonly double? AbovePhreaticLevel; internal readonly double? DryUnitWeight; + internal readonly string MaterialName; + internal readonly double? Color; /// /// Creates a new instance of , which contains properties @@ -170,16 +175,22 @@ string readColumn = SoilProfileDatabaseColumns.IsAquifer; try { - IsAquifer = reader.ReadOrNull(readColumn); + IsAquifer = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.BelowPhreaticLevel; - BelowPhreaticLevel = reader.ReadOrNull(readColumn); + BelowPhreaticLevel = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.AbovePhreaticLevel; - AbovePhreaticLevel = reader.ReadOrNull(readColumn); + AbovePhreaticLevel = reader.ReadOrDefault(readColumn); readColumn = SoilProfileDatabaseColumns.DryUnitWeight; - DryUnitWeight = reader.ReadOrNull(readColumn); + DryUnitWeight = reader.ReadOrDefault(readColumn); + + readColumn = SoilProfileDatabaseColumns.MaterialName; + MaterialName = reader.ReadOrDefault(readColumn); + + readColumn = SoilProfileDatabaseColumns.Color; + Color = reader.ReadOrDefault(readColumn); } catch (InvalidCastException e) { Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilLayer.cs =================================================================== diff -u -rb6432b2cbcb2db9bd326d9f006fb2d8b2528d263 -r49f905d3363336d44ef828259692644dcf5f9edc --- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilLayer.cs (.../PipingSoilLayer.cs) (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263) +++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilLayer.cs (.../PipingSoilLayer.cs) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Drawing; using Core.Common.Base.Storage; namespace Ringtoets.Piping.Primitives @@ -65,6 +66,16 @@ /// public double? DryUnitWeight { get; set; } + /// + /// Gets or sets the name of the material that was assigned to the . + /// + public string MaterialName { get; set; } + + /// + /// Gets or sets the that was used to represent the . + /// + public Color Color { get; set; } + public long StorageId { get; set; } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/Ringtoets.Piping.Primitives.csproj =================================================================== diff -u -rbf334f50530164badedba45a78f3aab857ae1bf6 -r49f905d3363336d44ef828259692644dcf5f9edc --- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/Ringtoets.Piping.Primitives.csproj (.../Ringtoets.Piping.Primitives.csproj) (revision bf334f50530164badedba45a78f3aab857ae1bf6) +++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/Ringtoets.Piping.Primitives.csproj (.../Ringtoets.Piping.Primitives.csproj) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -46,6 +46,7 @@ + Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilLayerTest.cs =================================================================== diff -u -rc7c07db38829afdc5965c331844e1d39123944ff -r49f905d3363336d44ef828259692644dcf5f9edc --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilLayerTest.cs (.../PipingSoilLayerTest.cs) (revision c7c07db38829afdc5965c331844e1d39123944ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilLayerTest.cs (.../PipingSoilLayerTest.cs) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.Drawing; using NUnit.Framework; using Ringtoets.Piping.Primitives; @@ -39,6 +40,12 @@ // Assert Assert.NotNull(layer); Assert.AreEqual(top, layer.Top); + Assert.IsNull(layer.AbovePhreaticLevel); + Assert.IsNull(layer.BelowPhreaticLevel); + Assert.IsNull(layer.DryUnitWeight); + Assert.IsFalse(layer.IsAquifer); + Assert.IsNull(layer.MaterialName); + Assert.AreEqual(Color.Empty, layer.Color); } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj =================================================================== diff -u -r80404901c704ca22397f36ebe46f81e73059e30a -r49f905d3363336d44ef828259692644dcf5f9edc --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj (.../Ringtoets.Piping.Data.Test.csproj) (revision 80404901c704ca22397f36ebe46f81e73059e30a) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Ringtoets.Piping.Data.Test.csproj (.../Ringtoets.Piping.Data.Test.csproj) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -52,6 +52,7 @@ + Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayer1DTest.cs =================================================================== diff -u -ra6ba313236d0ff8d2f219fc8249b700b1eade338 -r49f905d3363336d44ef828259692644dcf5f9edc --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayer1DTest.cs (.../SoilLayer1DTest.cs) (revision a6ba313236d0ff8d2f219fc8249b700b1eade338) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayer1DTest.cs (.../SoilLayer1DTest.cs) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -1,4 +1,5 @@ using System; +using System.Drawing; using NUnit.Framework; using Ringtoets.Piping.IO.Builders; @@ -19,6 +20,12 @@ // Assert Assert.AreEqual(top, layer.Top); + Assert.IsNull(layer.AbovePhreaticLevel); + Assert.IsNull(layer.BelowPhreaticLevel); + Assert.IsNull(layer.DryUnitWeight); + Assert.IsNull(layer.IsAquifer); + Assert.IsNull(layer.MaterialName); + Assert.IsNull(layer.Color); } [Test] @@ -30,16 +37,20 @@ // Setup var random = new Random(22); var top = random.NextDouble(); + var materialName = "materialX"; var abovePhreaticLevel = random.NextDouble(); var belowPhreaticLevel = random.NextDouble(); var dryUnitWeight = random.NextDouble(); + var color = Color.BlanchedAlmond; var layer = new SoilLayer1D(top) { + MaterialName = materialName, IsAquifer = isAquifer, AbovePhreaticLevel = abovePhreaticLevel, BelowPhreaticLevel = belowPhreaticLevel, - DryUnitWeight = dryUnitWeight + DryUnitWeight = dryUnitWeight, + Color = color.ToArgb() }; // Call @@ -51,6 +62,8 @@ Assert.AreEqual(abovePhreaticLevel, result.AbovePhreaticLevel); Assert.AreEqual(belowPhreaticLevel, result.BelowPhreaticLevel); Assert.AreEqual(dryUnitWeight, result.DryUnitWeight); + Assert.AreEqual(materialName, result.MaterialName); + Assert.AreEqual(Color.FromArgb(color.ToArgb()), result.Color); } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayer2DTest.cs =================================================================== diff -u -r5b63cfab474523f97be999403eb4906a0c376a3d -r49f905d3363336d44ef828259692644dcf5f9edc --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayer2DTest.cs (.../SoilLayer2DTest.cs) (revision 5b63cfab474523f97be999403eb4906a0c376a3d) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayer2DTest.cs (.../SoilLayer2DTest.cs) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using Core.Common.Base.Geometry; @@ -23,6 +24,12 @@ // Assert Assert.IsNull(result.OuterLoop); CollectionAssert.IsEmpty(result.InnerLoops); + Assert.IsNull(result.AbovePhreaticLevel); + Assert.IsNull(result.BelowPhreaticLevel); + Assert.IsNull(result.DryUnitWeight); + Assert.IsNull(result.IsAquifer); + Assert.IsNull(result.MaterialName); + Assert.IsNull(result.Color); } [Test] @@ -227,6 +234,68 @@ } [Test] + public void AsPipingSoilLayer_PropertiesSetWithDifferentIsAquifer_PropertiesAreSetInPipingSoilLayer() + { + // Setup + var random = new Random(22); + var y1 = random.NextDouble(); + var y2 = y1 + random.NextDouble(); + var x1 = 1.0; + var x2 = 1.1; + var x3 = 1.2; + var abovePhreaticLevel = random.NextDouble(); + var belowPhreaticLevel = random.NextDouble(); + var dryUnitWeight = random.NextDouble(); + var materialName = "materialX"; + var color = Color.DarkSeaGreen; + double bottom; + + var layer = new SoilLayer2D + { + MaterialName = materialName, + IsAquifer = 1.0, + AbovePhreaticLevel = abovePhreaticLevel, + BelowPhreaticLevel = belowPhreaticLevel, + DryUnitWeight = dryUnitWeight, + Color = color.ToArgb(), + OuterLoop = new List + { + new Segment2D( + new Point2D(x1, y1), + new Point2D(x3, y1) + ), + new Segment2D( + new Point2D(x3, y1), + new Point2D(x3, y2) + ), + new Segment2D( + new Point2D(x3, y2), + new Point2D(x1, y2) + ), + new Segment2D( + new Point2D(x1, y1), + new Point2D(x1, y2) + ) + } + }; + + // Call + var result = layer.AsPipingSoilLayers(x2, out bottom).ToArray(); + + // Assert + Assert.AreEqual(1, result.Length); + Assert.AreEqual(y1, bottom, 1e-6); + var resultLayer = result.First(); + Assert.AreEqual(y2, resultLayer.Top, 1e-6); + Assert.IsTrue(resultLayer.IsAquifer); + Assert.AreEqual(abovePhreaticLevel, resultLayer.AbovePhreaticLevel); + Assert.AreEqual(belowPhreaticLevel, resultLayer.BelowPhreaticLevel); + Assert.AreEqual(dryUnitWeight, resultLayer.DryUnitWeight); + Assert.AreEqual(materialName, resultLayer.MaterialName); + Assert.AreEqual(Color.FromArgb(color.ToArgb()), resultLayer.Color); + } + + [Test] public void AsPipingSoilLayers_WithOuterLoopNotIntersectingX_ReturnsEmptyCollectionWithMaxValueBottom() { // Setup Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj =================================================================== diff -u -rcdc41931db8cd6fbebe910c08d315d1b7066a6d2 -r49f905d3363336d44ef828259692644dcf5f9edc --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision cdc41931db8cd6fbebe910c08d315d1b7066a6d2) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -56,6 +56,7 @@ ..\..\..\..\packages\System.Data.SQLite.Core.1.0.99.0\lib\net40\System.Data.SQLite.dll True + @@ -68,6 +69,7 @@ + Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/PipingSoilProfileReaderTest.cs =================================================================== diff -u -r3f6060a9d5e2b63619d407706139325e8efb05df -r49f905d3363336d44ef828259692644dcf5f9edc --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/PipingSoilProfileReaderTest.cs (.../PipingSoilProfileReaderTest.cs) (revision 3f6060a9d5e2b63619d407706139325e8efb05df) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/PipingSoilProfileReaderTest.cs (.../PipingSoilProfileReaderTest.cs) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -22,6 +22,8 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Drawing; +using System.Globalization; using System.IO; using System.Linq; using Core.Common.IO.Exceptions; @@ -392,10 +394,61 @@ null, null }, profile.Layers.Select(l => l.DryUnitWeight)); + CollectionAssert.AreEqual(new [] + { + Color.FromArgb(128,255,128), + Color.FromArgb(255,0,0), + Color.FromArgb(70,130,180) + }, profile.Layers.Select(l => l.Color)); } } [Test] + public void ReadProfile_DatabaseWith2DProfile3Layers_ReturnsProfile() + { + // Setup + var testFile = "2dprofile.soil"; + var dbFile = Path.Combine(testDataPath, testFile); + using (var reader = new PipingSoilProfileReader(dbFile)) + { + // Call + var profile = reader.ReadProfile(); + + // Assert + CollectionAssert.AreEqual(new[] + { + true, + false, + false + }, profile.Layers.Select(l => l.IsAquifer)); + CollectionAssert.AreEqual(new[] + { + 0.001, + 0.001, + 0.001 + }, profile.Layers.Select(l => l.AbovePhreaticLevel)); + CollectionAssert.AreEqual(new[] + { + 0.001, + 0.001, + 0.001 + }, profile.Layers.Select(l => l.BelowPhreaticLevel)); + CollectionAssert.AreEqual(new double?[] + { + null, + null, + null + }, profile.Layers.Select(l => l.DryUnitWeight)); + CollectionAssert.AreEqual(new [] + { + Color.FromArgb(70,130,180), + Color.FromArgb(255,0,0), + Color.FromArgb(128,255,128) + }, profile.Layers.Select(l => l.Color)); + } + } + + [Test] public void Dispose_AfterConstruction_CorrectlyReleasesFile() { // Setup Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilLayerColorConversionHelperTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilLayerColorConversionHelperTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilLayerColorConversionHelperTest.cs (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -0,0 +1,40 @@ +using System.Drawing; +using NUnit.Framework; +using Ringtoets.Piping.IO.Builders; + +namespace Ringtoets.Piping.IO.Test.SoilProfile +{ + [TestFixture] + public class SoilLayerColorConversionHelperTest + { + [Test] + public void FromNullableDouble_Null_ReturnsEmptyColor() + { + // Call + var color = SoilLayerColorConversionHelper.ColorFromNullableDouble(null); + + // Assert + Assert.AreEqual(Color.Empty, color); + } + + [Test] + [TestCase(-12156236, 70, 130, 180)] + [TestCase(-8372160, 128, 64, 64)] + [TestCase(-65536, 255, 0, 0)] + [TestCase(-14634326, 32, 178, 170)] + [TestCase(-6632142, 154, 205, 50)] + [TestCase(-12566528, 64, 64, 0)] + [TestCase(-7278960, 144, 238, 144)] + [TestCase(-8323200, 128, 255, 128)] + [TestCase(-65281, 255, 0, 255)] + [TestCase(-8372224, 128, 64, 0)] + public void FromNullableDouble_DifferentDoubleValues_ReturnsExpectedColor(double colorValue, int r, int g, int b) + { + // Call + var color = SoilLayerColorConversionHelper.ColorFromNullableDouble(colorValue); + + // Assert + Assert.AreEqual(Color.FromArgb(r, g, b), color); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs =================================================================== diff -u -r3ab528e2b002824d82df7b45c2901c4f96fa148c -r49f905d3363336d44ef828259692644dcf5f9edc --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs (.../SoilProfile1DReaderTest.cs) (revision 3ab528e2b002824d82df7b45c2901c4f96fa148c) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs (.../SoilProfile1DReaderTest.cs) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -1,4 +1,5 @@ using System; +using System.Drawing; using System.Linq; using Core.Common.IO.Exceptions; using Core.Common.IO.Readers; @@ -83,7 +84,7 @@ const string profileName = ""; const string path = "A"; - SetExpectations(0, profileName, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0); + SetExpectations(0, profileName, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, string.Empty, 0); reader.Expect(r => r.Path).Return(path); mocks.ReplayAll(); @@ -111,7 +112,7 @@ reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(profileName); reader.Expect(r => r.Path).Return(path); reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1).Repeat.Any(); - reader.Expect(r => r.ReadOrNull(SoilProfileDatabaseColumns.IsAquifer)).Throw(new InvalidCastException()); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.IsAquifer)).Throw(new InvalidCastException()); mocks.ReplayAll(); // Call @@ -133,7 +134,7 @@ // Setup var bottom = 1.1; var top = 1.1; - SetExpectations(1, "", bottom, top, null, null, null, null); + SetExpectations(1, "", bottom, top, null, null, null, null, null, null); mocks.ReplayAll(); @@ -150,6 +151,8 @@ Assert.IsNull(pipingSoilLayer.BelowPhreaticLevel); Assert.IsNull(pipingSoilLayer.AbovePhreaticLevel); Assert.IsNull(pipingSoilLayer.DryUnitWeight); + Assert.IsNull(pipingSoilLayer.MaterialName); + Assert.AreEqual(Color.Empty, pipingSoilLayer.Color); Assert.IsFalse(pipingSoilLayer.IsAquifer); mocks.VerifyAll(); @@ -168,8 +171,10 @@ var dryUnitWeight = random.NextDouble(); var top = random.NextDouble(); var bottom = random.NextDouble(); + string materialName = "material"; + var color = Color.FromArgb(Color.DarkKhaki.ToArgb()); - SetExpectations(layerCount, "", bottom, top, 1.0, belowPhreaticLevel, abovePhreaticLevel, dryUnitWeight); + SetExpectations(layerCount, "", bottom, top, 1.0, belowPhreaticLevel, abovePhreaticLevel, dryUnitWeight, materialName, color.ToArgb()); mocks.ReplayAll(); @@ -187,19 +192,23 @@ Assert.AreEqual(abovePhreaticLevel, pipingSoilLayer.AbovePhreaticLevel); Assert.AreEqual(dryUnitWeight, pipingSoilLayer.DryUnitWeight); Assert.IsTrue(pipingSoilLayer.IsAquifer); + Assert.AreEqual(materialName, pipingSoilLayer.MaterialName); + Assert.AreEqual(color, pipingSoilLayer.Color); mocks.VerifyAll(); } - private void SetExpectations(int layerCount, string profileName, double bottom, double top, double? isAquifer, double? belowPhreaticLevel, double? abovePhreaticLevel, double? dryUnitWeight) + private void SetExpectations(int layerCount, string profileName, double bottom, double top, double? isAquifer, double? belowPhreaticLevel, double? abovePhreaticLevel, double? dryUnitWeight, string materialName, double? color) { reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(layerCount).Repeat.Any(); reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(profileName).Repeat.Any(); reader.Expect(r => r.Read(SoilProfileDatabaseColumns.Bottom)).Return(bottom).Repeat.Any(); reader.Expect(r => r.Read(SoilProfileDatabaseColumns.Top)).Return(top).Repeat.Any(); - reader.Expect(r => r.ReadOrNull(SoilProfileDatabaseColumns.IsAquifer)).Return(isAquifer).Repeat.Any(); - reader.Expect(r => r.ReadOrNull(SoilProfileDatabaseColumns.BelowPhreaticLevel)).Return(belowPhreaticLevel).Repeat.Any(); - reader.Expect(r => r.ReadOrNull(SoilProfileDatabaseColumns.AbovePhreaticLevel)).Return(abovePhreaticLevel).Repeat.Any(); - reader.Expect(r => r.ReadOrNull(SoilProfileDatabaseColumns.DryUnitWeight)).Return(dryUnitWeight).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.IsAquifer)).Return(isAquifer).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevel)).Return(belowPhreaticLevel).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.AbovePhreaticLevel)).Return(abovePhreaticLevel).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DryUnitWeight)).Return(dryUnitWeight).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.MaterialName)).Return(materialName).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.Color)).Return(color).Repeat.Any(); } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs =================================================================== diff -u -r3ab528e2b002824d82df7b45c2901c4f96fa148c -r49f905d3363336d44ef828259692644dcf5f9edc --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision 3ab528e2b002824d82df7b45c2901c4f96fa148c) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision 49f905d3363336d44ef828259692644dcf5f9edc) @@ -1,4 +1,5 @@ using System; +using System.Drawing; using System.Linq; using Core.Common.IO.Exceptions; using Core.Common.IO.Readers; @@ -116,7 +117,7 @@ const string path = "A"; reader.Expect(r => r.Path).Return(path); - SetExpectations(0, name, 0.0, 1.0, 0.0, 0.0, 0.0, new byte[0]); + SetExpectations(0, name, 0.0, 1.0, 0.0, 0.0, 0.0, new byte[0], string.Empty, 0); mocks.ReplayAll(); @@ -139,7 +140,7 @@ const string path = "A"; reader.Expect(r => r.Path).Return(path); - SetExpectations(1, name, 0.0, 1.0, 0.0, 0.0, 0.0, null); + SetExpectations(1, name, 0.0, 1.0, 0.0, 0.0, 0.0, null, string.Empty, 0); mocks.ReplayAll(); @@ -161,7 +162,7 @@ const string name = "cool name"; const string path = "A"; - SetExpectations(1, name, 0.0, 1.0, 0.0, 0.0, 0.0, new byte[0]); + SetExpectations(1, name, 0.0, 1.0, 0.0, 0.0, 0.0, new byte[0], string.Empty, 0); reader.Expect(r => r.Path).Return(path); mocks.ReplayAll(); @@ -187,7 +188,7 @@ reader.Expect(r => r.Path).Return(path); reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(name); reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1).Repeat.Any(); - reader.Expect(r => r.ReadOrNull(SoilProfileDatabaseColumns.IsAquifer)).Throw(new InvalidCastException()); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.IsAquifer)).Throw(new InvalidCastException()); mocks.ReplayAll(); // Call @@ -205,7 +206,7 @@ public void ReadFrom_NullValuesForLayer_ReturnsProfileWithNullValuesOnLayer() { // Setup - SetExpectations(1, "", 0.0, null, null, null, null, someGeometry); + SetExpectations(1, "", 0.0, null, null, null, null, someGeometry, null, null); mocks.ReplayAll(); @@ -223,6 +224,8 @@ Assert.IsNull(pipingSoilLayer.AbovePhreaticLevel); Assert.IsNull(pipingSoilLayer.DryUnitWeight); Assert.IsFalse(pipingSoilLayer.IsAquifer); + Assert.IsNull(pipingSoilLayer.MaterialName); + Assert.AreEqual(Color.Empty, pipingSoilLayer.Color); mocks.VerifyAll(); } @@ -239,8 +242,10 @@ var abovePhreaticLevel = random.NextDouble(); var dryUnitWeight = random.NextDouble(); var intersectionX = 0.5; + var materialName = "material"; + var color = Color.FromArgb(Color.AliceBlue.ToArgb()); - SetExpectations(layerCount, "", intersectionX, 1.0, belowPhreaticLevel, abovePhreaticLevel, dryUnitWeight, someGeometry); + SetExpectations(layerCount, "", intersectionX, 1.0, belowPhreaticLevel, abovePhreaticLevel, dryUnitWeight, someGeometry, materialName, color.ToArgb()); mocks.ReplayAll(); @@ -258,18 +263,22 @@ Assert.AreEqual(abovePhreaticLevel, pipingSoilLayer.AbovePhreaticLevel); Assert.AreEqual(dryUnitWeight, pipingSoilLayer.DryUnitWeight); Assert.IsTrue(pipingSoilLayer.IsAquifer); + Assert.AreEqual(materialName, pipingSoilLayer.MaterialName); + Assert.AreEqual(color, pipingSoilLayer.Color); mocks.VerifyAll(); } - private void SetExpectations(int layerCount, string profileName, double intersectionX, double? isAquifer, double? belowPhreaticLevel, double? abovePhreaticLevel, double? dryUnitWeight, byte[] geometry) + private void SetExpectations(int layerCount, string profileName, double intersectionX, double? isAquifer, double? belowPhreaticLevel, double? abovePhreaticLevel, double? dryUnitWeight, byte[] geometry, string materialName, double? color) { reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(layerCount).Repeat.Any(); reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(profileName).Repeat.Any(); reader.Expect(r => r.Read(SoilProfileDatabaseColumns.IntersectionX)).Return(intersectionX).Repeat.Any(); - reader.Expect(r => r.ReadOrNull(SoilProfileDatabaseColumns.IsAquifer)).Return(isAquifer).Repeat.Any(); - reader.Expect(r => r.ReadOrNull(SoilProfileDatabaseColumns.BelowPhreaticLevel)).Return(belowPhreaticLevel).Repeat.Any(); - reader.Expect(r => r.ReadOrNull(SoilProfileDatabaseColumns.AbovePhreaticLevel)).Return(abovePhreaticLevel).Repeat.Any(); - reader.Expect(r => r.ReadOrNull(SoilProfileDatabaseColumns.DryUnitWeight)).Return(dryUnitWeight).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.IsAquifer)).Return(isAquifer).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.BelowPhreaticLevel)).Return(belowPhreaticLevel).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.AbovePhreaticLevel)).Return(abovePhreaticLevel).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.DryUnitWeight)).Return(dryUnitWeight).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.MaterialName)).Return(materialName).Repeat.Any(); + reader.Expect(r => r.ReadOrDefault(SoilProfileDatabaseColumns.Color)).Return(color).Repeat.Any(); reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerGeometry)).Return(geometry).Repeat.Any(); } Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingSoilProfilesReader/1dprofile.soil =================================================================== diff -u -r17651988db014bcbf2059c03ba0aef438f79bec4 -r49f905d3363336d44ef828259692644dcf5f9edc Binary files differ Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/test-data/PipingSoilProfilesReader/2dprofile.soil =================================================================== diff -u Binary files differ