Fisheye: Tag 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/ISoilProfileBuilder.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer2D.cs
===================================================================
diff -u -r6692dc3480971fe1c017aef633382c40eb37056f -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer2D.cs (.../SoilLayer2D.cs) (revision 6692dc3480971fe1c017aef633382c40eb37056f)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilLayer2D.cs (.../SoilLayer2D.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -57,7 +57,9 @@
///
/// The point from which to take a 1D profile.
/// The bottom level of the .
- ///
+ /// A of .
+ /// Thrown when any of the or
+ /// contain a vertical line at .
internal IEnumerable AsPipingSoilLayers(double atX, out double bottom)
{
bottom = Double.MaxValue;
@@ -143,6 +145,16 @@
return result;
}
+ ///
+ /// Gets a of heights where the intersects the
+ /// vertical line at .
+ ///
+ /// The of which together create a loop.
+ /// The point on the x-axis where the vertical line is constructed do determine intersections with.
+ /// A of , representing the height at which the
+ /// intersects the vertical line at .
+ /// Thrown when a segment is vertical at and thus
+ /// no deterministic intersection points can be determined.
private Collection GetLoopIntersectionHeights(HashSet loop, double atX)
{
Collection intersectionPointY = new Collection();
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder1D.cs
===================================================================
diff -u -ra950714ad9510756331d862aa35695fa0b2ed03b -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder1D.cs (.../SoilProfileBuilder1D.cs) (revision a950714ad9510756331d862aa35695fa0b2ed03b)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder1D.cs (.../SoilProfileBuilder1D.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -6,33 +6,35 @@
///
/// Helps in the creation of a .
///
- public class SoilProfileBuilder1D : ISoilProfileBuilder
+ public class SoilProfileBuilder1D
{
+ private readonly Collection layers;
+ private readonly string name;
+ private readonly double bottom;
+
internal SoilProfileBuilder1D(string name, double bottom)
{
- Name = name;
- Bottom = bottom;
- Layers = new Collection();
+ this.name = name;
+ this.bottom = bottom;
+ layers = new Collection();
}
- private Collection Layers { get; set; }
-
- private string Name { get; set; }
-
- private double Bottom { get; set; }
-
+ ///
+ /// Creates a new instances of the based on the layer definitions.
+ ///
+ /// A new .
public PipingSoilProfile Build()
{
- return new PipingSoilProfile(Name, Bottom, Layers);
+ return new PipingSoilProfile(name, bottom, layers);
}
///
/// Adds a new , which will be added to the .
///
- ///
+ /// The to add.
internal void Add(PipingSoilLayer soilLayer)
{
- Layers.Add(soilLayer);
+ layers.Add(soilLayer);
}
}
}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder2D.cs
===================================================================
diff -u -r33d4f4e7e5404dcc6470dd3d34168b30410109eb -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder2D.cs (.../SoilProfileBuilder2D.cs) (revision 33d4f4e7e5404dcc6470dd3d34168b30410109eb)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilder2D.cs (.../SoilProfileBuilder2D.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -1,66 +1,87 @@
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
+ internal class SoilProfileBuilder2D
{
private readonly ICollection layers = new Collection();
+ private readonly double atX;
+ private readonly string profileName;
+ private double bottom;
+
///
/// 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.
+ /// Thrown when can not be used to determine intersections with
+ /// (is ).
internal SoilProfileBuilder2D(string profileName, double atX)
{
if (double.IsNaN(atX))
{
throw new ArgumentException(Resources.Error_SoilProfileBuilder_cant_determine_intersect_at_double_NaN);
}
- ProfileName = profileName;
- AtX = atX;
- Bottom = double.MaxValue;
+ this.profileName = profileName;
+ this.atX = atX;
+ bottom = double.MaxValue;
}
///
- /// Adds a new to the profile.
+ /// Creates a new instances of the based on the layer definitions.
///
- /// The to add to the profile.
- /// The .
- internal SoilProfileBuilder2D Add(SoilLayer2D soilLayer)
+ /// A new .
+ /// Thrown when trying to build a
+ /// and not having added any layers using .
+ ///
+ public PipingSoilProfile Build()
{
- double bottom;
- foreach (PipingSoilLayer layer in soilLayer.AsPipingSoilLayers(AtX, out bottom))
+ try
{
- layers.Add(layer);
+ return new PipingSoilProfile(profileName, bottom, layers);
}
- Bottom = Math.Min(Bottom, bottom);
- return this;
+ catch (ArgumentException e)
+ {
+ throw new SoilProfileBuilderException(e.Message, e);
+ }
}
///
- /// Creates a new instance of .
+ /// Adds a new to the profile.
///
- /// A new .
- public PipingSoilProfile Build()
+ /// The to add to the profile.
+ /// The .
+ /// Thrown when the 's geometry
+ /// contains vertical segments the X-coordinate given for the construction of the
+ /// .
+ internal SoilProfileBuilder2D Add(SoilLayer2D soilLayer)
{
- return new PipingSoilProfile(ProfileName, Bottom, layers);
- }
+ double newBottom;
- private double Bottom { get; set; }
+ try
+ {
+ var pipingSoilLayers = soilLayer.AsPipingSoilLayers(atX, out newBottom);
+ foreach (PipingSoilLayer layer in pipingSoilLayers)
+ {
+ layers.Add(layer);
+ }
+ }
+ catch (SoilLayer2DConversionException e)
+ {
+ throw new SoilProfileBuilderException(e.Message, e);
+ }
- private double AtX { get; set; }
-
- private string ProfileName { get; set; }
+ bottom = Math.Min(bottom, newBottom);
+ return this;
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilderException.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilderException.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Builders/SoilProfileBuilderException.cs (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -0,0 +1,38 @@
+using System;
+
+using Ringtoets.Piping.Data;
+
+namespace Ringtoets.Piping.IO.Builders
+{
+ ///
+ /// Exception thrown when something went wrong while building a .
+ ///
+ public class SoilProfileBuilderException : Exception
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public SoilProfileBuilderException()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class
+ /// with a specified error message.
+ ///
+ /// The message that describes the error.
+ public SoilProfileBuilderException(string message)
+ : base(message)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class with a specified error message
+ /// and a reference to the inner exception that is the cause of this exception.
+ ///
+ /// The error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or a
+ /// null reference if no inner exception is specified.
+ public SoilProfileBuilderException(string message, Exception innerException) : base(message, innerException) { }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Calculation/Math2D.cs
===================================================================
diff -u -ra950714ad9510756331d862aa35695fa0b2ed03b -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Calculation/Math2D.cs (.../Math2D.cs) (revision a950714ad9510756331d862aa35695fa0b2ed03b)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Calculation/Math2D.cs (.../Math2D.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -1,4 +1,5 @@
using System;
+using Ringtoets.Piping.IO.Properties;
namespace Ringtoets.Piping.IO.Calculation
{
@@ -17,7 +18,8 @@
///
/// X coordinates of the segments. Should have matching y coordinates in .
/// Y coordinates of the segments. Should have matching x coordinates in .
- ///
+ /// An array of double representing the point where the line segments intersect ((x,y) = (array[0],array[1])).
+ /// Thrown when either or is not of length 4.
public static double[] LineSegmentIntersectionWithLineSegment(double[] segmentsX, double[] segmentsY)
{
var extraPolatedIntersectionPoint = LineSegmentIntersectionWithLine(segmentsX, segmentsY);
@@ -48,7 +50,9 @@
///
/// X coordinates of the segment and line. Should have matching y coordinates in .
/// Y coordinates of the segment and line. Should have matching x coordinates in .
- ///
+ /// An array of double representing the point where the line segment intersects with the line
+ /// ((x,y) = (array[0],array[1])).
+ /// Thrown when either or is not of length 4.
public static double[] LineSegmentIntersectionWithLine(double[] segmentsX, double[] segmentsY)
{
var extraPolatedIntersectionPoint = LineIntersectionWithLine(segmentsX, segmentsY);
@@ -74,13 +78,17 @@
return new double[0];
}
- /// Taken from: https://www.topcoder.com/community/data-science/data-science-tutorials/geometry-concepts-line-intersection-and-its-applications/ .
+ ///
+ /// Taken from: https://www.topcoder.com/community/data-science/data-science-tutorials/geometry-concepts-line-intersection-and-its-applications/
+ /// Based on https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
+ ///
+ /// Thrown when either or is not of length 4.
private static double[] LineIntersectionWithLine(double[] linesX, double[] linesY)
{
var numberOfPoints = 4;
if (linesX.Length != numberOfPoints || linesY.Length != numberOfPoints)
{
- throw new ArgumentException(String.Format("Collections of lines' x and y coordinates need to have length of {0}.", numberOfPoints));
+ throw new ArgumentException(String.Format(Resources.Error_Collections_of_lines_coordinates_need_length_of_0_, numberOfPoints));
}
var aLine = linesY[1] - linesY[0];
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/PipingSoilProfileReader.cs
===================================================================
diff -u -rf67ccd7b88da303d2ac322bbd489f2c6ea287e1c -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision f67ccd7b88da303d2ac322bbd489f2c6ea287e1c)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -126,35 +126,64 @@
///
/// A new with information from the database.
/// Thrown when a layer's geometry could not be parsed as XML.
+ /// Thrown when no valid point to obtain a one-dimensional
+ /// intersection from was read from the database, or when after reading layers, no layers were added
+ /// to be build.
private PipingSoilProfile ReadPipingProfile2D()
{
var profileName = TryRead(profileNameColumn);
var layerCount = TryRead(layerCountColumn);
var intersectionX = TryRead(intersectionXColumn);
- var soilProfileBuilder = new SoilProfileBuilder2D(profileName, intersectionX);
-
- for (int i = 1; i <= layerCount; i++)
+ try
{
- try
+ var soilProfileBuilder = new SoilProfileBuilder2D(profileName, intersectionX);
+
+ for (int i = 1; i <= layerCount; i++)
{
- soilProfileBuilder.Add(ReadPiping2DSoilLayer());
+ try
+ {
+ soilProfileBuilder.Add(ReadPiping2DSoilLayer());
+ }
+ catch (SoilLayer2DConversionException e)
+ {
+ HandleLayerParseException(layerCount, i, profileName, e);
+ }
+ catch (XmlException e)
+ {
+ HandleLayerParseException(layerCount, i, profileName, e);
+ }
+ MoveNext();
}
- catch (XmlException e)
- {
- var exception = new PipingSoilProfileReadException(
- string.Format(Resources.PipingSoilProfileReader_CouldNotParseGeometryOfLayer_0_InProfile_1_, i, profileName), e);
- SkipRecords((int)layerCount + 1 - i);
-
- throw exception;
- }
- MoveNext();
+ return soilProfileBuilder.Build();
}
+ catch (ArgumentException e)
+ {
+ HandleCriticalBuildException(profileName, e);
+ }
+ catch (SoilProfileBuilderException e)
+ {
+ HandleCriticalBuildException(profileName, e);
+ }
+ return null;
+ }
- return soilProfileBuilder.Build();
+ private static void HandleCriticalBuildException(string profileName, Exception e)
+ {
+ var message = string.Format(Resources.PipingSoilProfileReader_Could_not_build_profile_0_from_layer_definitions, profileName);
+ throw new CriticalFileReadException(message, e);
}
+ private void HandleLayerParseException(long layerCount, int i, string profileName, Exception e)
+ {
+ SkipRecords((int) layerCount + 1 - i);
+ var exception = new PipingSoilProfileReadException(
+ string.Format(Resources.PipingSoilProfileReader_CouldNotParseGeometryOfLayer_0_InProfile_1_, i, profileName), e);
+
+ throw exception;
+ }
+
private void SkipRecords(int count)
{
for(int i = 0; i < count; i++)
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -rf7d48349feba2a41391fac27dc3fef3028df091d -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision f7d48349feba2a41391fac27dc3fef3028df091d)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -79,6 +79,15 @@
}
///
+ /// Looks up a localized string similar to Collecties van de x en y coordinaten van lijnen vereisen een lengte van 4..
+ ///
+ public static string Error_Collections_of_lines_coordinates_need_length_of_0_ {
+ get {
+ return ResourceManager.GetString("Error_Collections_of_lines_coordinates_need_length_of_0_", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Het bestandspad '{0}' verwijst naar een map die niet bestaat..
///
public static string Error_Directory_in_path_0_missing {
@@ -187,6 +196,15 @@
}
///
+ /// Looks up a localized string similar to Kon profiel '{0}' niet opbouwen vanuit de gegevens uit de database..
+ ///
+ public static string PipingSoilProfileReader_Could_not_build_profile_0_from_layer_definitions {
+ get {
+ return ResourceManager.GetString("PipingSoilProfileReader_Could_not_build_profile_0_from_layer_definitions", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Kan de geometry van laag nummer '{0}' in profiel '{1}' niet interpreteren..
///
public static string PipingSoilProfileReader_CouldNotParseGeometryOfLayer_0_InProfile_1_ {
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx
===================================================================
diff -u -r33d4f4e7e5404dcc6470dd3d34168b30410109eb -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision 33d4f4e7e5404dcc6470dd3d34168b30410109eb)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -186,4 +186,10 @@
De database heeft niet de vereiste versie informatie. Vereiste versie is: {0}.
+
+ Collecties van de x en y coordinaten van lijnen vereisen een lengte van 4.
+
+
+ Kon profiel '{0}' niet opbouwen vanuit de gegevens uit de database.
+
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj
===================================================================
diff -u -r2a90c0c1be6114f72af65c42f0a6f334b30e4755 -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 2a90c0c1be6114f72af65c42f0a6f334b30e4755)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -41,7 +41,7 @@
Properties\GlobalAssembly.cs
-
+
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs
===================================================================
diff -u -rf67ccd7b88da303d2ac322bbd489f2c6ea287e1c -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs (.../PipingSoilProfilesImporter.cs) (revision f67ccd7b88da303d2ac322bbd489f2c6ea287e1c)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs (.../PipingSoilProfilesImporter.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -50,7 +50,7 @@
{
return new[]
{
- typeof(IEnumerable)
+ typeof(ObservableList)
};
}
}
Index: Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Piping/PipingProfileCreatorTest.cs
===================================================================
diff -u -r6692dc3480971fe1c017aef633382c40eb37056f -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Piping/PipingProfileCreatorTest.cs (.../PipingProfileCreatorTest.cs) (revision 6692dc3480971fe1c017aef633382c40eb37056f)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Piping/PipingProfileCreatorTest.cs (.../PipingProfileCreatorTest.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -111,7 +111,7 @@
var soilProfile = new PipingSoilProfile(string.Empty, expectedBottom, layers);
// Precondition
- CollectionAssert.AreNotEqual(layers, layers.OrderByDescending(l => l.Top), "Layers were already ordered.");
+ CollectionAssert.AreNotEqual(layers, layers.OrderByDescending(l => l.Top), "Layer collection should not be in descending order by the Top property.");
// Call
PipingProfile actual = PipingProfileCreator.Create(soilProfile);
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilProfileTest.cs
===================================================================
diff -u -r6692dc3480971fe1c017aef633382c40eb37056f -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilProfileTest.cs (.../PipingSoilProfileTest.cs) (revision 6692dc3480971fe1c017aef633382c40eb37056f)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingSoilProfileTest.cs (.../PipingSoilProfileTest.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -28,7 +28,7 @@
// Assert
Assert.AreNotSame(equivalentLayers, profile.Layers);
- CollectionAssert.AreEquivalent(equivalentLayers, profile.Layers);
+ CollectionAssert.AreEqual(equivalentLayers, profile.Layers);
Assert.AreEqual(name, profile.Name);
Assert.AreEqual(bottom, profile.Bottom);
}
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PointCollectionHelperTest.cs
===================================================================
diff -u -ra950714ad9510756331d862aa35695fa0b2ed03b -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PointCollectionHelperTest.cs (.../PointCollectionHelperTest.cs) (revision a950714ad9510756331d862aa35695fa0b2ed03b)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PointCollectionHelperTest.cs (.../PointCollectionHelperTest.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -63,30 +63,5 @@
Assert.AreEqual(4, result[0].X);
Assert.AreEqual(0, result[0].Z);
}
-
-
- [Test]
- public void CreateFromFile_TwoPointReversed_ReturnsExpectedPoints()
- {
- // Setup
- var text = String.Join(Environment.NewLine,
- "3",
- "..2..",
- ".....",
- "....1"
- );
- var url = "temp";
- File.WriteAllText(url, text);
-
- // Call
- var result = PointCollectionHelper.CreateFromFile(url).ToArray();
-
- // Assert
- Assert.AreEqual(2, result.Length);
- Assert.AreEqual(2, result[1].X);
- Assert.AreEqual(2, result[1].Z);
- Assert.AreEqual(4, result[0].X);
- Assert.AreEqual(0, result[0].Z);
- }
}
}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PointCollectionHelper.cs
===================================================================
diff -u -ra950714ad9510756331d862aa35695fa0b2ed03b -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PointCollectionHelper.cs (.../PointCollectionHelper.cs) (revision a950714ad9510756331d862aa35695fa0b2ed03b)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PointCollectionHelper.cs (.../PointCollectionHelper.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -3,17 +3,14 @@
using System.IO;
using System.Text.RegularExpressions;
-using Ringtoets.Piping.Data;
-
namespace Ringtoets.Piping.Data.TestUtil
{
+ ///
+ /// The class helps to construct collections of points by reading a string (from file or directly) and
+ /// transforming this in objects that can be used in tests.
+ ///
public class PointCollectionHelper
{
- public static HashSet CreateFromFile(string url)
- {
- return CreateFromString(File.ReadAllText(url));
- }
-
public static HashSet CreateFromString(string s)
{
var points = new SortedDictionary();
@@ -33,14 +30,39 @@
return new HashSet(points.Values);
}
- private static IEnumerable> AllIndexesOfDigit(string word)
+ ///
+ /// Returns a of if .
+ /// The first item in the tuple contains the digit and the second item contains its index.
+ ///
+ /// The line which contains digits.
+ /// A of of
+ /// which contains the digits and the index of those digits.
+ /// Thrown when the regex magically matches more or less than it should
+ /// have (1 digit).
+ private static IEnumerable> AllIndexesOfDigit(string line)
{
var guess = @"\d";
- var matches = Regex.Matches(word, guess);
+ var matches = Regex.Matches(line, guess);
foreach (Match match in matches)
{
- var digit = int.Parse(match.Value);
- yield return Tuple.Create(digit, match.Index);
+ int digit;
+ try
+ {
+ digit = int.Parse(match.Value);
+ }
+ catch (ArgumentNullException e)
+ {
+ throw new Exception(e.Message,e);
+ }
+ catch (FormatException e)
+ {
+ throw new Exception(e.Message, e);
+ }
+ catch (OverflowException e)
+ {
+ throw new Exception(e.Message, e);
+ }
+ yield return Tuple.Create(digit, match.Index);
}
}
}
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayer2DTest.cs
===================================================================
diff -u -r33d4f4e7e5404dcc6470dd3d34168b30410109eb -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayer2DTest.cs (.../SoilLayer2DTest.cs) (revision 33d4f4e7e5404dcc6470dd3d34168b30410109eb)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilLayer2DTest.cs (.../SoilLayer2DTest.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -98,13 +98,13 @@
{
// Setup
var outerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "..1..2..",
- "........",
- "..8.7...",
- "..5.6...",
- "..4..3..",
- "........"));
+ "6",
+ "..1..2..",
+ "........",
+ "..8.7...",
+ "..5.6...",
+ "..4..3..",
+ "........"));
var layer = new SoilLayer2D
{
@@ -126,22 +126,22 @@
{
// Setup
var outerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "..1..2..",
- "........",
- "........",
- "........",
- "........",
- "..4..3.."));
+ "6",
+ "..1..2..",
+ "........",
+ "........",
+ "........",
+ "........",
+ "..4..3.."));
var innerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "........",
- "...12...",
- "........",
- "........",
- "...43...",
- "........"));
+ "6",
+ "........",
+ "...12...",
+ "........",
+ "........",
+ "...43...",
+ "........"));
var layer = new SoilLayer2D
{
@@ -167,22 +167,22 @@
{
// Setup
var outerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "..1..2..",
- "........",
- "........",
- "........",
- "........",
- "..4..3.."));
+ "6",
+ "..1..2..",
+ "........",
+ "........",
+ "........",
+ "........",
+ "..4..3.."));
var innerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "........",
- "...1.2..",
- "...87...",
- "...56...",
- "...4.3..",
- "........"));
+ "6",
+ "........",
+ "...1.2..",
+ "...87...",
+ "...56...",
+ "...4.3..",
+ "........"));
var layer = new SoilLayer2D
{
@@ -208,31 +208,31 @@
{
// Setup
var outerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "..1..2..",
- "........",
- "........",
- "........",
- "........",
- "..4..3.."));
+ "6",
+ "..1..2..",
+ "........",
+ "........",
+ "........",
+ "........",
+ "..4..3.."));
var innerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "........",
- "...12...",
- "...43...",
- "........",
- "........",
- "........"));
+ "6",
+ "........",
+ "...12...",
+ "...43...",
+ "........",
+ "........",
+ "........"));
var innerLoop2 = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "........",
- "........",
- "........",
- "........",
- "...12...",
- "........"));
+ "6",
+ "........",
+ "........",
+ "........",
+ "........",
+ "...12...",
+ "........"));
var layer = new SoilLayer2D
{
@@ -259,22 +259,22 @@
{
// Setup
var outerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "..1..2..",
- "........",
- "........",
- "........",
- ".4....3.",
- "........"));
+ "6",
+ "..1..2..",
+ "........",
+ "........",
+ "........",
+ ".4....3.",
+ "........"));
var innerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "........",
- "........",
- "........",
- "...12...",
- "........",
- "...43..."));
+ "6",
+ "........",
+ "........",
+ "........",
+ "...12...",
+ "........",
+ "...43..."));
var layer = new SoilLayer2D
{
@@ -300,31 +300,31 @@
{
// Setup
var outerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "..1..2..",
- "........",
- "........",
- "........",
- ".4....3.",
- "........"));
+ "6",
+ "..1..2..",
+ "........",
+ "........",
+ "........",
+ ".4....3.",
+ "........"));
var innerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "........",
- "...12...",
- "........",
- "...43...",
- "........",
- "........"));
+ "6",
+ "........",
+ "...12...",
+ "........",
+ "...43...",
+ "........",
+ "........"));
var innerLoop2 = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "........",
- "........",
- "...12...",
- "........",
- "........",
- "...43..."));
+ "6",
+ "........",
+ "........",
+ "...12...",
+ "........",
+ "........",
+ "...43..."));
var layer = new SoilLayer2D
{
@@ -351,22 +351,22 @@
{
// Setup
var outerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "..1..2..",
- "........",
- "........",
- "........",
- ".4....3.",
- "........"));
+ "6",
+ "..1..2..",
+ "........",
+ "........",
+ "........",
+ ".4....3.",
+ "........"));
var innerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "........",
- "........",
- "...12...",
- "........",
- "...43...",
- "........"));
+ "6",
+ "........",
+ "........",
+ "...12...",
+ "........",
+ "...43...",
+ "........"));
var layer = new SoilLayer2D
{
@@ -392,22 +392,22 @@
{
// Setup
var outerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "........",
- "..1..2..",
- "........",
- "........",
- ".4....3.",
- "........"));
+ "6",
+ "........",
+ "..1..2..",
+ "........",
+ "........",
+ ".4....3.",
+ "........"));
var innerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "...43...",
- "........",
- "...12...",
- "........",
- "........",
- "........"));
+ "6",
+ "...43...",
+ "........",
+ "...12...",
+ "........",
+ "........",
+ "........"));
var layer = new SoilLayer2D
{
@@ -433,22 +433,22 @@
{
// Setup
var outerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "..1..2..",
- "........",
- "........",
- "........",
- ".4....3.",
- "........"));
+ "6",
+ "..1..2..",
+ "........",
+ "........",
+ "........",
+ ".4....3.",
+ "........"));
var innerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "...43...",
- "........",
- "...12...",
- "........",
- "........",
- "........"));
+ "6",
+ "...43...",
+ "........",
+ "...12...",
+ "........",
+ "........",
+ "........"));
var layer = new SoilLayer2D
{
@@ -475,13 +475,13 @@
// Setup
var atX = 2.0;
var outerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "..1..2..",
- "........",
- "........",
- "........",
- "........",
- "..4..3.."));
+ "6",
+ "..1..2..",
+ "........",
+ "........",
+ "........",
+ "........",
+ "..4..3.."));
var layer = new SoilLayer2D
{
@@ -503,22 +503,22 @@
// Setup
var atX = 3.0;
var outerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "..1..2..",
- "........",
- "........",
- "........",
- "........",
- "..4..3.."));
+ "6",
+ "..1..2..",
+ "........",
+ "........",
+ "........",
+ "........",
+ "..4..3.."));
var innerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine,
- "6",
- "........",
- "...1.2..",
- "........",
- "........",
- "...4.3..",
- "........"));
+ "6",
+ "........",
+ "...1.2..",
+ "........",
+ "........",
+ "...4.3..",
+ "........"));
var layer = new SoilLayer2D
{
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilProfileBuilder2DTest.cs
===================================================================
diff -u -r6692dc3480971fe1c017aef633382c40eb37056f -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilProfileBuilder2DTest.cs (.../SoilProfileBuilder2DTest.cs) (revision 6692dc3480971fe1c017aef633382c40eb37056f)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Builders/SoilProfileBuilder2DTest.cs (.../SoilProfileBuilder2DTest.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -32,14 +32,14 @@
public void Constructor_WithNameValidX_ReturnsNewInstance(string name)
{
// Call
- var builder = new SoilProfileBuilder2D(name, 0.0);
+ TestDelegate test = () => new SoilProfileBuilder2D(name, 0.0);
// Assert
- Assert.NotNull(builder);
+ Assert.DoesNotThrow(test);
}
[Test]
- public void Build_WithOutLayers_ThrowsArgumentException()
+ public void Build_WithOutLayers_ThrowsSoilProfileBuilderException()
{
// Setup
var profileName = "SomeProfile";
@@ -49,7 +49,7 @@
TestDelegate test = () => builder.Build();
// Assert
- Assert.Throws(test);
+ Assert.Throws(test);
}
[Test]
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Calculation/Math2DTest.cs
===================================================================
diff -u -ra950714ad9510756331d862aa35695fa0b2ed03b -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Calculation/Math2DTest.cs (.../Math2DTest.cs) (revision a950714ad9510756331d862aa35695fa0b2ed03b)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Calculation/Math2DTest.cs (.../Math2DTest.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -8,98 +8,86 @@
{
public class Math2DTest
{
+ #region testcases
+
+ ///
+ /// Test cases for intersecting segments. The contains pairs of ,
+ /// which represent the coordinate of a point. Each pair of coordinates form a segment.
+ /// The last 2 double values are the expected intersection points.
+ ///
private static readonly double[][] IntersectingSegments =
{
// \/
// /\
new[]
{
- 0.0,
- 0.0,
- 1.0,
- 1.0,
- 1.0,
- 0.0,
- 0.0,
- 1.0,
- 0.5,
- 0.5
+ 0.0,0.0,
+ 1.0,1.0,
+ 1.0,0.0,
+ 0.0,1.0,
+ 0.5,0.5
},
// __
// /
// /
new[]
{
- 0.0,
- 0.0,
- 1.0,
- 1.0,
- 0.0,
- 1.0,
- 1.0,
- 1.0,
- 1.0,
- 1.0
+ 0.0,0.0,
+ 1.0,1.0,
+ 0.0,1.0,
+ 1.0,1.0,
+ 1.0,1.0
},
//
// /
// /__
new[]
{
- 0.0,
- 0.0,
- 1.0,
- 0.0,
- 0.0,
- 0.0,
- 1.0,
- 1.0,
- 0.0,
- 0.0
+ 0.0,0.0,
+ 1.0,0.0,
+ 0.0,0.0,
+ 1.0,1.0,
+ 0.0,0.0
}
};
+ ///
+ /// Test cases for parallel segments. The contains pairs of ,
+ /// which represent the coordinate of a point. Each pair of coordinates form a segment.
+ ///
private static readonly double[][] ParallelSegments =
{
// __
// __
new[]
{
- 0.0,
- 0.0,
- 1.0,
- 0.0,
- 0.0,
- 1.0,
- 1.0,
- 1.0
+ 0.0,0.0,
+ 1.0,0.0,
+ 0.0,1.0,
+ 1.0,1.0
},
// ____ (connected in single point)
new[]
{
- 0.0,
- 0.0,
- 1.0,
- 0.0,
- 1.0,
- 0.0,
- 2.0,
- 0.0
+ 0.0,0.0,
+ 1.0,0.0,
+ 1.0,0.0,
+ 2.0,0.0
},
// __ (overlap)
new[]
{
- 0.0,
- 0.0,
- 1.0,
- 0.0,
- 0.5,
- 0.0,
- 1.5,
- 0.0
+ 0.0,0.0,
+ 1.0,0.0,
+ 0.5,0.0,
+ 1.5,0.0
}
};
+ ///
+ /// Test cases for non intersecting segments. The contains pairs of ,
+ /// which represent the coordinate of a point. Each pair of coordinates form a segment.
+ ///
private static readonly double[][] NonIntersectingSegments =
{
// |
@@ -117,6 +105,8 @@
}
};
+ #endregion
+
[Test]
[TestCaseSource("IntersectingSegments")]
public void LineSegmentIntersectionWithLineSegment_DifferentLineSegmentsWithIntersections_ReturnsPoint(double[] coordinates)
@@ -190,7 +180,7 @@
// Assert
var message = Assert.Throws(test);
- Assert.AreEqual(message.Message, "Collections of lines' x and y coordinates need to have length of 4.");
+ Assert.AreEqual(message.Message, "Collecties van de x en y coordinaten van lijnen vereisen een lengte van 4.");
}
[Test]
@@ -220,7 +210,7 @@
// Assert
var message = Assert.Throws(test);
- Assert.AreEqual(message.Message, "Collections of lines' x and y coordinates need to have length of 4.");
+ Assert.AreEqual(message.Message, "Collecties van de x en y coordinaten van lijnen vereisen een lengte van 4.");
}
private double[][] ToSegmentCoordinatesCollections(double[] coordinates)
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/PipingSoilProfileReaderTest.cs
===================================================================
diff -u -r6692dc3480971fe1c017aef633382c40eb37056f -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/PipingSoilProfileReaderTest.cs (.../PipingSoilProfileReaderTest.cs) (revision 6692dc3480971fe1c017aef633382c40eb37056f)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/PipingSoilProfileReaderTest.cs (.../PipingSoilProfileReaderTest.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -77,85 +77,15 @@
pipingSoilProfileReader.ReadProfile();
}
- // Call
- var profile = pipingSoilProfileReader.ReadProfile();
-
- // Assert
- Assert.IsNull(profile);
+ // Call & Assert
+ Assert.IsNull(pipingSoilProfileReader.ReadProfile());
}
}
[Test]
- public void Dispose_AfterConstruction_CorrectlyReleasesFile()
+ public void ReadProfile_DatabaseWith1DAnd2DProfilesWithSameName_ReturnTwoProfilesWithSameName()
{
// Setup
- var testFile = "1dprofile.soil";
- var dbFile = Path.Combine(testDataPath, testFile);
-
- // Precondition
- Assert.IsTrue(FileHelper.CanOpenFileForWrite(dbFile), "Precondition failed: The file should be writable to begin with.");
-
- // Call
- new PipingSoilProfileReader(dbFile).Dispose();
-
- // Assert
- Assert.IsTrue(FileHelper.CanOpenFileForWrite(dbFile));
- }
-
- [Test]
- public void Dispose_WhenReadProfile_CorrectlyReleasesFile()
- {
- // Setup
- var testFile = "1dprofile.soil";
- var dbFile = Path.Combine(testDataPath, testFile);
-
- // Precondition
- Assert.IsTrue(FileHelper.CanOpenFileForWrite(dbFile), "Precondition failed: The file should be writable to begin with.");
-
- PipingSoilProfileReader pipingSoilProfilesReader = null;
- PipingSoilProfile profile = null;
- try
- {
- pipingSoilProfilesReader = new PipingSoilProfileReader(dbFile);
- profile = pipingSoilProfilesReader.ReadProfile();
- }
- finally
- {
- // Call
- if (pipingSoilProfilesReader != null)
- {
- pipingSoilProfilesReader.Dispose();
- }
- }
-
- // Assert
- Assert.NotNull(profile);
- Assert.IsTrue(FileHelper.CanOpenFileForWrite(dbFile));
- }
-
- [Test]
- public void ReadProfile_DatabaseWith1DProfile3Layers_ReturnsProfile()
- {
- // Setup
- var testFile = "1dprofile.soil";
- var dbFile = Path.Combine(testDataPath, testFile);
- using(var reader = new PipingSoilProfileReader(dbFile)){
- // Call
- var profile = reader.ReadProfile();
-
- // Assert
- CollectionAssert.AreEqual(new[] {0.0, 0.0, 1.0}, 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));
- Assert.AreEqual(3,profile.Layers.Count());
- }
- }
-
- [Test]
- public void Read_DatabaseWith1DAnd2DProfilesWithSameName_ReturnTwoProfilesWithSameName()
- {
- // Setup
var testFile = "combined1d2d.soil";
var dbFile = Path.Combine(testDataPath, testFile);
@@ -176,22 +106,24 @@
}
[Test]
- public void Read_DatabaseProfileWithInvalid2dLayerGeometry_SkipsTheProfile()
+ public void ReadProfile_DatabaseProfileWithInvalid2dLayerGeometry_SkipsTheProfile()
{
// Setup
var testFile = "invalid2dGeometry.soil";
using (var pipingSoilProfilesReader = new PipingSoilProfileReader(Path.Combine(testDataPath, testFile)))
{
// Call
TestDelegate profile = () => pipingSoilProfilesReader.ReadProfile();
- Func profile2 = () => pipingSoilProfilesReader.ReadProfile();
// Assert
var exception = Assert.Throws(profile);
var message = String.Format(Resources.PipingSoilProfileReader_CouldNotParseGeometryOfLayer_0_InProfile_1_, 1, "Profile");
Assert.AreEqual(message, exception.Message);
- var pipingSoilProfile = profile2();
+ // Call
+ var pipingSoilProfile = pipingSoilProfilesReader.ReadProfile();
+
+ // Assert
Assert.AreEqual("Profile2", pipingSoilProfile.Name);
Assert.AreEqual(3, pipingSoilProfile.Layers.Count());
@@ -200,7 +132,7 @@
}
[Test]
- public void Read_DatabaseProfileWithoutValuesForLayerProperties_ReturnsProfileWithAllLayers()
+ public void ReadProfile_DatabaseProfileWithoutValuesForLayerProperties_ReturnsProfileWithAllLayers()
{
// Setup
var testFile = "1dprofileNoValues.soil";
@@ -226,6 +158,93 @@
}
[Test]
+ public void ReadProfile_DatabaseWith1DProfile3Layers_ReturnsProfile()
+ {
+ // Setup
+ var testFile = "1dprofile.soil";
+ var dbFile = Path.Combine(testDataPath, testFile);
+ using (var reader = new PipingSoilProfileReader(dbFile))
+ {
+ // Call
+ var profile = reader.ReadProfile();
+
+ // Assert
+ CollectionAssert.AreEqual(new[]
+ {
+ 0.0,
+ 0.0,
+ 1.0
+ }, 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));
+ }
+ }
+
+ [Test]
+ public void Dispose_AfterConstruction_CorrectlyReleasesFile()
+ {
+ // Setup
+ var testFile = "1dprofile.soil";
+ var dbFile = Path.Combine(testDataPath, testFile);
+
+ // Precondition
+ Assert.IsTrue(FileHelper.CanOpenFileForWrite(dbFile), "Precondition failed: The file should be writable to begin with.");
+
+ // Call
+ new PipingSoilProfileReader(dbFile).Dispose();
+
+ // Assert
+ Assert.IsTrue(FileHelper.CanOpenFileForWrite(dbFile));
+ }
+
+ [Test]
+ public void Dispose_WhenReadProfile_CorrectlyReleasesFile()
+ {
+ // Setup
+ var testFile = "1dprofile.soil";
+ var dbFile = Path.Combine(testDataPath, testFile);
+
+ // Precondition
+ Assert.IsTrue(FileHelper.CanOpenFileForWrite(dbFile), "Precondition failed: The file should be writable to begin with.");
+
+ PipingSoilProfileReader pipingSoilProfilesReader = null;
+ PipingSoilProfile profile = null;
+ try
+ {
+ pipingSoilProfilesReader = new PipingSoilProfileReader(dbFile);
+ profile = pipingSoilProfilesReader.ReadProfile();
+ }
+ finally
+ {
+ // Call
+ if (pipingSoilProfilesReader != null)
+ {
+ pipingSoilProfilesReader.Dispose();
+ }
+ }
+
+ // Assert
+ Assert.NotNull(profile);
+ Assert.IsTrue(FileHelper.CanOpenFileForWrite(dbFile));
+ }
+
+ [Test]
[SetCulture("nl-NL")]
public void GivenDatabaseWith1DProfileAndDutchLocale_WhenReadingTheCompleteDatabase_ReturnsCompleteSoilProfile()
{
@@ -253,7 +272,7 @@
GivenACompleteDatabase_WhenReadingTheCompleteDatabase_Returns2ProfilesWithLayersAndGeometries();
}
- public void GivenDatabaseWith1DProfile_WhenReadingTheCompleteDatabase_ReturnsCompleteSoilProfile()
+ private void GivenDatabaseWith1DProfile_WhenReadingTheCompleteDatabase_ReturnsCompleteSoilProfile()
{
// Setup
var testFile = "1dprofile.soil";
@@ -313,11 +332,12 @@
// Assert
Assert.AreEqual(0, skipped);
Assert.AreEqual(26, result.Count);
- CollectionAssert.AreEquivalent(new[]
+ CollectionAssert.AreEqual(new[]
{
"AD640M00_Segment_36005_1D1",
"AD640M00_Segment_36005_1D2",
"Segment_36005_1D1",
+ "Segment_36005_1D10",
"Segment_36005_1D2",
"Segment_36005_1D3",
"Segment_36005_1D4",
@@ -326,7 +346,6 @@
"Segment_36005_1D7",
"Segment_36005_1D8",
"Segment_36005_1D9",
- "Segment_36005_1D10",
"Segment_36006_1D1",
"Segment_36006_1D2",
"Segment_36006_1D3",
@@ -343,7 +362,7 @@
"Segment_36007_1D8"
}, result.Select(p => p.Name));
- CollectionAssert.AreEquivalent(new[]
+ CollectionAssert.AreEqual(new[]
{
-39.999943172545208,
-45,
@@ -373,11 +392,12 @@
-21
}, result.Select(p => p.Bottom));
- CollectionAssert.AreEquivalent(new[]
+ CollectionAssert.AreEqual(new[]
{
9,
8,
8,
+ 3,
6,
6,
5,
@@ -386,7 +406,6 @@
4,
4,
3,
- 3,
7,
7,
7,
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/TestHelpers/FileHelper.cs
===================================================================
diff -u -rd514ce187a1ce571355fd92ca1edf822d943ba39 -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/TestHelpers/FileHelper.cs (.../FileHelper.cs) (revision d514ce187a1ce571355fd92ca1edf822d943ba39)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/TestHelpers/FileHelper.cs (.../FileHelper.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -2,8 +2,17 @@
namespace Ringtoets.Piping.IO.Test.TestHelpers
{
+ ///
+ /// This static class contains helper methods which can be used in tests.
+ ///
public static class FileHelper {
+ ///
+ /// Checks whether the file pointed at by can be opened
+ /// for writing.
+ ///
+ /// The location of the file to open for writing.
+ /// true if the file could be opened with write permissions. false otherwise.
public static bool CanOpenFileForWrite(string pathToFile)
{
FileStream file = null;
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs
===================================================================
diff -u -rf7d48349feba2a41391fac27dc3fef3028df091d -r97c9e382dffcf32dc34d2e05e6a8a475b833ebd4
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs (.../PipingSoilProfilesImporterTest.cs) (revision f7d48349feba2a41391fac27dc3fef3028df091d)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs (.../PipingSoilProfilesImporterTest.cs) (revision 97c9e382dffcf32dc34d2e05e6a8a475b833ebd4)
@@ -37,7 +37,7 @@
Assert.AreEqual(ApplicationResources.Wti_application_name, importer.Category);
Assert.AreEqual(16, importer.Image.Width);
Assert.AreEqual(16, importer.Image.Height);
- CollectionAssert.AreEqual(new[] { typeof(IEnumerable) }, importer.SupportedItemTypes);
+ CollectionAssert.AreEqual(new[] { typeof(ObservableList) }, importer.SupportedItemTypes);
Assert.IsFalse(importer.CanImportOnRootLevel);
Assert.AreEqual(expectedFileFilter, importer.FileFilter);
Assert.IsNull(importer.TargetDataDirectory);