Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingSoilProfile.cs =================================================================== diff -u -r069921ae1e06e13d8e5e19dd9caa5e8f7b9e1f35 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingSoilProfile.cs (.../PipingSoilProfile.cs) (revision 069921ae1e06e13d8e5e19dd9caa5e8f7b9e1f35) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingSoilProfile.cs (.../PipingSoilProfile.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -20,7 +20,8 @@ /// The name of the profile. /// The bottom level of the profile. /// The collection of layers that should be part of the profile. - /// Thrown when is null or contains no layers. + /// Thrown when contains no layers. + /// Thrown when is null. public PipingSoilProfile(string name, double bottom, IEnumerable layers) { Name = name; @@ -42,7 +43,8 @@ /// Gets an ordered (by , descending) of /// for the . /// - /// Thrown when the value is null or contains no layers. + /// Thrown when the value is null. + /// Thrown when the value contains no layers. public IEnumerable Layers { get @@ -51,8 +53,12 @@ } private set { - if (value == null || !value.Any()) + if (value == null) { + throw new ArgumentNullException(@"value", string.Format(Resources.Error_Cannot_Construct_PipingSoilProfile_Without_Layers)); + } + if(!value.Any()) + { throw new ArgumentException(string.Format(Resources.Error_Cannot_Construct_PipingSoilProfile_Without_Layers)); } layers = value.OrderByDescending(l => l.Top).ToArray(); Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.Designer.cs =================================================================== diff -u -r7906ab33fe161cecffe7fd086d3a8cc824829aef -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 7906ab33fe161cecffe7fd086d3a8cc824829aef) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -115,6 +115,15 @@ } /// + /// Looks up a localized string similar to Een punt in de geometrie voor de dwarsdoorsnede heeft geen waarde.. + /// + internal static string RingtoetsPipingSurfaceLine_A_point_in_the_collection_was_null { + get { + return ResourceManager.GetString("RingtoetsPipingSurfaceLine_A_point_in_the_collection_was_null", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Kan geen hoogte bepalen op het punt L={0}, omdate de dwarsdoorsnede verticaal loopt op dat punt.. /// internal static string RingtoetsPipingSurfaceLine_Cannot_determine_reliable_z_when_surface_line_is_vertical_in_l { @@ -125,6 +134,15 @@ } /// + /// Looks up a localized string similar to De geometrie die opgegeven werd voor de dwarsdoorsnede heeft geen waarde.. + /// + internal static string RingtoetsPipingSurfaceLine_Collection_of_points_for_geometry_is_null { + get { + return ResourceManager.GetString("RingtoetsPipingSurfaceLine_Collection_of_points_for_geometry_is_null", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Voor het maken van een segment zijn twee punten nodig.. /// internal static string Segment2D_Constructor_Segment_must_be_created_with_two_points { Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.resx =================================================================== diff -u -r7906ab33fe161cecffe7fd086d3a8cc824829aef -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.resx (.../Resources.resx) (revision 7906ab33fe161cecffe7fd086d3a8cc824829aef) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Properties/Resources.resx (.../Resources.resx) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -144,4 +144,10 @@ Kan geen hoogte bepalen op het punt L={0}, omdate de dwarsdoorsnede verticaal loopt op dat punt. + + Een punt in de geometrie voor de dwarsdoorsnede heeft geen waarde. + + + De geometrie die opgegeven werd voor de dwarsdoorsnede heeft geen waarde. + \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/RingtoetsPipingSurfaceLine.cs =================================================================== diff -u -r712a020ea0330ece24849c2710641c1ce399ed61 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/src/Ringtoets.Piping.Data/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision 712a020ea0330ece24849c2710641c1ce399ed61) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -56,8 +56,17 @@ /// Sets the geometry of the surfaceline. /// /// The collection of points defining the surfaceline geometry. + /// Thrown when any of the has no value (== null). public void SetGeometry(IEnumerable points) { + if (points == null) + { + throw new ArgumentNullException("points", Resources.RingtoetsPipingSurfaceLine_Collection_of_points_for_geometry_is_null); + } + if (points.Any(p => p == null)) + { + throw new ArgumentException(Resources.RingtoetsPipingSurfaceLine_A_point_in_the_collection_was_null); + } geometryPoints = points.ToArray(); if (geometryPoints.Length > 0) @@ -80,7 +89,7 @@ var segments = new Collection(); for (int i = 1; i < projectGeometryToLz.Length; i++) { - segments.Add(new Segment2D(projectGeometryToLz[i-1], projectGeometryToLz[i])); + segments.Add(new Segment2D(projectGeometryToLz[i - 1], projectGeometryToLz[i])); } var intersectionPoints = Math2D.SegmentsIntersectionWithVerticalLine(segments, l).OrderBy(p => p.Y).ToArray(); Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/Segment2D.cs =================================================================== diff -u -r712a020ea0330ece24849c2710641c1ce399ed61 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/src/Ringtoets.Piping.Data/Segment2D.cs (.../Segment2D.cs) (revision 712a020ea0330ece24849c2710641c1ce399ed61) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/Segment2D.cs (.../Segment2D.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -14,14 +14,18 @@ /// /// The first of the . /// The second of the . - /// Thrown when either the or + /// Thrown when either the or /// point is null. public Segment2D(Point2D first, Point2D second) { - if (first == null || second == null) + if (first == null) { - throw new ArgumentException(Resources.Segment2D_Constructor_Segment_must_be_created_with_two_points); + throw new ArgumentNullException("first",Resources.Segment2D_Constructor_Segment_must_be_created_with_two_points); } + if (second == null) + { + throw new ArgumentNullException("second",Resources.Segment2D_Constructor_Segment_must_be_created_with_two_points); + } FirstPoint = first; SecondPoint = second; } Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder1D.cs =================================================================== diff -u -r069921ae1e06e13d8e5e19dd9caa5e8f7b9e1f35 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder1D.cs (.../SoilProfileBuilder1D.cs) (revision 069921ae1e06e13d8e5e19dd9caa5e8f7b9e1f35) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder1D.cs (.../SoilProfileBuilder1D.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -7,7 +7,7 @@ /// /// Helps in the creation of a . /// - public class SoilProfileBuilder1D + internal class SoilProfileBuilder1D { private readonly Collection layers; private readonly string name; @@ -24,10 +24,17 @@ /// Creates a new instances of the based on the layer definitions. /// /// A new . - /// Thrown when no layers have been added through . - public PipingSoilProfile Build() + /// Thrown when no layers have been added through . + internal PipingSoilProfile Build() { - return new PipingSoilProfile(name, bottom, layers); + try + { + return new PipingSoilProfile(name, bottom, layers); + } + catch (ArgumentException e) + { + throw new SoilProfileBuilderException(e.Message, e); + } } /// Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder2D.cs =================================================================== diff -u -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder2D.cs (.../SoilProfileBuilder2D.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder2D.cs (.../SoilProfileBuilder2D.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -29,7 +29,8 @@ { if (double.IsNaN(atX)) { - throw new ArgumentException(Resources.Error_SoilProfileBuilder_cant_determine_intersect_at_double_NaN); + var message = string.Format(Resources.Error_SoilProfileBuilder_cant_determine_intersect_at_double_NaN , profileName); + throw new ArgumentException(message); } this.profileName = profileName; this.atX = atX; @@ -43,7 +44,7 @@ /// Thrown when trying to build a /// and not having added any layers using . /// - public PipingSoilProfile Build() + internal PipingSoilProfile Build() { try { Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Exceptions/PipingSoilProfileReadException.cs =================================================================== diff -u -r069921ae1e06e13d8e5e19dd9caa5e8f7b9e1f35 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Exceptions/PipingSoilProfileReadException.cs (.../PipingSoilProfileReadException.cs) (revision 069921ae1e06e13d8e5e19dd9caa5e8f7b9e1f35) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Exceptions/PipingSoilProfileReadException.cs (.../PipingSoilProfileReadException.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -9,6 +9,8 @@ /// public class PipingSoilProfileReadException : Exception { + private readonly string ProfileNameKey = "ProfileName"; + /// /// Initializes a new instance of the class. /// @@ -47,6 +49,16 @@ /// /// The name of the profile for which this exception was thrown. /// - public string ProfileName { get; private set; } + public string ProfileName + { + get + { + return (string)Data[ProfileNameKey]; + } + private set + { + Data[ProfileNameKey] = value; + } + } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj =================================================================== diff -u -r79b1cdcf9dcdbe4c015f5fc6b42605a00386b120 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 79b1cdcf9dcdbe4c015f5fc6b42605a00386b120) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -61,7 +61,7 @@ - + Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/CriticalProfileProperties.cs =================================================================== diff -u -r069921ae1e06e13d8e5e19dd9caa5e8f7b9e1f35 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/CriticalProfileProperties.cs (.../CriticalProfileProperties.cs) (revision 069921ae1e06e13d8e5e19dd9caa5e8f7b9e1f35) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/CriticalProfileProperties.cs (.../CriticalProfileProperties.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -4,20 +4,21 @@ namespace Ringtoets.Piping.IO.SoilProfile { + /// + /// This class describes properties which are critical when reading soil profiles from a data source. + /// If obtaining properties could not be obtained, then it is impossible to guarantee a correct import. + /// internal class CriticalProfileProperties { - internal readonly string ProfileName; - internal readonly long LayerCount; - /// /// Creates a new instance of , which contains properties /// that are critical for reading profiles. If these properties cannot be read, then something /// went wrong while querying the database. /// - /// + /// The from which to obtain the critical properties. /// Thrown when the values in the database could not be /// casted to the expected column types. - internal CriticalProfileProperties(IRowBasedReader reader) + internal CriticalProfileProperties(IRowBasedDatabaseReader reader) { try { @@ -29,5 +30,15 @@ throw new CriticalFileReadException(Resources.PipingSoilProfileReader_Critical_Unexpected_value_on_column, e); } } + + /// + /// The name of the profile to read + /// + internal string ProfileName { get; private set; } + + /// + /// The number of layers that the profile to read has + /// + internal long LayerCount { get; private set; } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/IRowBasedDatabaseReader.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/IRowBasedDatabaseReader.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/IRowBasedDatabaseReader.cs (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -0,0 +1,35 @@ +using System; +using Ringtoets.Piping.IO.Exceptions; + +namespace Ringtoets.Piping.IO.SoilProfile +{ + /// + /// This interface can be used for data bases to implement a row/column based way of reading records. + /// + internal interface IRowBasedDatabaseReader + { + /// + /// Moves the reader to the next record in the database. + /// + void MoveNext(); + + /// + /// Reads a value at column from the database. + /// + /// The expected type of value in the column with name . + /// The name of the column to read from. + /// The read value from the column with name . + /// Thrown when the value in the column was not of type . + T Read(string columnName); + + /// + /// Reads the value in the column with name from the + /// current row that's being pointed at. + /// + /// 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; + } +} \ No newline at end of file Fisheye: Tag d2b5b334c49948fa49297a1d24c13bc98aa6ee1e refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/IRowBasedReader.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs =================================================================== diff -u -r1efcd2277f5a38d44a78e4a9286eec35134fe8dd -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision 1efcd2277f5a38d44a78e4a9286eec35134fe8dd) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -11,7 +11,7 @@ /// /// This class reads a SqLite database file and constructs instances from this database. /// - public class PipingSoilProfileReader : IRowBasedReader, IDisposable + public class PipingSoilProfileReader : IRowBasedDatabaseReader, IDisposable { private const string databaseRequiredVersion = "15.0.5.0"; private const string pipingMechanismName = "Piping"; Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilLayer2DReader.cs =================================================================== diff -u -r069921ae1e06e13d8e5e19dd9caa5e8f7b9e1f35 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilLayer2DReader.cs (.../SoilLayer2DReader.cs) (revision 069921ae1e06e13d8e5e19dd9caa5e8f7b9e1f35) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilLayer2DReader.cs (.../SoilLayer2DReader.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -147,7 +147,7 @@ segment = new Segment2D(points[0], points[1]); return true; } - catch (ArgumentException e) + catch (ArgumentNullException e) { throw new SoilLayer2DConversionException(Resources.SoilLayer2DReader_Geometry_contains_no_valid_xml, e); } Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile1DReader.cs =================================================================== diff -u -ra6ba313236d0ff8d2f219fc8249b700b1eade338 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile1DReader.cs (.../SoilProfile1DReader.cs) (revision a6ba313236d0ff8d2f219fc8249b700b1eade338) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile1DReader.cs (.../SoilProfile1DReader.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -16,25 +16,27 @@ /// /// Reads a 1D profile from the given . /// - /// A which is used to read row values from. + /// A which is used to read row values from. /// A new , which is based on the information from the database. /// Thrown when reading the profile encountered an unrecoverable error. /// Thrown when reading the profile encountered a recoverable error. - internal static PipingSoilProfile ReadFrom(IRowBasedReader reader) + internal static PipingSoilProfile ReadFrom(IRowBasedDatabaseReader reader) { var criticalProperties = new CriticalProfileProperties(reader); - var requiredProperties = new RequiredProfileProperties(reader, criticalProperties.ProfileName); - var soilProfileBuilder = new SoilProfileBuilder1D(criticalProperties.ProfileName, requiredProperties.Bottom); + var profileName = criticalProperties.ProfileName; + var requiredProperties = new RequiredProfileProperties(reader, profileName); + var soilProfileBuilder = new SoilProfileBuilder1D(profileName, requiredProperties.Bottom); + for (var i = 1; i <= criticalProperties.LayerCount; i++) { - SoilLayer1D soilLayer = ReadSoilLayerFrom(reader, criticalProperties.ProfileName); + SoilLayer1D soilLayer = ReadSoilLayerFrom(reader, profileName); soilProfileBuilder.Add(soilLayer.AsPipingSoilLayer()); reader.MoveNext(); } - return Build(soilProfileBuilder, criticalProperties.ProfileName); + return Build(soilProfileBuilder, profileName); } /// @@ -47,7 +49,7 @@ { return soilProfileBuilder.Build(); } - catch (ArgumentException e) + catch (SoilProfileBuilderException e) { throw new PipingSoilProfileReadException(profileName, e.Message, e); } @@ -57,7 +59,7 @@ /// Reads a from the given . /// /// Thrown when reading properties of the layers failed. - private static SoilLayer1D ReadSoilLayerFrom(IRowBasedReader reader, string profileName) + private static SoilLayer1D ReadSoilLayerFrom(IRowBasedDatabaseReader reader, string profileName) { var properties = new LayerProperties(reader, profileName); @@ -84,7 +86,7 @@ /// The profile name used in generating exceptions messages if casting failed. /// Thrown when the values in the database could not be /// casted to the expected column types. - internal RequiredProfileProperties(IRowBasedReader reader, string profileName) + internal RequiredProfileProperties(IRowBasedDatabaseReader reader, string profileName) { string readColumn = SoilProfileDatabaseColumns.Bottom; try @@ -116,7 +118,7 @@ /// The profile name used in generating exceptions messages if casting failed. /// Thrown when the values in the database could not be /// casted to the expected column types. - internal LayerProperties(IRowBasedReader reader, string profileName) + internal LayerProperties(IRowBasedDatabaseReader reader, string profileName) { string readColumn = SoilProfileDatabaseColumns.Top; try Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs =================================================================== diff -u -rabafce00e4098c8041a52f62b3f174c615cf890d -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs (.../SoilProfile2DReader.cs) (revision abafce00e4098c8041a52f62b3f174c615cf890d) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs (.../SoilProfile2DReader.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -16,7 +16,7 @@ /// /// Reads information for a profile from the database and creates a based on the information. /// - /// A which is used to read row values from. + /// A which is used to read row values from. /// A new , which is based on the information from the database. /// Thrown when reading the profile encountered an unrecoverable error. /// Thrown when @@ -27,7 +27,7 @@ /// unexpected values were encountered for layer properties /// /// - internal static PipingSoilProfile ReadFrom(IRowBasedReader reader) + internal static PipingSoilProfile ReadFrom(IRowBasedDatabaseReader reader) { var criticalProperties = new CriticalProfileProperties(reader); var requiredProperties = new RequiredProfileProperties(reader, criticalProperties.ProfileName); @@ -66,7 +66,7 @@ /// A column for a layer property did not contain a value of the expected type. /// Thrown when the read geometry does not contain segments that form form a loop for either the inner or outer loop. /// - private static SoilLayer2D ReadPiping2DSoilLayer(IRowBasedReader reader, string profileName) + private static SoilLayer2D ReadPiping2DSoilLayer(IRowBasedDatabaseReader reader, string profileName) { var properties = new LayerProperties(reader, profileName); @@ -97,7 +97,7 @@ /// The to read the geometry value from. /// The profile name used in generating exceptions messages if casting failed. /// - private static byte[] ReadGeometryFrom(IRowBasedReader reader, string profileName) + private static byte[] ReadGeometryFrom(IRowBasedDatabaseReader reader, string profileName) { try { @@ -128,7 +128,7 @@ /// The profile name used in generating exceptions messages if casting failed. /// Thrown when the values in the database could not be /// casted to the expected column types. - internal RequiredProfileProperties(IRowBasedReader reader, string profileName) + internal RequiredProfileProperties(IRowBasedDatabaseReader reader, string profileName) { string readColumn = SoilProfileDatabaseColumns.IntersectionX; try @@ -159,7 +159,7 @@ /// The profile name used in generating exceptions messages if casting failed. /// Thrown when the values in the database could not be /// casted to the expected column types. - internal LayerProperties(IRowBasedReader reader, string profileName) + internal LayerProperties(IRowBasedDatabaseReader reader, string profileName) { string readColumn = SoilProfileDatabaseColumns.IsAquifer; try Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfileDatabaseColumns.cs =================================================================== diff -u -r069921ae1e06e13d8e5e19dd9caa5e8f7b9e1f35 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfileDatabaseColumns.cs (.../SoilProfileDatabaseColumns.cs) (revision 069921ae1e06e13d8e5e19dd9caa5e8f7b9e1f35) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfileDatabaseColumns.cs (.../SoilProfileDatabaseColumns.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -1,18 +1,21 @@ namespace Ringtoets.Piping.IO.SoilProfile { - public static class SoilProfileDatabaseColumns + /// + /// This class contains the column names that are used when querying the DSoil-Model database. + /// + internal static class SoilProfileDatabaseColumns { - public const string ProfileCount = "ProfileCount"; - public const string Dimension = "Dimension"; - public const string IsAquifer = "IsAquifer"; - public const string ProfileName = "ProfileName"; - public const string IntersectionX = "IntersectionX"; - public const string Bottom = "Bottom"; - public const string Top = "Top"; - public const string LayerGeometry = "LayerGeometry"; - public const string AbovePhreaticLevel = "AbovePhreaticLevel"; - public const string BelowPhreaticLevel = "BelowPhreaticLevel"; - public const string DryUnitWeight = "DryUnitWeight"; - public const string LayerCount = "LayerCount"; + internal const string ProfileCount = "ProfileCount"; + internal const string Dimension = "Dimension"; + internal const string IsAquifer = "IsAquifer"; + internal const string ProfileName = "ProfileName"; + internal const string IntersectionX = "IntersectionX"; + internal const string Bottom = "Bottom"; + internal const string Top = "Top"; + internal const string LayerGeometry = "LayerGeometry"; + internal const string AbovePhreaticLevel = "AbovePhreaticLevel"; + internal const string BelowPhreaticLevel = "BelowPhreaticLevel"; + internal const string DryUnitWeight = "DryUnitWeight"; + internal const string LayerCount = "LayerCount"; } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilProfileTest.cs =================================================================== diff -u -r2a49b7243807fe0b95136efd55652201164a6c74 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilProfileTest.cs (.../PipingSoilProfileTest.cs) (revision 2a49b7243807fe0b95136efd55652201164a6c74) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilProfileTest.cs (.../PipingSoilProfileTest.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -44,14 +44,14 @@ } [Test] - public void Constructor_WithNameBottomLayersNull_ThrowsArgumentException() + public void Constructor_WithNameBottomLayersNull_ThrowsArgumentNullException() { // Call TestDelegate test = () => new PipingSoilProfile(String.Empty, Double.NaN, null); // Assert - var message = Assert.Throws(test).Message; - Assert.AreEqual(Properties.Resources.Error_Cannot_Construct_PipingSoilProfile_Without_Layers, message); + var message = Assert.Throws(test).Message; + StringAssert.StartsWith(Properties.Resources.Error_Cannot_Construct_PipingSoilProfile_Without_Layers, message); } [Test] Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs =================================================================== diff -u -r712a020ea0330ece24849c2710641c1ce399ed61 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs (.../RingtoetsPipingSurfaceLineTest.cs) (revision 712a020ea0330ece24849c2710641c1ce399ed61) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs (.../RingtoetsPipingSurfaceLineTest.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; - using NUnit.Framework; using Ringtoets.Piping.Data.Exceptions; @@ -180,6 +179,34 @@ } [Test] + public void SetGeometry_GeometryIsNull_ThrowsArgumentNullException() + { + // Setup + var surfaceLine = new RingtoetsPipingSurfaceLine(); + + // Call + TestDelegate test = () => surfaceLine.SetGeometry(null); + + // Assert + var exception = Assert.Throws(test); + StringAssert.StartsWith(Properties.Resources.RingtoetsPipingSurfaceLine_Collection_of_points_for_geometry_is_null, exception.Message); + } + + [Test] + public void SetGeometry_GeometryContainsNullPoint_ThrowsArgumentException() + { + // Setup + var surfaceLine = new RingtoetsPipingSurfaceLine(); + + // Call + TestDelegate test = () => surfaceLine.SetGeometry(new Point3D[] { null }); + + // Assert + var exception = Assert.Throws(test); + StringAssert.StartsWith(Properties.Resources.RingtoetsPipingSurfaceLine_A_point_in_the_collection_was_null, exception.Message); + } + + [Test] public void GetZAtL_SurfaceLineVerticalAtL_ThrowsRingtoetsPipingSurfaceLineException() { // Setup Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Segment2DTest.cs =================================================================== diff -u -r712a020ea0330ece24849c2710641c1ce399ed61 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Segment2DTest.cs (.../Segment2DTest.cs) (revision 712a020ea0330ece24849c2710641c1ce399ed61) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/Segment2DTest.cs (.../Segment2DTest.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -1,5 +1,6 @@ using System; using NUnit.Framework; +using Ringtoets.Piping.Data.Properties; namespace Ringtoets.Piping.Data.Test { @@ -9,9 +10,11 @@ [Test] public void Constructor_WithTwoPoints_ReturnsSegmentWithPointsSet() { - // Call + // Setup var firstPoint = new Point2D(); var secondPoint = new Point2D(); + + // Call var segment = new Segment2D(firstPoint, secondPoint); // Assert @@ -20,6 +23,36 @@ } [Test] + public void Constructor_WithNullFirstPoint_ThrowsArgumentNullException() + { + // Setup + var firstPoint = new Point2D(); + var secondPoint = new Point2D(); + + // Call + TestDelegate test = () => new Segment2D(null, secondPoint); + + // Assert + var exception = Assert.Throws(test); + StringAssert.StartsWith(Resources.Segment2D_Constructor_Segment_must_be_created_with_two_points, exception.Message); + } + + [Test] + public void Constructor_WithNullSecondPoint_ThrowsArgumentNullException() + { + // Setup + var firstPoint = new Point2D(); + var secondPoint = new Point2D(); + + // Call + TestDelegate test = () => new Segment2D(firstPoint, null); + + // Assert + var exception = Assert.Throws(test); + StringAssert.StartsWith(Resources.Segment2D_Constructor_Segment_must_be_created_with_two_points, exception.Message); + } + + [Test] [TestCase(1, 2, 1.5, true)] [TestCase(1, 2, 1 + 1e-6, true)] [TestCase(1, 2, 2 - 1e-6, true)] Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilProfileBuilder1DTest.cs =================================================================== diff -u -r2a49b7243807fe0b95136efd55652201164a6c74 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilProfileBuilder1DTest.cs (.../SoilProfileBuilder1DTest.cs) (revision 2a49b7243807fe0b95136efd55652201164a6c74) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilProfileBuilder1DTest.cs (.../SoilProfileBuilder1DTest.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -9,7 +9,7 @@ public class SoilProfileBuilder1DTest { [Test] - public void Build_WithOutLayers_ThrowsArgumentException() + public void Build_WithOutLayers_ThrowsSoilProfileBuilderException() { // Setup var profileName = "SomeProfile"; @@ -19,7 +19,7 @@ TestDelegate test = () => builder.Build(); // Assert - Assert.Throws(test); + Assert.Throws(test); } [Test] Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilProfileBuilder2DTest.cs =================================================================== diff -u -rc664c0529925f2d316a81a4d496bcd98531ae4d6 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilProfileBuilder2DTest.cs (.../SoilProfileBuilder2DTest.cs) (revision c664c0529925f2d316a81a4d496bcd98531ae4d6) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilProfileBuilder2DTest.cs (.../SoilProfileBuilder2DTest.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -23,7 +23,8 @@ // Assert var exception = Assert.Throws(test); - Assert.AreEqual(Resources.Error_SoilProfileBuilder_cant_determine_intersect_at_double_NaN, exception.Message); + var message = string.Format(Resources.Error_SoilProfileBuilder_cant_determine_intersect_at_double_NaN, name); + Assert.AreEqual(message, exception.Message); } [Test] Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/CriticalProfilePropertiesTest.cs =================================================================== diff -u -ra6ba313236d0ff8d2f219fc8249b700b1eade338 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/CriticalProfilePropertiesTest.cs (.../CriticalProfilePropertiesTest.cs) (revision a6ba313236d0ff8d2f219fc8249b700b1eade338) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/CriticalProfilePropertiesTest.cs (.../CriticalProfilePropertiesTest.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -22,7 +22,7 @@ public void Constructor_WithReaderValuesValid_SetProperties() { // Setup - var reader = mocks.StrictMock(); + var reader = mocks.StrictMock(); string profileName = "profile"; var layerCount = 1; @@ -45,7 +45,7 @@ public void Constructor_WithReaderInvalidProfileName_SetProperties() { // Setup - var reader = mocks.StrictMock(); + var reader = mocks.StrictMock(); var layerCount = 1; var invalidCastException = new InvalidCastException(); @@ -69,7 +69,7 @@ public void Constructor_WithReaderInvalidLayerCount_SetProperties() { // Setup - var reader = mocks.StrictMock(); + var reader = mocks.StrictMock(); string profileName = "profile"; var invalidCastException = new InvalidCastException(); Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs =================================================================== diff -u -rabafce00e4098c8041a52f62b3f174c615cf890d -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs (.../SoilProfile1DReaderTest.cs) (revision abafce00e4098c8041a52f62b3f174c615cf890d) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs (.../SoilProfile1DReaderTest.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -11,13 +11,13 @@ public class SoilProfile1DReaderTest { private MockRepository mocks; - private IRowBasedReader reader; + private IRowBasedDatabaseReader reader; [SetUp] public void SetUp() { mocks = new MockRepository(); - reader = mocks.DynamicMock(); + reader = mocks.DynamicMock(); } [Test] @@ -32,7 +32,8 @@ TestDelegate test = () => SoilProfile1DReader.ReadFrom(reader); // Assert - Assert.Throws(test); + var exception = Assert.Throws(test); + Assert.AreEqual("Kritieke fout opgetreden bij het uitlezen van waardes uit kolommen in de database.", exception.Message); mocks.VerifyAll(); } @@ -51,7 +52,8 @@ TestDelegate test = () => SoilProfile1DReader.ReadFrom(reader); // Assert - Assert.Throws(test); + var exception = Assert.Throws(test); + Assert.AreEqual("Ondergrondprofiel '' in database bevat geen geldige waarde in kolom 'Bottom'.", exception.Message); mocks.VerifyAll(); } @@ -68,7 +70,8 @@ TestDelegate test = () => SoilProfile1DReader.ReadFrom(reader); // Assert - Assert.Throws(test); + var exception = Assert.Throws(test); + Assert.AreEqual("Geen lagen gevonden voor het profiel.", exception.Message); mocks.VerifyAll(); } @@ -85,7 +88,8 @@ TestDelegate test = () => SoilProfile1DReader.ReadFrom(reader); // Assert - Assert.Throws(test); + var exception = Assert.Throws(test); + Assert.AreEqual("Ondergrondprofiel '' in database bevat geen geldige waarde in kolom 'IsAquifer'.", exception.Message); mocks.VerifyAll(); } Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs =================================================================== diff -u -rabafce00e4098c8041a52f62b3f174c615cf890d -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision abafce00e4098c8041a52f62b3f174c615cf890d) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -12,7 +12,7 @@ public class SoilProfile2DReaderTest { private MockRepository mocks; - private IRowBasedReader reader; + private IRowBasedDatabaseReader reader; private readonly byte[] someGeometry = StringGeometryHelper.GetBytes("" + "" + @@ -27,7 +27,7 @@ public void SetUp() { mocks = new MockRepository(); - reader = mocks.DynamicMock(); + reader = mocks.DynamicMock(); } [Test] @@ -42,7 +42,8 @@ TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader); // Assert - Assert.Throws(test); + var exception = Assert.Throws(test); + Assert.AreEqual("Kritieke fout opgetreden bij het uitlezen van waardes uit kolommen in de database.", exception.Message); mocks.VerifyAll(); } @@ -61,7 +62,8 @@ TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader); // Assert - Assert.Throws(test); + var exception = Assert.Throws(test); + Assert.AreEqual("Ondergrondprofiel '' in database bevat geen geldige waarde in kolom 'IntersectionX'.", exception.Message); mocks.VerifyAll(); } @@ -70,8 +72,10 @@ public void ReadFrom_DoubleNaNIntersectionX_ThrowsPipingSoilProfileReadException() { // Setup + string name = "profile"; + reader.Expect(r => r.Read(SoilProfileDatabaseColumns.LayerCount)).Return(1).Repeat.Any(); - reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return("").Repeat.Any(); + reader.Expect(r => r.Read(SoilProfileDatabaseColumns.ProfileName)).Return(name).Repeat.Any(); reader.Expect(r => r.Read(SoilProfileDatabaseColumns.IntersectionX)).Return(double.NaN); mocks.ReplayAll(); @@ -80,7 +84,9 @@ TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader); // Assert - Assert.Throws(test); + var exception = Assert.Throws(test); + var expectedMessage = string.Format("Geen geldige X waarde gevonden om intersectie te maken uit 2D profiel '{0}'.", name); + Assert.AreEqual(expectedMessage, exception.Message); mocks.VerifyAll(); } @@ -97,7 +103,8 @@ TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader); // Assert - Assert.Throws(test); + var exception = Assert.Throws(test); + Assert.AreEqual("Geen lagen gevonden voor het profiel.", exception.Message); mocks.VerifyAll(); } @@ -116,7 +123,8 @@ TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader); // Assert - Assert.Throws(test); + var exception = Assert.Throws(test); + Assert.AreEqual("Het XML-document dat de geometrie beschrijft voor de laag is niet geldig.", exception.Message); mocks.VerifyAll(); } @@ -133,7 +141,8 @@ TestDelegate test = () => SoilProfile2DReader.ReadFrom(reader); // Assert - Assert.Throws(test); + var exception = Assert.Throws(test); + Assert.AreEqual("Ondergrondprofiel '' in database bevat geen geldige waarde in kolom 'IsAquifer'.", exception.Message); mocks.VerifyAll(); } Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/TestHelpers/DoubleWithToleranceComparer.cs =================================================================== diff -u -rf69d756f50ae1464a1a11f0780b6d6aa646f3114 -rd2b5b334c49948fa49297a1d24c13bc98aa6ee1e --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/TestHelpers/DoubleWithToleranceComparer.cs (.../DoubleWithToleranceComparer.cs) (revision f69d756f50ae1464a1a11f0780b6d6aa646f3114) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/TestHelpers/DoubleWithToleranceComparer.cs (.../DoubleWithToleranceComparer.cs) (revision d2b5b334c49948fa49297a1d24c13bc98aa6ee1e) @@ -1,10 +1,15 @@ using System; using System.Collections; +using System.Collections.Generic; using Ringtoets.Piping.Data; namespace Ringtoets.Piping.IO.Test.TestHelpers { - public class DoubleWithToleranceComparer : IComparer + /// + /// This class can be used to compare doubles with a given tolerance, which can be useful to overcome double precision + /// errors. + /// + public class DoubleWithToleranceComparer : IComparer, IComparer { private readonly double tolerance; @@ -13,7 +18,7 @@ this.tolerance = tolerance; } - private int Compare(double firstDouble, double secondDouble) + public int Compare(double firstDouble, double secondDouble) { var diff = firstDouble - secondDouble;