Index: Core/Components/src/Core.Components.Gis.IO/Core.Components.Gis.IO.csproj
===================================================================
diff -u -r33c64ea2cd6b287bf5954e63a548d89dadb7f153 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Components/src/Core.Components.Gis.IO/Core.Components.Gis.IO.csproj (.../Core.Components.Gis.IO.csproj) (revision 33c64ea2cd6b287bf5954e63a548d89dadb7f153)
+++ Core/Components/src/Core.Components.Gis.IO/Core.Components.Gis.IO.csproj (.../Core.Components.Gis.IO.csproj) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -63,13 +63,16 @@
Properties\GlobalAssembly.cs
-
True
True
Resources.resx
+
+
+
+
Fisheye: Tag 5e80369138024933a45f3e4ae721509dfb17d8fb refers to a dead (removed) revision in file `Core/Components/src/Core.Components.Gis.IO/PolylineShapeFileReader.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Core/Components/src/Core.Components.Gis.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -rc9f9c04e4fc62406231afd07d63cd7da11673ec6 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Components/src/Core.Components.Gis.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision c9f9c04e4fc62406231afd07d63cd7da11673ec6)
+++ Core/Components/src/Core.Components.Gis.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -70,15 +70,42 @@
}
///
- /// Looks up a localized string similar to op index {0}.
+ /// Looks up a localized string similar to Bestand bevat geometrieën die geen punt zijn..
///
- internal static string PolylineShapeFileReader_GetSingleLineFeature_At_shapefile_index_0_ {
+ internal static string PointShapeFileReader_File_contains_geometries_not_points {
get {
- return ResourceManager.GetString("PolylineShapeFileReader_GetSingleLineFeature_At_shapefile_index_0_", resourceCulture);
+ return ResourceManager.GetString("PointShapeFileReader_File_contains_geometries_not_points", resourceCulture);
}
}
///
+ /// Looks up a localized string similar to Bestand bevat geometrieën die geen polygonen zijn..
+ ///
+ internal static string PointShapeFileReader_File_contains_geometries_not_polygons {
+ get {
+ return ResourceManager.GetString("PointShapeFileReader_File_contains_geometries_not_polygons", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Punten.
+ ///
+ internal static string PointShapeFileReader_ReadLine_Points {
+ get {
+ return ResourceManager.GetString("PointShapeFileReader_ReadLine_Points", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Polygoon.
+ ///
+ internal static string PolygonShapeFileReader_ReadLine_Polygon {
+ get {
+ return ResourceManager.GetString("PolygonShapeFileReader_ReadLine_Polygon", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Lijn.
///
internal static string PolylineShapeFileReader_ReadLine_Line {
@@ -95,5 +122,14 @@
return ResourceManager.GetString("PolylineShapeFileReader_ReadLine_Read_unsupported_multipolyline", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to op index {0}.
+ ///
+ internal static string ShapeFileReaderBase_GetFeature_At_shapefile_index_0_ {
+ get {
+ return ResourceManager.GetString("ShapeFileReaderBase_GetFeature_At_shapefile_index_0_", resourceCulture);
+ }
+ }
}
}
Index: Core/Components/src/Core.Components.Gis.IO/Properties/Resources.resx
===================================================================
diff -u -rc9f9c04e4fc62406231afd07d63cd7da11673ec6 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Components/src/Core.Components.Gis.IO/Properties/Resources.resx (.../Resources.resx) (revision c9f9c04e4fc62406231afd07d63cd7da11673ec6)
+++ Core/Components/src/Core.Components.Gis.IO/Properties/Resources.resx (.../Resources.resx) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -123,10 +123,22 @@
Ingelezen element is een 'multi-lijn'; alleen enkelvoudige lijn elementen worden ondersteund.
-
+
op index {0}
Lijn
+
+ Bestand bevat geometrieën die geen punt zijn.
+
+
+ Punten
+
+
+ Bestand bevat geometrieën die geen polygonen zijn.
+
+
+ Polygoon
+
\ No newline at end of file
Index: Core/Components/src/Core.Components.Gis.IO/Readers/PointShapeFileReader.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.Gis.IO/Readers/PointShapeFileReader.cs (revision 0)
+++ Core/Components/src/Core.Components.Gis.IO/Readers/PointShapeFileReader.cs (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -0,0 +1,96 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Data;
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Common.IO.Exceptions;
+using Core.Common.Utils.Builders;
+using Core.Components.Gis.Data;
+using DotSpatial.Data;
+using CoreCommonUtilsResources = Core.Common.Utils.Properties.Resources;
+using GisIOResources = Core.Components.Gis.IO.Properties.Resources;
+
+namespace Core.Components.Gis.IO.Readers
+{
+ ///
+ /// Class to be used to read points from a shapefile.
+ ///
+ public class PointShapeFileReader : ShapeFileReaderBase
+ {
+ private int readIndex;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The path to the shape file.
+ /// Thrown when is invalid.
+ /// Thrown when
+ ///
+ /// - points to a file that doesn't exist.
+ /// - The shapefile has non-point geometries in it.
+ ///
+ ///
+ public PointShapeFileReader(string filePath) : base(filePath)
+ {
+ try
+ {
+ ShapeFile = new PointShapefile(filePath);
+ }
+ catch (ApplicationException e)
+ {
+ string message = new FileReaderErrorMessageBuilder(filePath)
+ .Build(GisIOResources.PointShapeFileReader_File_contains_geometries_not_points);
+ throw new CriticalFileReadException(message, e);
+ }
+ }
+
+ public override PointBasedMapData ReadLine(string name = null)
+ {
+ if (readIndex == GetNumberOfLines())
+ {
+ return null;
+ }
+
+ try
+ {
+ IFeature pointFeature = GetFeature(readIndex);
+ return ConvertPointFeatureToMapPointData(pointFeature, name ?? GisIOResources.PointShapeFileReader_ReadLine_Points);
+ }
+ finally
+ {
+ readIndex++;
+ }
+ }
+
+ public override IFeature GetFeature(int index)
+ {
+ IFeature pointFeature = ShapeFile.Features[index];
+ return pointFeature;
+ }
+
+ private PointBasedMapData ConvertPointFeatureToMapPointData(IFeature pointFeature, string name)
+ {
+ return new MapPointData(pointFeature.Coordinates.Select(c => new Point2D(c.X, c.Y)), name);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.Gis.IO/Readers/PolygonShapeFileReader.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.Gis.IO/Readers/PolygonShapeFileReader.cs (revision 0)
+++ Core/Components/src/Core.Components.Gis.IO/Readers/PolygonShapeFileReader.cs (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -0,0 +1,96 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Data;
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Common.IO.Exceptions;
+using Core.Common.Utils.Builders;
+using Core.Components.Gis.Data;
+using DotSpatial.Data;
+using CoreCommonUtilsResources = Core.Common.Utils.Properties.Resources;
+using GisIOResources = Core.Components.Gis.IO.Properties.Resources;
+
+namespace Core.Components.Gis.IO.Readers
+{
+ ///
+ /// Class to be used to read polygons from a shapefile.
+ ///
+ public class PolygonShapeFileReader : ShapeFileReaderBase
+ {
+ private int readIndex;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The path to the shape file.
+ /// When is invalid.
+ /// When either:
+ ///
+ /// - points to a file that doesn't exist.
+ /// - The shapefile has non-polygon geometries in it.
+ ///
+ ///
+ public PolygonShapeFileReader(string filePath) : base(filePath)
+ {
+ try
+ {
+ ShapeFile = new PolygonShapefile(filePath);
+ }
+ catch (ArgumentException e)
+ {
+ string message = new FileReaderErrorMessageBuilder(filePath)
+ .Build(GisIOResources.PointShapeFileReader_File_contains_geometries_not_polygons);
+ throw new CriticalFileReadException(message, e);
+ }
+ }
+
+ public override PointBasedMapData ReadLine(string name = null)
+ {
+ if (readIndex == GetNumberOfLines())
+ {
+ return null;
+ }
+
+ try
+ {
+ IFeature polygonFeature = GetFeature(readIndex);
+ return ConvertPolygonFeatureToMapPolygonData(polygonFeature, name ?? GisIOResources.PolygonShapeFileReader_ReadLine_Polygon);
+ }
+ finally
+ {
+ readIndex++;
+ }
+ }
+
+ public override IFeature GetFeature(int index)
+ {
+ IFeature polygonFeature = ShapeFile.Features[index];
+ return polygonFeature;
+ }
+
+ private PointBasedMapData ConvertPolygonFeatureToMapPolygonData(IFeature polygonFeature, string name)
+ {
+ return new MapPolygonData(polygonFeature.Coordinates.Select(c => new Point2D(c.X, c.Y)), name);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.Gis.IO/Readers/PolylineShapeFileReader.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.Gis.IO/Readers/PolylineShapeFileReader.cs (revision 0)
+++ Core/Components/src/Core.Components.Gis.IO/Readers/PolylineShapeFileReader.cs (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -0,0 +1,122 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Data;
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Common.IO.Exceptions;
+using Core.Common.Utils.Builders;
+using Core.Components.Gis.Data;
+using DotSpatial.Data;
+using CoreCommonUtilsResources = Core.Common.Utils.Properties.Resources;
+using GisIOResources = Core.Components.Gis.IO.Properties.Resources;
+
+namespace Core.Components.Gis.IO.Readers
+{
+ ///
+ /// Class to be used to read polylines from a shapefile.
+ ///
+ public class PolylineShapeFileReader : ShapeFileReaderBase
+ {
+ private int readIndex;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The shapefile path.
+ /// When is invalid.
+ /// When either:
+ ///
+ /// - points to a file that doesn't exist.
+ /// - The shapefile has non-line geometries in it.
+ ///
+ ///
+ public PolylineShapeFileReader(string shapeFilePath) : base(shapeFilePath)
+ {
+ try
+ {
+ ShapeFile = new LineShapefile(shapeFilePath);
+ }
+ catch (ArgumentException e)
+ {
+ string message = new FileReaderErrorMessageBuilder(shapeFilePath)
+ .Build(GisIOResources.LineShapeFileReader_File_contains_geometries_not_line);
+ throw new CriticalFileReadException(message, e);
+ }
+ }
+
+ ///
+ /// Reads a line shape from the file.
+ ///
+ /// The representing the read line shape, or
+ /// null when at the end of the shapefile.
+ /// When reading a multi-line feature.
+ public override PointBasedMapData ReadLine(string name = null)
+ {
+ if (readIndex == GetNumberOfLines())
+ {
+ return null;
+ }
+
+ try
+ {
+ IFeature lineFeature = GetFeature(readIndex);
+ return ConvertSingleLineFeatureToMapLineData(lineFeature, name ?? GisIOResources.PolylineShapeFileReader_ReadLine_Line);
+ }
+ finally
+ {
+ readIndex++;
+ }
+ }
+
+ ///
+ /// Gets the single line feature at the given index.
+ ///
+ /// The index of which feature to retrieve.
+ /// The feature that consists out of 1 whole polyline.
+ /// When reading a multi-line feature.
+ public override IFeature GetFeature(int index)
+ {
+ IFeature lineFeature = ShapeFile.Features[index];
+ if (lineFeature.NumGeometries > 1)
+ {
+ string message = new FileReaderErrorMessageBuilder(FilePath)
+ .WithLocation(string.Format(GisIOResources.ShapeFileReaderBase_GetFeature_At_shapefile_index_0_, index))
+ .Build(GisIOResources.PolylineShapeFileReader_ReadLine_Read_unsupported_multipolyline);
+ throw new ElementReadException(message);
+ }
+ return lineFeature;
+ }
+
+ private MapLineData ConvertSingleLineFeatureToMapLineData(IFeature lineFeature, string name)
+ {
+ var lineData = new MapLineData(lineFeature.Coordinates.Select(c => new Point2D(c.X, c.Y)), name);
+ DataTable table = ShapeFile.GetAttributes(readIndex, 1);
+ DataRow dataRow = table.Rows[0];
+ for (int i = 0; i < table.Columns.Count; i++)
+ {
+ lineData.MetaData[table.Columns[i].ColumnName] = dataRow[i];
+ }
+ return lineData;
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.Gis.IO/Readers/ShapeFileReaderBase.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.Gis.IO/Readers/ShapeFileReaderBase.cs (revision 0)
+++ Core/Components/src/Core.Components.Gis.IO/Readers/ShapeFileReaderBase.cs (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -0,0 +1,108 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.IO;
+using System.Linq;
+using Core.Common.IO.Exceptions;
+using Core.Common.Utils;
+using Core.Common.Utils.Builders;
+using Core.Components.Gis.Data;
+using DotSpatial.Data;
+using CoreCommonUtilsResources = Core.Common.Utils.Properties.Resources;
+using GisIOResources = Core.Components.Gis.IO.Properties.Resources;
+
+namespace Core.Components.Gis.IO.Readers
+{
+ ///
+ /// The base class to read data from a shapefile.
+ ///
+ public abstract class ShapeFileReaderBase : IDisposable
+ {
+ protected readonly string FilePath;
+ protected Shapefile ShapeFile;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The path to the shape file.
+ /// Thrown when is invalid.
+ /// Thrown when
+ ///
+ /// - points to a file that doesn't exist.
+ /// - The shapefile has unexpected geometries in it.
+ ///
+ ///
+ protected ShapeFileReaderBase(string filePath)
+ {
+ FileUtils.ValidateFilePath(filePath);
+ if (!File.Exists(filePath))
+ {
+ string message = new FileReaderErrorMessageBuilder(filePath)
+ .Build(CoreCommonUtilsResources.Error_File_does_not_exist);
+ throw new CriticalFileReadException(message);
+ }
+
+ FilePath = filePath;
+ }
+
+ ///
+ /// Gets the number of lines in the shapefile.
+ ///
+ public int GetNumberOfLines()
+ {
+ return ShapeFile != null ? ShapeFile.Features.Count : 0;
+ }
+
+ ///
+ /// Determines whether the specified attribute has been defined in the shapefile attributes.
+ ///
+ /// Name of the attribute.
+ /// True is the attribute is defined, false otherwise.
+ /// This check is case-sensitive.
+ public bool HasAttribute(string attributeName)
+ {
+ return ShapeFile != null && ShapeFile.Attributes.Columns.Any(c => c.ColumnName == attributeName);
+ }
+
+ ///
+ /// Reads a line shape from the file.
+ ///
+ /// The representing the shape, or
+ /// null when at the end of the shapefile.
+ public abstract PointBasedMapData ReadLine(string name = null);
+
+ ///
+ /// Gets the feature at the given index.
+ ///
+ /// The index of which feature to retrieve.
+ /// The feature.
+ public abstract IFeature GetFeature(int index);
+
+ public void Dispose()
+ {
+ if (ShapeFile != null)
+ {
+ ShapeFile.Close();
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.Gis/Data/MapData.cs
===================================================================
diff -u -r80aeb6fb275f0d7ea3f470bb8ba0ef0fc5caa113 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Components/src/Core.Components.Gis/Data/MapData.cs (.../MapData.cs) (revision 80aeb6fb275f0d7ea3f470bb8ba0ef0fc5caa113)
+++ Core/Components/src/Core.Components.Gis/Data/MapData.cs (.../MapData.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -44,6 +44,9 @@
Name = name;
}
+ ///
+ /// The name of the .
+ ///
public string Name { get; private set; }
}
}
\ No newline at end of file
Index: Core/Components/src/Core.Components.Gis/Data/MapLineData.cs
===================================================================
diff -u -rc9f9c04e4fc62406231afd07d63cd7da11673ec6 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Components/src/Core.Components.Gis/Data/MapLineData.cs (.../MapLineData.cs) (revision c9f9c04e4fc62406231afd07d63cd7da11673ec6)
+++ Core/Components/src/Core.Components.Gis/Data/MapLineData.cs (.../MapLineData.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -47,8 +47,8 @@
}
///
- /// Gets the meta data associated with the line data.
+ /// Gets the meta data associated with the map data.
///
- public IDictionary MetaData { get; private set; }
+ public IDictionary MetaData { get; private set; }
}
}
\ No newline at end of file
Index: Core/Components/test/Core.Components.Gis.IO.Test/Core.Components.Gis.IO.Test.csproj
===================================================================
diff -u -r33c64ea2cd6b287bf5954e63a548d89dadb7f153 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Components/test/Core.Components.Gis.IO.Test/Core.Components.Gis.IO.Test.csproj (.../Core.Components.Gis.IO.Test.csproj) (revision 33c64ea2cd6b287bf5954e63a548d89dadb7f153)
+++ Core/Components/test/Core.Components.Gis.IO.Test/Core.Components.Gis.IO.Test.csproj (.../Core.Components.Gis.IO.Test.csproj) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -61,8 +61,11 @@
-
+
+
+
+
Fisheye: Tag 5e80369138024933a45f3e4ae721509dfb17d8fb refers to a dead (removed) revision in file `Core/Components/test/Core.Components.Gis.IO.Test/PolylineShapeFileReaderTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Core/Components/test/Core.Components.Gis.IO.Test/Readers/PointShapeFileReaderTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.Gis.IO.Test/Readers/PointShapeFileReaderTest.cs (revision 0)
+++ Core/Components/test/Core.Components.Gis.IO.Test/Readers/PointShapeFileReaderTest.cs (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -0,0 +1,257 @@
+using System.Linq;
+using Core.Common.IO.Exceptions;
+using Core.Common.TestUtil;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.IO.Readers;
+using NUnit.Framework;
+
+namespace Core.Components.Gis.IO.Test.Readers
+{
+ [TestFixture]
+ public class PointShapeFileReaderTest
+ {
+ [Test]
+ [TestCase("Single_Point_with_ID.shp")]
+ [TestCase("Multiple_Point_with_ID.shp")]
+ public void ParameteredConstructor_ExpectedValues(string shapeFileName)
+ {
+ // Setup
+ string testFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ shapeFileName);
+
+ // Call
+ using (var reader = new PointShapeFileReader(testFilePath))
+ {
+ // Assert
+ Assert.IsInstanceOf(reader);
+ }
+ }
+
+ [Test]
+ [TestCase("traject_10-1.shp")]
+ [TestCase("Single_Multi-Polygon_with_ID.shp")]
+ [TestCase("Multiple_Polygon_with_ID.shp")]
+ public void ParameteredConstructor_ShapeFileIsNotPointShapesfile_ThrowCriticalFileReadException(string shapeFileName)
+ {
+ // Setup
+ string nonPointShapeFile = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ shapeFileName);
+
+ // Call
+ TestDelegate call = () => new PointShapeFileReader(nonPointShapeFile);
+
+ // Assert
+ var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': Bestand bevat geometrieën die geen punt zijn.",
+ nonPointShapeFile);
+ var message = Assert.Throws(call).Message;
+ Assert.AreEqual(expectedMessage, message);
+ }
+
+ [Test]
+ public void GetNumberOfLines_EmptyPointShapeFile_ReturnZero()
+ {
+ // Setup
+ string shapeWithOneLine = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Empty_Point_with_ID.shp");
+ using (var reader = new PointShapeFileReader(shapeWithOneLine))
+ {
+ // Call
+ var count = reader.GetNumberOfLines();
+
+ // Assert
+ Assert.AreEqual(0, count);
+ }
+ }
+
+ [Test]
+ public void GetNumberOfLines_ShapeFileWithOnePointFeature_ReturnOne()
+ {
+ // Setup
+ string shapeWithOnePoint = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Single_Point_with_ID.shp");
+ using (var reader = new PointShapeFileReader(shapeWithOnePoint))
+ {
+ // Call
+ var count = reader.GetNumberOfLines();
+
+ // Assert
+ Assert.AreEqual(1, count);
+ }
+ }
+
+ [Test]
+ public void GetNumberOfLines_ShapeFileWithMultiplePointFeatures_ReturnThatNumberOfFeatures()
+ {
+ // Setup
+ string shapeWithMultiplePoints = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Multiple_Point_with_ID.shp");
+
+ using (var reader = new PointShapeFileReader(shapeWithMultiplePoints))
+ {
+ // Call
+ var count = reader.GetNumberOfLines();
+
+ // Assert
+ Assert.AreEqual(6, count);
+ }
+ }
+
+ [Test]
+ public void ReadLine_ShapeFileWithOnePointFeature_ReturnShape()
+ {
+ // Setup
+ string shapeWithOnePoint = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Single_Point_with_ID.shp");
+ using (var reader = new PointShapeFileReader(shapeWithOnePoint))
+ {
+ // Call
+ MapPointData point = reader.ReadLine() as MapPointData;
+
+ // Assert
+ Assert.IsNotNull(point);
+ var points = point.Points.ToArray();
+ Assert.AreEqual(1, points.Length);
+ Assert.AreEqual(1.705, points[0].X, 1e-1);
+ Assert.AreEqual(0.922, points[0].Y, 1e-1);
+ }
+ }
+
+ [Test]
+ public void ReadLine_ShapeFileWithMultiplePointFeatures_ReturnShapes()
+ {
+ // Setup
+ string shapeWithMultiplePoints = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Multiple_Point_with_ID.shp");
+ using (var reader = new PointShapeFileReader(shapeWithMultiplePoints))
+ {
+ // Precondition
+ Assert.AreEqual(6, reader.GetNumberOfLines());
+
+ // Call
+ MapPointData point1 = reader.ReadLine() as MapPointData;
+ MapPointData point2 = reader.ReadLine() as MapPointData;
+ MapPointData point3 = reader.ReadLine() as MapPointData;
+ MapPointData point4 = reader.ReadLine() as MapPointData;
+ MapPointData point5 = reader.ReadLine() as MapPointData;
+ MapPointData point6 = reader.ReadLine() as MapPointData;
+
+ // Assert
+
+ #region Assertsions for 'point1'
+
+ var point1Points = point1.Points.ToArray();
+ Assert.AreEqual(1, point1Points.Length);
+ Assert.AreEqual(-1.750, point1Points[0].X, 1e-1);
+ Assert.AreEqual(-0.488, point1Points[0].Y, 1e-1);
+
+ #endregion
+
+ #region Assertsions for 'point2'
+
+ var point2Points = point2.Points.ToArray();
+ Assert.AreEqual(1, point2Points.Length);
+ Assert.AreEqual(-0.790, point2Points[0].X, 1e-1);
+ Assert.AreEqual(-0.308, point2Points[0].Y, 1e-1);
+
+ #endregion
+
+ #region Assertsions for 'point3'
+
+ var point3Points = point3.Points.ToArray();
+ Assert.AreEqual(1, point3Points.Length);
+ Assert.AreEqual(0.740, point3Points[0].X, 1e-1);
+ Assert.AreEqual(-0.577, point3Points[0].Y, 1e-1);
+
+ #endregion
+
+ #region Assertsions for 'point4'
+
+ var point4Points = point4.Points.ToArray();
+ Assert.AreEqual(1, point4Points.Length);
+ Assert.AreEqual(0.787, point4Points[0].X, 1e-1);
+ Assert.AreEqual(0.759, point4Points[0].Y, 1e-1);
+
+ #endregion
+
+ #region Assertsions for 'point5'
+
+ var point5Points = point5.Points.ToArray();
+ Assert.AreEqual(1, point5Points.Length);
+ Assert.AreEqual(-0.544, point5Points[0].X, 1e-1);
+ Assert.AreEqual(0.283, point5Points[0].Y, 1e-1);
+
+ #endregion
+
+ #region Assertsions for 'point6'
+
+ var point6Points = point6.Points.ToArray();
+ Assert.AreEqual(1, point6Points.Length);
+ Assert.AreEqual(-2.066, point6Points[0].X, 1e-1);
+ Assert.AreEqual(0.827, point6Points[0].Y, 1e-1);
+
+ #endregion
+ }
+ }
+
+ [Test]
+ [TestCase("Empty_Point_with_ID.shp")]
+ [TestCase("Single_Point_with_ID.shp")]
+ [TestCase("Multiple_Point_with_ID.shp")]
+ public void ReadLine_WhenAtEndOfShapeFile_ReturnNull(string fileName)
+ {
+ // Setup
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ fileName);
+ using (var reader = new PointShapeFileReader(filePath))
+ {
+ for (int i = 0; i < reader.GetNumberOfLines(); i++)
+ {
+ reader.ReadLine();
+ }
+
+ // Call
+ MapPointData point = reader.ReadLine() as MapPointData;
+
+ // Assert
+ Assert.IsNull(point);
+ }
+ }
+
+ [Test]
+ public void HasAttribute_AttributeInShapefile_ReturnTrue()
+ {
+ // Setup
+ string shapefileFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Single_Point_with_ID.shp");
+ using (var reader = new PointShapeFileReader(shapefileFilePath))
+ {
+ // Call
+ bool result = reader.HasAttribute("id");
+
+ // Assert
+ Assert.IsTrue(result);
+ }
+ }
+
+ [Test]
+ [TestCase("id", true)]
+ [TestCase("ID", false)]
+ [TestCase("Id", false)]
+ [TestCase("iD", false)]
+ [TestCase("Im_not_in_file", false)]
+ public void HasAttribute_VariousCases_ReturnTrueIfMatchesInProperCaseHasBeenFound(string attributeName, bool expectedResult)
+ {
+ // Setup
+ string shapefileFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Single_Point_with_ID.shp");
+ using (var reader = new PointShapeFileReader(shapefileFilePath))
+ {
+ // Call
+ bool result = reader.HasAttribute(attributeName);
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolygonShapeFileReaderTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolygonShapeFileReaderTest.cs (revision 0)
+++ Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolygonShapeFileReaderTest.cs (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -0,0 +1,242 @@
+using System.Linq;
+using Core.Common.IO.Exceptions;
+using Core.Common.TestUtil;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.IO.Readers;
+using NUnit.Framework;
+
+namespace Core.Components.Gis.IO.Test.Readers
+{
+ [TestFixture]
+ public class PolygonShapeFileReaderTest
+ {
+ [Test]
+ [TestCase("Single_Multi-Polygon_with_ID.shp")]
+ [TestCase("Single_Polygon_with_ID.shp")]
+ [TestCase("Multiple_Polygon_with_ID.shp")]
+ public void ParameteredConstructor_ExpectedValues(string shapeFileName)
+ {
+ // Setup
+ string testFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ shapeFileName);
+
+ // Call
+ using (var reader = new PolygonShapeFileReader(testFilePath))
+ {
+ // Assert
+ Assert.IsInstanceOf(reader);
+ }
+ }
+
+ [Test]
+ [TestCase("traject_10-1.shp")]
+ [TestCase("Empty_Point_with_ID.shp")]
+ [TestCase("Single_Point_with_ID.shp")]
+ [TestCase("Multiple_Point_with_ID.shp")]
+ [TestCase("Empty_PolyLine_with_ID.shp")]
+ [TestCase("Single_Multi-PolyLine_with_ID.shp")]
+ [TestCase("Multiple_PolyLine_with_ID.shp")]
+ public void ParameteredConstructor_ShapeFileIsNotPolygonShapesfile_ThrowCriticalFileReadException(string shapeFileName)
+ {
+ // Setup
+ string nonPolygonShapeFile = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ shapeFileName);
+
+ // Call
+ TestDelegate call = () => new PolygonShapeFileReader(nonPolygonShapeFile);
+
+ // Assert
+ var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': Bestand bevat geometrieën die geen polygonen zijn.",
+ nonPolygonShapeFile);
+ var message = Assert.Throws(call).Message;
+ Assert.AreEqual(expectedMessage, message);
+ }
+
+ [Test]
+ public void GetNumberOfLines_EmptyPolygonShapeFile_ReturnZero()
+ {
+ // Setup
+ string shapeWithOnePolygon = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Empty_Polygon_with_ID.shp");
+ using (var reader = new PolygonShapeFileReader(shapeWithOnePolygon))
+ {
+ // Call
+ var count = reader.GetNumberOfLines();
+
+ // Assert
+ Assert.AreEqual(0, count);
+ }
+ }
+
+ [Test]
+ public void GetNumberOfLines_ShapeFileWithOnePolygonFeature_ReturnOne()
+ {
+ // Setup
+ string shapeWithOnePolygon = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Single_Polygon_with_ID.shp");
+ using (var reader = new PolygonShapeFileReader(shapeWithOnePolygon))
+ {
+ // Call
+ var count = reader.GetNumberOfLines();
+
+ // Assert
+ Assert.AreEqual(1, count);
+ }
+ }
+
+ [Test]
+ public void GetNumberOfLines_ShapeFileWithMultipleLineFeatures_ReturnThatNumberOfFeatures()
+ {
+ // Setup
+ string shapeWithMultiplePolygons = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Multiple_Polygon_with_ID.shp");
+
+ using (var reader = new PolygonShapeFileReader(shapeWithMultiplePolygons))
+ {
+ // Call
+ var count = reader.GetNumberOfLines();
+
+ // Assert
+ Assert.AreEqual(4, count);
+ }
+ }
+
+ [Test]
+ public void ReadLine_ShapeFileWithOneLineFeature_ReturnShape()
+ {
+ // Setup
+ string shapeWithOneLine = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Single_Polygon_with_ID.shp");
+ using (var reader = new PolygonShapeFileReader(shapeWithOneLine))
+ {
+ // Call
+ MapPolygonData polygon = reader.ReadLine() as MapPolygonData;
+
+ // Assert
+ Assert.IsNotNull(polygon);
+ var points = polygon.Points.ToArray();
+ Assert.AreEqual(30, points.Length);
+ Assert.AreEqual(-0.264, points[25].X, 1e-1);
+ Assert.AreEqual(0.169, points[25].Y, 1e-1);
+ }
+ }
+
+ [Test]
+ public void ReadLine_ShapeFileWithMultiplePolygonFeatures_ReturnShapes()
+ {
+ // Setup
+ string shapeWithMultiplePolygons = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Multiple_Polygon_with_ID.shp");
+ using (var reader = new PolygonShapeFileReader(shapeWithMultiplePolygons))
+ {
+ // Precondition
+ Assert.AreEqual(4, reader.GetNumberOfLines());
+
+ // Call
+ MapPolygonData polygon1 = reader.ReadLine() as MapPolygonData;
+ MapPolygonData polygon2 = reader.ReadLine() as MapPolygonData;
+ MapPolygonData polygon3 = reader.ReadLine() as MapPolygonData;
+ MapPolygonData polygon4 = reader.ReadLine() as MapPolygonData;
+
+ // Assert
+
+ #region Assertsions for 'polygon1'
+
+ var polygon1Points = polygon1.Points.ToArray();
+ Assert.AreEqual(6, polygon1Points.Length);
+ Assert.AreEqual(-1.070, polygon1Points[2].X, 1e-1);
+ Assert.AreEqual(0.066, polygon1Points[2].Y, 1e-1);
+
+ #endregion
+
+ #region Assertsions for 'polygon2'
+
+ var polygon2Points = polygon2.Points.ToArray();
+ Assert.AreEqual(25, polygon2Points.Length);
+ Assert.AreEqual(-2.172, polygon2Points[23].X, 1e-1);
+ Assert.AreEqual(0.212, polygon2Points[23].Y, 1e-1);
+
+ #endregion
+
+ #region Assertsions for 'polygon3'
+
+ var polygon3Points = polygon3.Points.ToArray();
+ Assert.AreEqual(10, polygon3Points.Length);
+ Assert.AreEqual(-1.091, polygon3Points[0].X, 1e-1);
+ Assert.AreEqual(0.566, polygon3Points[0].Y, 1e-1);
+
+ #endregion
+
+ #region Assertsions for 'polygon4'
+
+ var polygon4Points = polygon4.Points.ToArray();
+ Assert.AreEqual(9, polygon4Points.Length);
+ Assert.AreEqual(-1.917, polygon4Points[8].X, 1e-1);
+ Assert.AreEqual(0.759, polygon4Points[8].Y, 1e-1);
+
+ #endregion
+ }
+ }
+
+ [Test]
+ [TestCase("Single_Multi-Polygon_with_ID.shp")]
+ [TestCase("Single_Polygon_with_ID.shp")]
+ [TestCase("Multiple_Polygon_with_ID.shp")]
+ public void ReadLine_WhenAtEndOfShapeFile_ReturnNull(string fileName)
+ {
+ // Setup
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ fileName);
+ using (var reader = new PolygonShapeFileReader(filePath))
+ {
+ for (int i = 0; i < reader.GetNumberOfLines(); i++)
+ {
+ reader.ReadLine();
+ }
+
+ // Call
+ MapPolygonData polygon = reader.ReadLine() as MapPolygonData;
+
+ // Assert
+ Assert.IsNull(polygon);
+ }
+ }
+
+ [Test]
+ public void HasAttribute_AttributeInShapefile_ReturnTrue()
+ {
+ // Setup
+ string shapefileFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Single_Polygon_with_ID.shp");
+ using (var reader = new PolygonShapeFileReader(shapefileFilePath))
+ {
+ // Call
+ bool result = reader.HasAttribute("id");
+
+ // Assert
+ Assert.IsTrue(result);
+ }
+ }
+
+ [Test]
+ [TestCase("id", true)]
+ [TestCase("ID", false)]
+ [TestCase("Id", false)]
+ [TestCase("iD", false)]
+ [TestCase("Im_not_in_file", false)]
+ public void HasAttribute_VariousCases_ReturnTrueIfMatchesInProperCaseHasBeenFound(string attributeName, bool expectedResult)
+ {
+ // Setup
+ string shapefileFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Single_Polygon_with_ID.shp");
+ using (var reader = new PolygonShapeFileReader(shapefileFilePath))
+ {
+ // Call
+ bool result = reader.HasAttribute(attributeName);
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+ }
+ }
+}
Index: Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolylineShapeFileReaderTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolylineShapeFileReaderTest.cs (revision 0)
+++ Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolylineShapeFileReaderTest.cs (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -0,0 +1,277 @@
+using System;
+using System.IO;
+using System.Linq;
+using Core.Common.IO.Exceptions;
+using Core.Common.TestUtil;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.IO.Readers;
+using NUnit.Framework;
+
+namespace Core.Components.Gis.IO.Test.Readers
+{
+ [TestFixture]
+ public class PolylineShapeFileReaderTest
+ {
+ [Test]
+ public void ParameteredConstructor_ExpectedValues()
+ {
+ // Setup
+ string testFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "traject_10-1.shp");
+
+ // Call
+ using (var reader = new PolylineShapeFileReader(testFilePath))
+ {
+ // Assert
+ Assert.IsInstanceOf(reader);
+ }
+ }
+
+ [Test]
+ [TestCase("Single_Point_with_ID.shp")]
+ [TestCase("Multiple_Point_with_ID.shp")]
+ [TestCase("Single_Multi-Polygon_with_ID.shp")]
+ [TestCase("Multiple_Polygon_with_ID.shp")]
+ public void ParameteredConstructor_ShapeFileIsNotLinesShapesfile_ThrowCriticalFileReadException(string shapeFileName)
+ {
+ // Setup
+ string nonLineShapeFile = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ shapeFileName);
+
+ // Call
+ TestDelegate call = () => new PolylineShapeFileReader(nonLineShapeFile);
+
+ // Assert
+ var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': Bestand bevat geometrieën die geen lijn zijn.",
+ nonLineShapeFile);
+ var message = Assert.Throws(call).Message;
+ Assert.AreEqual(expectedMessage, message);
+ }
+
+ [Test]
+ public void GetNumberOfLines_EmptyLineShapeFile_ReturnZero()
+ {
+ // Setup
+ string shapeWithOneLine = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Empty_PolyLine_with_ID.shp");
+ using (var reader = new PolylineShapeFileReader(shapeWithOneLine))
+ {
+ // Call
+ var count = reader.GetNumberOfLines();
+
+ // Assert
+ Assert.AreEqual(0, count);
+ }
+ }
+
+ [Test]
+ public void GetNumberOfLines_ShapeFileWithOneLineFeature_ReturnOne()
+ {
+ // Setup
+ string shapeWithOneLine = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "traject_10-1.shp");
+ using (var reader = new PolylineShapeFileReader(shapeWithOneLine))
+ {
+ // Call
+ var count = reader.GetNumberOfLines();
+
+ // Assert
+ Assert.AreEqual(1, count);
+ }
+ }
+
+ [Test]
+ public void GetNumberOfLines_ShapeFileWithMultipleLineFeatures_ReturnThatNumberOfFeatures()
+ {
+ // Setup
+ string shapeWithMultipleLines = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Multiple_PolyLine_with_ID.shp");
+
+ using (var reader = new PolylineShapeFileReader(shapeWithMultipleLines))
+ {
+ // Call
+ var count = reader.GetNumberOfLines();
+
+ // Assert
+ Assert.AreEqual(4, count);
+ }
+ }
+
+ [Test]
+ public void ReadLine_ShapeFileWithOneLineFeature_ReturnShape()
+ {
+ // Setup
+ string shapeWithOneLine = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "traject_10-1.shp");
+ using (var reader = new PolylineShapeFileReader(shapeWithOneLine))
+ {
+ // Call
+ MapLineData line = reader.ReadLine() as MapLineData;
+
+ // Assert
+ Assert.IsNotNull(line);
+ var points = line.Points.ToArray();
+ Assert.AreEqual(1669, points.Length);
+ Assert.AreEqual(202714.219, points[457].X, 1e-6);
+ Assert.AreEqual(507775.781, points[457].Y, 1e-6);
+
+ Assert.AreEqual(6, line.MetaData.Count);
+ Assert.AreEqual("A", line.MetaData["CATEGORIE"]);
+ Assert.AreEqual("10", line.MetaData["DIJKRING"]);
+ Assert.AreEqual(19190.35000000, line.MetaData["LENGTE_TRJ"]);
+ Assert.AreEqual("1:1000", line.MetaData["Ondergrens"]);
+ Assert.AreEqual("1:3000", line.MetaData["Signalerin"]);
+ Assert.AreEqual("10-1", line.MetaData["TRAJECT_ID"]);
+ }
+ }
+
+ [Test]
+ public void ReadLine_ShapeFileWithMultipleLineFeatures_ReturnShapes()
+ {
+ // Setup
+ string shapeWithMultipleLines = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Multiple_PolyLine_with_ID.shp");
+ using (var reader = new PolylineShapeFileReader(shapeWithMultipleLines))
+ {
+ // Precondition
+ Assert.AreEqual(4, reader.GetNumberOfLines());
+
+ // Call
+ MapLineData line1 = reader.ReadLine() as MapLineData;
+ MapLineData line2 = reader.ReadLine() as MapLineData;
+ MapLineData line3 = reader.ReadLine() as MapLineData;
+ MapLineData line4 = reader.ReadLine() as MapLineData;
+
+ // Assert
+
+ #region Assertions for 'line1'
+
+ var line1Points = line1.Points.ToArray();
+ Assert.AreEqual(15, line1Points.Length);
+ Assert.AreEqual(-1.514151, line1Points[2].X, 1e-6);
+ Assert.AreEqual(-0.879717, line1Points[2].Y, 1e-6);
+
+ Assert.AreEqual(1, line1.MetaData.Count);
+ Assert.AreEqual(4, line1.MetaData["id"]);
+
+ #endregion
+
+ #region Assertions for 'line2'
+
+ var line2Points = line2.Points.ToArray();
+ Assert.AreEqual(6, line2Points.Length);
+ Assert.AreEqual(-2.028302, line2Points[3].X, 1e-6);
+ Assert.AreEqual(-0.382075, line2Points[3].Y, 1e-6);
+
+ Assert.AreEqual(1, line2.MetaData.Count);
+ Assert.AreEqual(3, line2.MetaData["id"]);
+
+ #endregion
+
+ #region Assertions for 'line3'
+
+ var line3Points = line3.Points.ToArray();
+ Assert.AreEqual(13, line3Points.Length);
+ Assert.AreEqual(0.891509, line3Points[12].X, 1e-6);
+ Assert.AreEqual(-0.122641, line3Points[12].Y, 1e-6);
+
+ Assert.AreEqual(1, line3.MetaData.Count);
+ Assert.AreEqual(2, line3.MetaData["id"]);
+
+ #endregion
+
+ #region Assertions for 'line4'
+
+ var line4Points = line4.Points.ToArray();
+ Assert.AreEqual(6, line4Points.Length);
+ Assert.AreEqual(-2.070754, line4Points[0].X, 1e-6);
+ Assert.AreEqual(0.73584906, line4Points[0].Y, 1e-6);
+
+ Assert.AreEqual(1, line4.MetaData.Count);
+ Assert.AreEqual(1, line4.MetaData["id"]);
+
+ #endregion
+ }
+ }
+
+ [Test]
+ [TestCase("Empty_PolyLine_with_ID.shp")]
+ [TestCase("traject_10-1.shp")]
+ [TestCase("Multiple_PolyLine_with_ID.shp")]
+ public void ReadLine_WhenAtEndOfShapeFile_ReturnNull(string shapeFileName)
+ {
+ // Setup
+ string linesShapefileFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ shapeFileName);
+ using (var reader = new PolylineShapeFileReader(linesShapefileFilePath))
+ {
+ for (int i = 0; i < reader.GetNumberOfLines(); i++)
+ {
+ reader.ReadLine();
+ }
+
+ // Call
+ MapLineData line = reader.ReadLine() as MapLineData;
+
+ // Assert
+ Assert.IsNull(line);
+ }
+ }
+
+ [Test]
+ public void ReadLine_ShapeFileIsIsMultiLine_ThrowCriticalFileReadException()
+ {
+ // Setup
+ string nonLineShapeFile = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Single_Multi-PolyLine_with_ID.shp");
+
+ var reader = new PolylineShapeFileReader(nonLineShapeFile);
+
+ // Call
+ TestDelegate call = () => reader.ReadLine();
+
+ // Assert
+ var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}' op index 0: Ingelezen element is een 'multi-lijn'; alleen enkelvoudige lijn elementen worden ondersteund.",
+ nonLineShapeFile);
+ var message = Assert.Throws(call).Message;
+ Assert.AreEqual(expectedMessage, message);
+ }
+
+ [Test]
+ public void HasAttribute_AttributeInShapefile_ReturnTrue()
+ {
+ // Setup
+ string shapefileFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Multiple_PolyLine_with_ID.shp");
+ using (var reader = new PolylineShapeFileReader(shapefileFilePath))
+ {
+ // Call
+ bool result = reader.HasAttribute("id");
+
+ // Assert
+ Assert.IsTrue(result);
+ }
+ }
+
+ [Test]
+ [TestCase("id", true)]
+ [TestCase("ID", false)]
+ [TestCase("Id", false)]
+ [TestCase("iD", false)]
+ [TestCase("Im_not_in_file", false)]
+ public void HasAttribute_VariousCases_ReturnTrueIfMatchesInProperCaseHasBeenFound(string attributeName, bool expectedResult)
+ {
+ // Setup
+ string shapefileFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "Multiple_PolyLine_with_ID.shp");
+ using (var reader = new PolylineShapeFileReader(shapefileFilePath))
+ {
+ // Call
+ bool result = reader.HasAttribute(attributeName);
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/test/Core.Components.Gis.IO.Test/Readers/ShapeFileReaderBaseTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.Gis.IO.Test/Readers/ShapeFileReaderBaseTest.cs (revision 0)
+++ Core/Components/test/Core.Components.Gis.IO.Test/Readers/ShapeFileReaderBaseTest.cs (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -0,0 +1,128 @@
+using System;
+using System.IO;
+using Core.Common.IO.Exceptions;
+using Core.Common.TestUtil;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.IO.Readers;
+using DotSpatial.Data;
+using NUnit.Framework;
+
+namespace Core.Components.Gis.IO.Test.Readers
+{
+ [TestFixture]
+ public class ShapeFileReaderBaseTest
+ {
+ [Test]
+ public void ParameteredConstructor_ExpectedValues()
+ {
+ // Setup
+ string testFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "traject_10-1.shp");
+
+ // Call
+ using (var reader = new TestShapeFileReaderBase(testFilePath))
+ {
+ // Assert
+ Assert.IsInstanceOf(reader);
+ Assert.AreEqual(testFilePath, reader.GetFilePath);
+ Assert.IsNull(reader.GetShapeFile);
+ }
+ }
+
+ [Test]
+ [TestCase("")]
+ [TestCase(" ")]
+ [TestCase(null)]
+ public void ParameteredConstructor_NoFilePath_ThrowArgumentException(string invalidFilePath)
+ {
+ // Call
+ TestDelegate call = () => new TestShapeFileReaderBase(invalidFilePath);
+
+ // Assert
+ var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': Bestandspad mag niet leeg of ongedefinieerd zijn.",
+ invalidFilePath);
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+ }
+
+ [Test]
+ public void ParameteredConstructor_FileDoesNotExist_ThrowArgumentException()
+ {
+ // Call
+ string pathToNotExistingShapeFile = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "I_do_not_exist.shp");
+ TestDelegate call = () => new TestShapeFileReaderBase(pathToNotExistingShapeFile);
+
+ // Assert
+ var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': Het bestand bestaat niet.",
+ pathToNotExistingShapeFile);
+ var message = Assert.Throws(call).Message;
+ Assert.AreEqual(expectedMessage, message);
+ }
+
+ [Test]
+ public void ParameteredConstructor_FilePathHasInvalidPathCharacter_ThrowArgumentException()
+ {
+ // Setup
+ char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
+
+ string validFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ "traject_10-1.shp");
+ string invalidFilePath = validFilePath.Replace("_", invalidFileNameChars[0].ToString());
+
+ // Call
+ TestDelegate call = () => new TestShapeFileReaderBase(invalidFilePath);
+
+ // Assert
+ var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': Bestandspad mag niet de volgende tekens bevatten: {1}",
+ invalidFilePath, String.Join(", ", invalidFileNameChars));
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+ }
+
+ [Test]
+ public void ParameteredConstructor_FilePathIsActuallyDirectoryPath_ThrowArgumentException()
+ {
+ // Setup
+ string invalidFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO,
+ Path.DirectorySeparatorChar.ToString());
+
+ // Call
+ TestDelegate call = () => new TestShapeFileReaderBase(invalidFilePath);
+
+ // Assert
+ var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': Bestandspad mag niet naar een map verwijzen.",
+ invalidFilePath);
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+ }
+
+ private class TestShapeFileReaderBase : ShapeFileReaderBase
+ {
+ public TestShapeFileReaderBase(string filePath) : base(filePath) {}
+
+ public override PointBasedMapData ReadLine(string name = null)
+ {
+ return null;
+ }
+
+ public override IFeature GetFeature(int index)
+ {
+ return null;
+ }
+
+ public string GetFilePath
+ {
+ get
+ {
+ return FilePath;
+ }
+ }
+
+ public Shapefile GetShapeFile
+ {
+ get
+ {
+ return ShapeFile;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Point_with_ID.dbf
===================================================================
diff -u
Binary files differ
Index: Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Point_with_ID.prj
===================================================================
diff -u
--- Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Point_with_ID.prj (revision 0)
+++ Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Point_with_ID.prj (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -0,0 +1 @@
+PROJCS["Amersfoort_RD_New",GEOGCS["GCS_Amersfoort",DATUM["D_Amersfoort",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Double_Stereographic"],PARAMETER["latitude_of_origin",52.15616055555555],PARAMETER["central_meridian",5.38763888888889],PARAMETER["scale_factor",0.9999079],PARAMETER["false_easting",155000],PARAMETER["false_northing",463000],UNIT["Meter",1]]
\ No newline at end of file
Index: Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Point_with_ID.qpj
===================================================================
diff -u
--- Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Point_with_ID.qpj (revision 0)
+++ Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Point_with_ID.qpj (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -0,0 +1 @@
+PROJCS["Amersfoort / RD New",GEOGCS["Amersfoort",DATUM["Amersfoort",SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],TOWGS84[565.4171,50.3319,465.5524,-0.398957388243134,0.343987817378283,-1.87740163998045,4.0725],AUTHORITY["EPSG","6289"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4289"]],PROJECTION["Oblique_Stereographic"],PARAMETER["latitude_of_origin",52.15616055555555],PARAMETER["central_meridian",5.38763888888889],PARAMETER["scale_factor",0.9999079],PARAMETER["false_easting",155000],PARAMETER["false_northing",463000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],AUTHORITY["EPSG","28992"]]
Index: Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Point_with_ID.shp
===================================================================
diff -u
Binary files differ
Index: Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Point_with_ID.shx
===================================================================
diff -u
Binary files differ
Index: Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Polygon_with_ID.dbf
===================================================================
diff -u
Binary files differ
Index: Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Polygon_with_ID.prj
===================================================================
diff -u
--- Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Polygon_with_ID.prj (revision 0)
+++ Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Polygon_with_ID.prj (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -0,0 +1 @@
+PROJCS["Amersfoort_RD_New",GEOGCS["GCS_Amersfoort",DATUM["D_Amersfoort",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Double_Stereographic"],PARAMETER["latitude_of_origin",52.15616055555555],PARAMETER["central_meridian",5.38763888888889],PARAMETER["scale_factor",0.9999079],PARAMETER["false_easting",155000],PARAMETER["false_northing",463000],UNIT["Meter",1]]
\ No newline at end of file
Index: Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Polygon_with_ID.qpj
===================================================================
diff -u
--- Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Polygon_with_ID.qpj (revision 0)
+++ Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Polygon_with_ID.qpj (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -0,0 +1 @@
+PROJCS["Amersfoort / RD New",GEOGCS["Amersfoort",DATUM["Amersfoort",SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],TOWGS84[565.4171,50.3319,465.5524,-0.398957388243134,0.343987817378283,-1.87740163998045,4.0725],AUTHORITY["EPSG","6289"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4289"]],PROJECTION["Oblique_Stereographic"],PARAMETER["latitude_of_origin",52.15616055555555],PARAMETER["central_meridian",5.38763888888889],PARAMETER["scale_factor",0.9999079],PARAMETER["false_easting",155000],PARAMETER["false_northing",463000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],AUTHORITY["EPSG","28992"]]
Index: Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Polygon_with_ID.shp
===================================================================
diff -u
Binary files differ
Index: Core/Components/test/Core.Components.Gis.IO.Test/test-data/Empty_Polygon_with_ID.shx
===================================================================
diff -u
Binary files differ
Index: Core/Plugins/src/Core.Plugins.DotSpatial/Core.Plugins.DotSpatial.csproj
===================================================================
diff -u -r86e717a5477d55d1c4351f2857a1d76e220a3ab4 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Plugins/src/Core.Plugins.DotSpatial/Core.Plugins.DotSpatial.csproj (.../Core.Plugins.DotSpatial.csproj) (revision 86e717a5477d55d1c4351f2857a1d76e220a3ab4)
+++ Core/Plugins/src/Core.Plugins.DotSpatial/Core.Plugins.DotSpatial.csproj (.../Core.Plugins.DotSpatial.csproj) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -32,6 +32,26 @@
AllRules.ruleset
+
+ ..\..\..\..\packages\DotSpatial.Data.1.7\lib\net40-Client\DotSpatial.Data.dll
+ True
+
+
+ ..\..\..\..\packages\DotSpatial.Mono.1.7\lib\net40-Client\DotSpatial.Mono.dll
+ True
+
+
+ ..\..\..\..\packages\DotSpatial.Projections.1.7\lib\net40-Client\DotSpatial.Projections.dll
+ True
+
+
+ ..\..\..\..\packages\DotSpatial.Serialization.1.7\lib\net40-Client\DotSpatial.Serialization.dll
+ True
+
+
+ ..\..\..\..\packages\DotSpatial.Topology.1.7\lib\net40-Client\DotSpatial.Topology.dll
+ True
+
..\..\..\..\packages\Fluent.Ribbon.3.4.0\lib\net40\Fluent.dll
True
@@ -95,6 +115,16 @@
Core.Common.Gui
False
+
+ {e344867e-9ac9-44c8-88a5-8185681679a9}
+ Core.Common.IO
+ False
+
+
+ {f49bd8b2-332a-4c91-a196-8cce0a2c7d98}
+ Core.Common.Utils
+ False
+
{c90b77da-e421-43cc-b82e-529651bc21ac}
Core.Common.Version
@@ -109,6 +139,11 @@
Core.Components.Gis.Forms
False
+
+ {fd264fad-e6f9-47cc-97cd-770199a8e629}
+ Core.Components.Gis.IO
+ False
+
{318ba582-88c9-4816-a54a-a7e431461de3}
Core.Components.Gis
@@ -157,6 +192,9 @@
+
+
+
-
-
-
-
-
-
-
\ No newline at end of file
Index: Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.cs
===================================================================
diff -u -r30b12b82918d500fe834eafd9f6cd9b2c5dbe60f -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.cs (.../LegendView.cs) (revision 30b12b82918d500fe834eafd9f6cd9b2c5dbe60f)
+++ Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.cs (.../LegendView.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -53,7 +53,7 @@
CanDrag = (pointData, parentData) => true,
CanCheck = pointData => true,
IsChecked = pointData => pointData.IsVisible,
- OnNodeChecked = PointDataOnNodeChecked
+ OnNodeChecked = PointBasedChartDataOnNodeChecked
});
treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo
@@ -63,7 +63,7 @@
CanDrag = (lineData, parentData) => true,
CanCheck = lineData => true,
IsChecked = lineData => lineData.IsVisible,
- OnNodeChecked = LineDataOnNodeChecked
+ OnNodeChecked = PointBasedChartDataOnNodeChecked
});
treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo
@@ -73,7 +73,7 @@
CanDrag = (areaData, parentData) => true,
CanCheck = areaData => true,
IsChecked = areaData => areaData.IsVisible,
- OnNodeChecked = AreaDataOnNodeChecked
+ OnNodeChecked = PointBasedChartDataOnNodeChecked
});
treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo
@@ -118,21 +118,6 @@
# region ChartData
- private static void PointDataOnNodeChecked(PointData pointData, object parentData)
- {
- PointBasedChartDataOnNodeChecked(pointData, parentData);
- }
-
- private static void LineDataOnNodeChecked(LineData lineData, object parentData)
- {
- PointBasedChartDataOnNodeChecked(lineData, parentData);
- }
-
- private static void AreaDataOnNodeChecked(AreaData areaData, object parentData)
- {
- PointBasedChartDataOnNodeChecked(areaData, parentData);
- }
-
private static void PointBasedChartDataOnNodeChecked(PointBasedChartData pointBasedChartData, object parentData)
{
pointBasedChartData.IsVisible = !pointBasedChartData.IsVisible;
Index: Core/Plugins/test/Core.Plugins.DotSpatial.Test/Commands/ToggleMapLegendViewCommandTest.cs
===================================================================
diff -u -r70686cbe24e58c091018219365a4bfa0c3c62685 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Plugins/test/Core.Plugins.DotSpatial.Test/Commands/ToggleMapLegendViewCommandTest.cs (.../ToggleMapLegendViewCommandTest.cs) (revision 70686cbe24e58c091018219365a4bfa0c3c62685)
+++ Core/Plugins/test/Core.Plugins.DotSpatial.Test/Commands/ToggleMapLegendViewCommandTest.cs (.../ToggleMapLegendViewCommandTest.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -1,4 +1,5 @@
-using Core.Common.Controls.Commands;
+using System.Windows.Forms;
+using Core.Common.Controls.Commands;
using Core.Common.Gui;
using Core.Common.Gui.ContextMenu;
using Core.Plugins.DotSpatial.Commands;
@@ -39,13 +40,14 @@
// Setup
var mocks = new MockRepository();
var plugin = mocks.StrictMock();
+ var parentWindow = mocks.StrictMock();
plugin.Expect(p => p.IsToolWindowOpen()).Return(open);
var contextMenuBuilderProvider = mocks.StrictMock();
mocks.ReplayAll();
- var controller = new MapLegendController(plugin, contextMenuBuilderProvider);
+ var controller = new MapLegendController(plugin, contextMenuBuilderProvider, parentWindow);
var command = new ToggleMapLegendViewCommand(controller);
// Call
@@ -63,6 +65,7 @@
var mocks = new MockRepository();
var plugin = mocks.StrictMock();
var contextMenuBuilderProvider = mocks.StrictMock();
+ var parentWindow = mocks.StrictMock();
// Open first
using (mocks.Ordered())
@@ -76,7 +79,7 @@
}
mocks.ReplayAll();
- var controller = new MapLegendController(plugin, contextMenuBuilderProvider);
+ var controller = new MapLegendController(plugin, contextMenuBuilderProvider, parentWindow);
var command = new ToggleMapLegendViewCommand(controller);
// Call
Index: Core/Plugins/test/Core.Plugins.DotSpatial.Test/Core.Plugins.DotSpatial.Test.csproj
===================================================================
diff -u -r86e717a5477d55d1c4351f2857a1d76e220a3ab4 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Plugins/test/Core.Plugins.DotSpatial.Test/Core.Plugins.DotSpatial.Test.csproj (.../Core.Plugins.DotSpatial.Test.csproj) (revision 86e717a5477d55d1c4351f2857a1d76e220a3ab4)
+++ Core/Plugins/test/Core.Plugins.DotSpatial.Test/Core.Plugins.DotSpatial.Test.csproj (.../Core.Plugins.DotSpatial.Test.csproj) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -67,6 +67,7 @@
+
@@ -104,6 +105,10 @@
{F49BD8B2-332A-4C91-A196-8CCE0A2C7D98}
Core.Common.Utils
+
+ {26214BD0-DAFB-4CFC-8EB2-80C5D53C859E}
+ Core.Common.Gui.TestUtil
+
{D749EE4C-CE50-4C17-BF01-9A953028C126}
Core.Common.TestUtil
Index: Core/Plugins/test/Core.Plugins.DotSpatial.Test/DotSpatialGuiPluginTest.cs
===================================================================
diff -u -r30b12b82918d500fe834eafd9f6cd9b2c5dbe60f -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Plugins/test/Core.Plugins.DotSpatial.Test/DotSpatialGuiPluginTest.cs (.../DotSpatialGuiPluginTest.cs) (revision 30b12b82918d500fe834eafd9f6cd9b2c5dbe60f)
+++ Core/Plugins/test/Core.Plugins.DotSpatial.Test/DotSpatialGuiPluginTest.cs (.../DotSpatialGuiPluginTest.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -78,12 +78,15 @@
{
var gui = mocks.StrictMock();
+ var mainWindow = mocks.StrictMock();
+
gui.Stub(g => g.IsToolWindowOpen()).Return(false);
gui.Expect(g => g.OpenToolView(Arg.Matches(c => true)));
gui.Expect(g => g.ActiveViewChanged += null).IgnoreArguments();
gui.Expect(g => g.ActiveViewChanged -= null).IgnoreArguments();
gui.Expect(g => g.ActiveView).Return(view);
+ gui.Expect(g => g.MainWindow).Return(mainWindow);
mocks.ReplayAll();
Index: Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapDataCollectionTreeNodeInfoTest.cs
===================================================================
diff -u -r70686cbe24e58c091018219365a4bfa0c3c62685 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapDataCollectionTreeNodeInfoTest.cs (.../MapDataCollectionTreeNodeInfoTest.cs) (revision 70686cbe24e58c091018219365a4bfa0c3c62685)
+++ Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapDataCollectionTreeNodeInfoTest.cs (.../MapDataCollectionTreeNodeInfoTest.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Windows.Forms;
using Core.Common.Base;
using Core.Common.Controls.TreeView;
using Core.Common.Gui.ContextMenu;
+using Core.Common.Gui.TestUtil.ContextMenu;
using Core.Common.TestUtil;
using Core.Common.Utils.Reflection;
using Core.Components.Gis.Data;
@@ -21,13 +23,15 @@
private MockRepository mocks;
private MapLegendView mapLegendView;
private TreeNodeInfo info;
+ private IContextMenuBuilderProvider contextMenuBuilderProvider;
[SetUp]
public void SetUp()
{
mocks = new MockRepository();
- var contextMenuBuilderProvider = mocks.StrictMock();
- mapLegendView = new MapLegendView(contextMenuBuilderProvider);
+ contextMenuBuilderProvider = mocks.StrictMock();
+ var parentWindow = mocks.StrictMock();
+ mapLegendView = new MapLegendView(contextMenuBuilderProvider, parentWindow);
var treeViewControl = TypeUtils.GetField(mapLegendView, "treeViewControl");
var treeNodeInfoLookup = TypeUtils.GetField>(treeViewControl, "tagTypeTreeNodeInfoLookup");
@@ -41,7 +45,6 @@
// Assert
Assert.AreEqual(typeof(MapDataCollection), info.TagType);
Assert.IsNull(info.ForeColor);
- Assert.IsNull(info.ContextMenuStrip);
Assert.IsNull(info.EnsureVisibleOnCreate);
Assert.IsNull(info.CanRename);
Assert.IsNull(info.OnNodeRenamed);
@@ -57,7 +60,7 @@
public void Text_Always_ReturnsNameFromMapData()
{
// Setup
- var mapDataCollection = mocks.StrictMock(new List(), "Collectie");
+ var mapDataCollection = mocks.StrictMock(Enumerable.Empty(), "Collectie");
mocks.ReplayAll();
@@ -113,7 +116,7 @@
public void CanDrop_SourceNodeTagIsNoMapData_ReturnsFalse()
{
// Setup
- var mapDataCollection = mocks.StrictMock(new List(), "test data");
+ var mapDataCollection = mocks.StrictMock(Enumerable.Empty(), "test data");
mocks.ReplayAll();
@@ -131,7 +134,7 @@
{
// Setup
var mapData = mocks.StrictMock("test data");
- var mapDataCollection = mocks.StrictMock(new List(), "test data");
+ var mapDataCollection = mocks.StrictMock(Enumerable.Empty(), "test data");
mocks.ReplayAll();
@@ -148,7 +151,7 @@
public void CanInsert_SourceNodeTagIsNoMapData_ReturnsFalse()
{
// Setup
- var mapDataCollection = mocks.StrictMock(new List(), "test data");
+ var mapDataCollection = mocks.StrictMock(Enumerable.Empty(), "test data");
mocks.ReplayAll();
@@ -166,7 +169,7 @@
{
// Setup
var mapData = mocks.StrictMock("test data");
- var mapDataCollection = mocks.StrictMock(new List(), "test data");
+ var mapDataCollection = mocks.StrictMock(Enumerable.Empty(), "test data");
mocks.ReplayAll();
@@ -248,5 +251,50 @@
mocks.VerifyAll(); // UpdateObserver should be not called
}
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ var menuBuilderMock = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+
+ var mapDataCollection = mocks.StrictMock(Enumerable.Empty(), "test data");
+
+ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ contextMenuBuilderProvider.Expect(cmbp => cmbp.Get(mapDataCollection, treeViewControlMock)).Return(menuBuilderMock);
+
+ mocks.ReplayAll();
+
+ // Call
+ info.ContextMenuStrip(mapDataCollection, null, treeViewControlMock);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_ContainsAddMapLayerMenuItem()
+ {
+ // Setup
+ var treeViewControlMock = mocks.StrictMock();
+ var mapDataCollection = mocks.StrictMock(Enumerable.Empty(), "test data");
+
+ contextMenuBuilderProvider.Expect(cmbp => cmbp.Get(mapDataCollection, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
+
+ mocks.ReplayAll();
+
+ // Call
+ var contextMenu = info.ContextMenuStrip(mapDataCollection, null, treeViewControlMock);
+
+ // Assert
+ const string expectedItemText = "&Voeg kaartlaag toe...";
+ const string expectedItemTooltip = "Importeer een nieuwe kaartlaag en voeg deze toe.";
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, 0, expectedItemText, expectedItemTooltip, DotSpatialResources.MapIcon);
+ mocks.VerifyAll();
+ }
+
}
}
\ No newline at end of file
Index: Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapLegendControllerTest.cs
===================================================================
diff -u -r70686cbe24e58c091018219365a4bfa0c3c62685 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapLegendControllerTest.cs (.../MapLegendControllerTest.cs) (revision 70686cbe24e58c091018219365a4bfa0c3c62685)
+++ Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapLegendControllerTest.cs (.../MapLegendControllerTest.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -1,4 +1,5 @@
using System;
+using System.Windows.Forms;
using Core.Common.Gui;
using Core.Common.Gui.ContextMenu;
using Core.Plugins.DotSpatial.Legend;
@@ -16,10 +17,11 @@
// Setup
var mocks = new MockRepository();
var contextMenuBuilderProvider = mocks.StrictMock();
+ var parentWindow = mocks.StrictMock();
mocks.ReplayAll();
// Call
- TestDelegate test = () => new MapLegendController(null, contextMenuBuilderProvider);
+ TestDelegate test = () => new MapLegendController(null, contextMenuBuilderProvider, parentWindow);
// Assert
ArgumentNullException exception = Assert.Throws(test);
@@ -28,15 +30,16 @@
}
[Test]
- public void Constructor_WithoutContextMenuBuilderProvicer_ThrowsArgumentNullException()
+ public void Constructor_WithoutContextMenuBuilderProvider_ThrowsArgumentNullException()
{
// Setup
var mocks = new MockRepository();
var toolViewController = mocks.StrictMock();
+ var parentWindow = mocks.StrictMock();
mocks.ReplayAll();
// Call
- TestDelegate test = () => new MapLegendController(toolViewController, null);
+ TestDelegate test = () => new MapLegendController(toolViewController, null, parentWindow);
// Assert
ArgumentNullException exception = Assert.Throws(test);
@@ -45,17 +48,36 @@
}
[Test]
+ public void Constructor_WithoutParentWindow_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var toolViewController = mocks.StrictMock();
+ var contextMenuBuilderProvider = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => new MapLegendController(toolViewController, contextMenuBuilderProvider, null);
+
+ // Assert
+ ArgumentNullException exception = Assert.Throws(test);
+ Assert.AreEqual("parentWindow", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
public void Constructor_WithToolViewControllerAndContextMenuBuilderProvider_DoesNotThrow()
{
// Setup
var mocks = new MockRepository();
var toolViewController = mocks.StrictMock();
var contextMenuBuilderProvider = mocks.StrictMock();
+ var parentWindow = mocks.StrictMock();
mocks.ReplayAll();
// Call
- TestDelegate test = () => new MapLegendController(toolViewController, contextMenuBuilderProvider);
+ TestDelegate test = () => new MapLegendController(toolViewController, contextMenuBuilderProvider, parentWindow);
// Assert
Assert.DoesNotThrow(test);
@@ -71,11 +93,12 @@
var mocks = new MockRepository();
var plugin = mocks.StrictMock();
var contextMenuBuilderProvider = mocks.StrictMock();
+ var parentWindow = mocks.StrictMock();
plugin.Expect(p => p.IsToolWindowOpen()).Return(open);
mocks.ReplayAll();
- var controller = new MapLegendController(plugin, contextMenuBuilderProvider);
+ var controller = new MapLegendController(plugin, contextMenuBuilderProvider, parentWindow);
// Call
var result = controller.IsLegendViewOpen();
@@ -94,6 +117,7 @@
var mocks = new MockRepository();
var plugin = mocks.StrictMock();
var contextMenuBuilderProvider = mocks.StrictMock();
+ var parentWindow = mocks.StrictMock();
if (open)
{
@@ -109,7 +133,7 @@
mocks.ReplayAll();
- var controller = new MapLegendController(plugin, contextMenuBuilderProvider);
+ var controller = new MapLegendController(plugin, contextMenuBuilderProvider, parentWindow);
if (open)
{
Index: Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapLegendViewTest.cs
===================================================================
diff -u -r70686cbe24e58c091018219365a4bfa0c3c62685 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapLegendViewTest.cs (.../MapLegendViewTest.cs) (revision 70686cbe24e58c091018219365a4bfa0c3c62685)
+++ Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapLegendViewTest.cs (.../MapLegendViewTest.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -21,12 +21,14 @@
{
private MockRepository mocks;
private IContextMenuBuilderProvider contextMenuBuilderProvider;
+ private IWin32Window parentWindow;
[SetUp]
public void SetUp()
{
mocks = new MockRepository();
contextMenuBuilderProvider = mocks.StrictMock();
+ parentWindow = mocks.StrictMock();
mocks.ReplayAll();
}
@@ -37,46 +39,47 @@
}
[Test]
- public void Constructor_CreatesUserControl()
+ public void Constructor_ContextMenuBuilderProviderAndWindowNotNull_CreatesUserControlAndTreeViewControl()
{
// Call
- var view = new MapLegendView(contextMenuBuilderProvider);
+ var view = new MapLegendView(contextMenuBuilderProvider, parentWindow);
+ var treeView = TypeUtils.GetField(view, "treeViewControl");
+
// Assert
Assert.IsInstanceOf(view);
Assert.IsInstanceOf(view);
Assert.IsNull(view.Data);
Assert.AreEqual(Resources.General_Map, view.Text);
+ Assert.IsNotNull(treeView);
+ Assert.IsInstanceOf(treeView);
}
[Test]
public void Constructor_ContextMenuBuilderProviderNull_ThrowsArgumentNullException()
{
// Call
- TestDelegate test = () => new MapLegendView(null);
+ TestDelegate test = () => new MapLegendView(null, parentWindow);
// Assert
TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "Cannot create a MapLegendView when the context menu builder provider is null");
}
-
+
[Test]
- public void DefaultConstructor_CreatesTreeViewControl()
+ public void Constructor_ParentWindowNull_ThrowsArgumentNullException()
{
// Call
- var view = new MapLegendView(contextMenuBuilderProvider);
+ TestDelegate test = () => new MapLegendView(contextMenuBuilderProvider, null);
- var treeView = TypeUtils.GetField(view, "treeViewControl");
-
// Assert
- Assert.IsNotNull(treeView);
- Assert.IsInstanceOf(treeView);
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "Cannot create a MapLegendView when the parent window is null");
}
[Test]
public void Data_MapDataCollection_DataSet()
{
// Setup
- var view = new MapLegendView(contextMenuBuilderProvider);
+ var view = new MapLegendView(contextMenuBuilderProvider, parentWindow);
var mapData = new MapDataCollection(new List(), "test data");
// Call
@@ -92,7 +95,7 @@
public void Data_MapPointData_DataSet()
{
// Setup
- var view = new MapLegendView(contextMenuBuilderProvider);
+ var view = new MapLegendView(contextMenuBuilderProvider, parentWindow);
var mapData = new MapPointData(Enumerable.Empty(), "test data");
// Call
@@ -107,7 +110,7 @@
public void Data_MapLineData_DataSet()
{
// Setup
- var view = new MapLegendView(contextMenuBuilderProvider);
+ var view = new MapLegendView(contextMenuBuilderProvider, parentWindow);
var mapData = new MapLineData(Enumerable.Empty(), "test data");
// Call
@@ -122,7 +125,7 @@
public void Data_MapPolygonData_DataSet()
{
// Setup
- var view = new MapLegendView(contextMenuBuilderProvider);
+ var view = new MapLegendView(contextMenuBuilderProvider, parentWindow);
var mapData = new MapPolygonData(Enumerable.Empty(), "test data");
// Call
@@ -137,7 +140,7 @@
public void Data_MapMultiLineData_DataSet()
{
// Setup
- var view = new MapLegendView(contextMenuBuilderProvider);
+ var view = new MapLegendView(contextMenuBuilderProvider, parentWindow);
var mapData = new MapMultiLineData(Enumerable.Empty>(), "test data");
// Call
@@ -152,7 +155,7 @@
public void Data_ForNull_NullSet()
{
// Setup
- var view = new MapLegendView(contextMenuBuilderProvider);
+ var view = new MapLegendView(contextMenuBuilderProvider, parentWindow);
// Call
view.Data = null;
@@ -165,7 +168,7 @@
public void Data_OtherObject_ThrowsInvalidCastException()
{
// Setup
- var view = new MapLegendView(contextMenuBuilderProvider);
+ var view = new MapLegendView(contextMenuBuilderProvider, parentWindow);
// Call
TestDelegate test = () => view.Data = new object();
Index: Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapLineDataTreeNodeInfoTest.cs
===================================================================
diff -u -r70686cbe24e58c091018219365a4bfa0c3c62685 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapLineDataTreeNodeInfoTest.cs (.../MapLineDataTreeNodeInfoTest.cs) (revision 70686cbe24e58c091018219365a4bfa0c3c62685)
+++ Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapLineDataTreeNodeInfoTest.cs (.../MapLineDataTreeNodeInfoTest.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Windows.Forms;
using Core.Common.Base;
using Core.Common.Base.Geometry;
using Core.Common.Controls.TreeView;
@@ -27,9 +28,10 @@
{
mockRepository = new MockRepository();
var contextMenuBuilderProvider = mockRepository.StrictMock();
+ var parentWindow = mockRepository.StrictMock();
mockRepository.ReplayAll();
- mapLegendView = new MapLegendView(contextMenuBuilderProvider);
+ mapLegendView = new MapLegendView(contextMenuBuilderProvider, parentWindow);
var treeViewControl = TypeUtils.GetField(mapLegendView, "treeViewControl");
var treeNodeInfoLookup = TypeUtils.GetField>(treeViewControl, "tagTypeTreeNodeInfoLookup");
Index: Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapMultiLineDataTreeNodeInfoTest.cs
===================================================================
diff -u
--- Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapMultiLineDataTreeNodeInfoTest.cs (revision 0)
+++ Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapMultiLineDataTreeNodeInfoTest.cs (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -0,0 +1,180 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+using Core.Common.Base;
+using Core.Common.Base.Geometry;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.TestUtil;
+using Core.Common.Utils.Reflection;
+using Core.Components.Gis.Data;
+using Core.Plugins.DotSpatial.Legend;
+using NUnit.Framework;
+using Rhino.Mocks;
+using DotSpatialResources = Core.Plugins.DotSpatial.Properties.Resources;
+
+namespace Core.Plugins.DotSpatial.Test.Legend
+{
+ [TestFixture]
+ public class MapMultiLineDataTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+ private MapLegendView mapLegendView;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ var contextMenuBuilderProvider = mocks.StrictMock();
+ var parentWindow = mocks.StrictMock();
+ mapLegendView = new MapLegendView(contextMenuBuilderProvider, parentWindow);
+
+ var treeViewControl = TypeUtils.GetField(mapLegendView, "treeViewControl");
+ var treeNodeInfoLookup = TypeUtils.GetField>(treeViewControl, "tagTypeTreeNodeInfoLookup");
+
+ info = treeNodeInfoLookup[typeof(MapMultiLineData)];
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual(typeof(MapMultiLineData), info.TagType);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.ChildNodeObjects);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+
+ [Test]
+ public void Text_Always_ReturnsNameFromMapData()
+ {
+ // Setup
+ var mapMultiLineData = mocks.StrictMock(Enumerable.Empty>(), "Collectie");
+
+ mocks.ReplayAll();
+
+ // Call
+ var text = info.Text(mapMultiLineData);
+
+ // Assert
+ Assert.AreEqual(mapMultiLineData.Name, text);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Image_Always_ReturnsImageFromResource()
+ {
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(DotSpatialResources.LineIcon, image);
+ }
+
+ [Test]
+ public void CanCheck_Always_ReturnsTrue()
+ {
+ // Setup
+ var lineData = mocks.StrictMock(Enumerable.Empty>(), "test data");
+
+ mocks.ReplayAll();
+
+ // Call
+ var canCheck = info.CanCheck(lineData);
+
+ // Assert
+ Assert.IsTrue(canCheck);
+
+ mocks.VerifyAll();
+ }
+
+ [TestCase(true)]
+ [TestCase(false)]
+ public void IsChecked_Always_ReturnsAccordingToVisibleStateOfLineData(bool isVisible)
+ {
+ // Setup
+ var lineData = mocks.StrictMock(Enumerable.Empty>(), "test data");
+
+ lineData.IsVisible = isVisible;
+
+ mocks.ReplayAll();
+
+ // Call
+ var canCheck = info.IsChecked(lineData);
+
+ // Assert
+ Assert.AreEqual(isVisible, canCheck);
+
+ mocks.VerifyAll();
+ }
+
+ [TestCase(true)]
+ [TestCase(false)]
+ public void OnNodeChecked_LineDataNodeWithoutParent_SetsLineDataVisibility(bool initialVisibleState)
+ {
+ // Setup
+ var lineData = mocks.StrictMock(Enumerable.Empty>(), "test data");
+
+ mocks.ReplayAll();
+
+ lineData.IsVisible = initialVisibleState;
+
+ // Call
+ info.OnNodeChecked(lineData, null);
+
+ // Assert
+ Assert.AreEqual(!initialVisibleState, lineData.IsVisible);
+
+ mocks.VerifyAll();
+ }
+
+ [TestCase(true)]
+ [TestCase(false)]
+ public void OnNodeChecked_LineDataNodeWithObservableParent_SetsLineDataVisibilityAndNotifiesParentObservers(bool initialVisibleState)
+ {
+ // Setup
+ var observable = mocks.StrictMock();
+ var lineData = mocks.StrictMock(Enumerable.Empty>(), "test data");
+
+ observable.Expect(o => o.NotifyObservers());
+
+ mocks.ReplayAll();
+
+ lineData.IsVisible = initialVisibleState;
+
+ // Call
+ info.OnNodeChecked(lineData, observable);
+
+ // Assert
+ Assert.AreEqual(!initialVisibleState, lineData.IsVisible);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CanDrag_Always_ReturnsTrue()
+ {
+ // Setup
+ var lineData = mocks.StrictMock(Enumerable.Empty>(), "test data");
+
+ mocks.ReplayAll();
+
+ // Call
+ var canDrag = info.CanDrag(lineData, null);
+
+ // Assert
+ Assert.IsTrue(canDrag);
+
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapPointDataTreeNodeInfoTest.cs
===================================================================
diff -u -r70686cbe24e58c091018219365a4bfa0c3c62685 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapPointDataTreeNodeInfoTest.cs (.../MapPointDataTreeNodeInfoTest.cs) (revision 70686cbe24e58c091018219365a4bfa0c3c62685)
+++ Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapPointDataTreeNodeInfoTest.cs (.../MapPointDataTreeNodeInfoTest.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Windows.Forms;
using Core.Common.Base;
using Core.Common.Base.Geometry;
using Core.Common.Controls.TreeView;
@@ -27,9 +28,10 @@
{
mockRepository = new MockRepository();
var contextMenuBuilderProvider = mockRepository.StrictMock();
+ var parentWindow = mockRepository.StrictMock();
mockRepository.ReplayAll();
- mapLegendView = new MapLegendView(contextMenuBuilderProvider);
+ mapLegendView = new MapLegendView(contextMenuBuilderProvider, parentWindow);
var treeViewControl = TypeUtils.GetField(mapLegendView, "treeViewControl");
var treeNodeInfoLookup = TypeUtils.GetField>(treeViewControl, "tagTypeTreeNodeInfoLookup");
Index: Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapPolygonDataTreeNodeInfoTest.cs
===================================================================
diff -u -r70686cbe24e58c091018219365a4bfa0c3c62685 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapPolygonDataTreeNodeInfoTest.cs (.../MapPolygonDataTreeNodeInfoTest.cs) (revision 70686cbe24e58c091018219365a4bfa0c3c62685)
+++ Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapPolygonDataTreeNodeInfoTest.cs (.../MapPolygonDataTreeNodeInfoTest.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Windows.Forms;
using Core.Common.Base;
using Core.Common.Base.Geometry;
using Core.Common.Controls.TreeView;
@@ -27,9 +28,10 @@
{
mockRepository = new MockRepository();
var contextMenuBuilderProvider = mockRepository.StrictMock();
+ var parentWindow = mockRepository.StrictMock();
mockRepository.ReplayAll();
- mapLegendView = new MapLegendView(contextMenuBuilderProvider);
+ mapLegendView = new MapLegendView(contextMenuBuilderProvider, parentWindow);
var treeViewControl = TypeUtils.GetField(mapLegendView, "treeViewControl");
var treeNodeInfoLookup = TypeUtils.GetField>(treeViewControl, "tagTypeTreeNodeInfoLookup");
Index: Core/Plugins/test/Core.Plugins.DotSpatial.Test/MapRibbonTest.cs
===================================================================
diff -u -r70686cbe24e58c091018219365a4bfa0c3c62685 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Core/Plugins/test/Core.Plugins.DotSpatial.Test/MapRibbonTest.cs (.../MapRibbonTest.cs) (revision 70686cbe24e58c091018219365a4bfa0c3c62685)
+++ Core/Plugins/test/Core.Plugins.DotSpatial.Test/MapRibbonTest.cs (.../MapRibbonTest.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -1,7 +1,6 @@
using System.Linq;
using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Controls.Primitives;
+using System.Windows.Forms;
using Core.Common.Controls.Commands;
using Core.Common.Gui;
using Core.Common.Gui.ContextMenu;
@@ -12,6 +11,8 @@
using NUnit.Framework;
using Rhino.Mocks;
using Button = Fluent.Button;
+using ButtonBase = System.Windows.Controls.Primitives.ButtonBase;
+using Control = System.Windows.Controls.Control;
using ToggleButton = Fluent.ToggleButton;
namespace Core.Plugins.DotSpatial.Test
@@ -49,9 +50,11 @@
var mocks = new MockRepository();
var toolViewController = mocks.Stub();
var contextMenuBuilderProvider = mocks.StrictMock();
+ var parentWindow = mocks.StrictMock();
+
mocks.ReplayAll();
- var toggleLegendViewCommand = new ToggleMapLegendViewCommand(new MapLegendController(toolViewController, contextMenuBuilderProvider));
+ var toggleLegendViewCommand = new ToggleMapLegendViewCommand(new MapLegendController(toolViewController, contextMenuBuilderProvider, parentWindow));
var ribbon = new MapRibbon
{
Index: Ringtoets/Common/src/Ringtoets.Common.IO/FailureMechanismSectionReader.cs
===================================================================
diff -u -r5e0d414ac611e8a6fd5b77a41d0459be8b749e83 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Ringtoets/Common/src/Ringtoets.Common.IO/FailureMechanismSectionReader.cs (.../FailureMechanismSectionReader.cs) (revision 5e0d414ac611e8a6fd5b77a41d0459be8b749e83)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/FailureMechanismSectionReader.cs (.../FailureMechanismSectionReader.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -30,7 +30,7 @@
using Core.Common.Utils.Builders;
using Core.Components.Gis.Data;
using Core.Components.Gis.IO;
-
+using Core.Components.Gis.IO.Readers;
using Ringtoets.Common.Data;
using CoreCommonUtilsResources = Core.Common.Utils.Properties.Resources;
@@ -93,12 +93,7 @@
ValidateExistenceOfRequiredAttributes();
var lineData = ReadMapLineData();
- if (lineData == null)
- {
- return null;
- }
-
- return CreateFailureMechanismSection(lineData);
+ return lineData == null ? null : CreateFailureMechanismSection(lineData);
}
public void Dispose()
@@ -144,7 +139,7 @@
{
try
{
- return polylineShapeFileReader.ReadLine();
+ return polylineShapeFileReader.ReadLine() as MapLineData;
}
catch (ElementReadException e)
{
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -rc96faf42eae37d9b6ad63d7ed0250b7fef11bef8 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision c96faf42eae37d9b6ad63d7ed0250b7fef11bef8)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
+// Runtime Version:4.0.30319.17929
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
Index: Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineReader.cs
===================================================================
diff -u -rc9f9c04e4fc62406231afd07d63cd7da11673ec6 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineReader.cs (.../ReferenceLineReader.cs) (revision c9f9c04e4fc62406231afd07d63cd7da11673ec6)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineReader.cs (.../ReferenceLineReader.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -29,7 +29,7 @@
using Core.Common.Utils.Builders;
using Core.Components.Gis.Data;
using Core.Components.Gis.IO;
-
+using Core.Components.Gis.IO.Readers;
using Ringtoets.Common.Data;
using CoreCommonUtilsResources = Core.Common.Utils.Properties.Resources;
@@ -103,7 +103,8 @@
/// When either:
///
/// - There isn't exactly 1 polyline in the shapefile.
- /// - Shapefile contains a multi-polyline.
+ /// - The shapefile doesn't contains lines.
+ /// - The shapefile contains a multi-polyline.
///
///
private static MapLineData GetReferenceLineMapData(PolylineShapeFileReader lineShapeReader, string shapeFilePath)
@@ -117,14 +118,20 @@
try
{
- return lineShapeReader.ReadLine(RingtoetsCommonDataResources.ReferenceLine_DisplayName);
+ return (MapLineData) lineShapeReader.ReadLine(RingtoetsCommonDataResources.ReferenceLine_DisplayName);
}
catch (ElementReadException e)
{
string message = new FileReaderErrorMessageBuilder(shapeFilePath)
.Build(RingtoetsCommonIOResources.ReferenceLineReader_File_contains_unsupported_multi_polyline);
throw new CriticalFileReadException(message, e);
}
+ catch (InvalidCastException exception)
+ {
+ string message = new FileReaderErrorMessageBuilder(shapeFilePath)
+ .Build(RingtoetsCommonIOResources.ReferenceLineReader_File_must_contain_1_polyline);
+ throw new CriticalFileReadException(message, exception);
+ }
}
private static ReferenceLine CreateReferenceLine(MapLineData lineMapData)
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj
===================================================================
diff -u -r428f61c9f1c755c69ea1ff2745e38c1864dad558 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 428f61c9f1c755c69ea1ff2745e38c1864dad558)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -89,6 +89,7 @@
ResXFileCodeGenerator
Resources.Designer.cs
+ Designer
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs
===================================================================
diff -u -r80ba92856fef1308510823aa4ad0ed3cd16c79d3 -r5e80369138024933a45f3e4ae721509dfb17d8fb
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs (.../HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs) (revision 80ba92856fef1308510823aa4ad0ed3cd16c79d3)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs (.../HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs) (revision 5e80369138024933a45f3e4ae721509dfb17d8fb)
@@ -11,7 +11,6 @@
using Ringtoets.Common.Data;
using Ringtoets.HydraRing.Data;
-using Ringtoets.Integration.Data;
using Ringtoets.Integration.Forms.PresentationObjects;
using Ringtoets.Integration.Plugin;
using RingtoetsFormsResources = Ringtoets.Integration.Forms.Properties.Resources;