Index: Core/Components/src/Core.Components.DotSpatial/BaseMap.cs
===================================================================
diff -u -r71ce26f5bde53bd1173fbe6ea09510e30a6a1166 -r04c70d10f22ba007f8210813d3d02697e42f8a5d
--- Core/Components/src/Core.Components.DotSpatial/BaseMap.cs (.../BaseMap.cs) (revision 71ce26f5bde53bd1173fbe6ea09510e30a6a1166)
+++ Core/Components/src/Core.Components.DotSpatial/BaseMap.cs (.../BaseMap.cs) (revision 04c70d10f22ba007f8210813d3d02697e42f8a5d)
@@ -28,21 +28,26 @@
///
/// Gets and sets the . When is not empty it will load the data on the map.
///
- /// Thrown when is invalid.
+ /// Thrown when is null.
+ /// Thrown when does not exist.
+ /// Thrown when has an unaccepted extension.
public void SetMapData(MapData mapData)
{
- try
+ if (IsDisposed)
{
- if (mapData.IsValid())
- {
- data = mapData;
- LoadData();
- }
+ return;
}
- catch (Exception e)
+
+ if(mapData == null)
{
- throw new ArgumentException("Could not set the data on the map.", e.Message);
+ throw new ArgumentNullException("mapData", "MapData is required when adding shapeFiles");
}
+
+ if (mapData.IsValid())
+ {
+ data = mapData;
+ LoadData();
+ }
}
///
Index: Core/Components/src/Core.Components.DotSpatial/Data/MapData.cs
===================================================================
diff -u -r71ce26f5bde53bd1173fbe6ea09510e30a6a1166 -r04c70d10f22ba007f8210813d3d02697e42f8a5d
--- Core/Components/src/Core.Components.DotSpatial/Data/MapData.cs (.../MapData.cs) (revision 71ce26f5bde53bd1173fbe6ea09510e30a6a1166)
+++ Core/Components/src/Core.Components.DotSpatial/Data/MapData.cs (.../MapData.cs) (revision 04c70d10f22ba007f8210813d3d02697e42f8a5d)
@@ -10,7 +10,7 @@
///
public class MapData
{
- private const string extension = "shp";
+ private const string extension = ".shp";
private readonly HashSet filePaths;
@@ -37,6 +37,7 @@
/// Adds the shape file to the list. Each should be unique.
///
/// The path to the file.
+ /// Thrown when is null.
/// Thrown when does not exist.
/// Thrown when has an unaccepted extension.
/// True when added to the list. False when it is not added, for example when is not unique.
@@ -50,12 +51,13 @@
///
/// Checks if the given paths are valid.
///
- /// Thrown when does not exist.
- /// Thrown when has an unaccepted extension.
+ /// Throwns when value in is null.
+ /// Thrown when value in does not exist.
+ /// Thrown when value has an unaccepted extension.
///
public bool IsValid()
{
- foreach (var path in FilePaths)
+ foreach (var path in filePaths)
{
IsPathValid(path);
}
@@ -65,6 +67,11 @@
private void IsPathValid(string path)
{
+ if (path == null)
+ {
+ throw new ArgumentNullException("path", "A path is required when adding shape files");
+ }
+
if (!File.Exists(path))
{
throw new FileNotFoundException(string.Format(Resources.MapData_IsPathValid_File_on_path__0__does_not_exist, path));
Index: Core/Components/src/Core.Components.DotSpatial/Properties/Resources.Designer.cs
===================================================================
diff -u -r71ce26f5bde53bd1173fbe6ea09510e30a6a1166 -r04c70d10f22ba007f8210813d3d02697e42f8a5d
--- Core/Components/src/Core.Components.DotSpatial/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 71ce26f5bde53bd1173fbe6ea09510e30a6a1166)
+++ Core/Components/src/Core.Components.DotSpatial/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 04c70d10f22ba007f8210813d3d02697e42f8a5d)
@@ -61,33 +61,6 @@
}
///
- /// Looks up a localized string similar to Kan bestand met deze extensie niet openen..
- ///
- public static string BaseMap_LoadData_Cannot_open_file_extension {
- get {
- return ResourceManager.GetString("BaseMap_LoadData_Cannot_open_file_extension", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Het bestand {0} kon niet worden gevonden..
- ///
- public static string BaseMap_LoadData_File_loading_failded__The_file__0__could_not_be_found {
- get {
- return ResourceManager.GetString("BaseMap_LoadData_File_loading_failded__The_file__0__could_not_be_found", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Bestand is niet compleet..
- ///
- public static string BaseMap_LoadData_NullException_in_file {
- get {
- return ResourceManager.GetString("BaseMap_LoadData_NullException_in_file", resourceCulture);
- }
- }
-
- ///
/// Looks up a localized string similar to Shape file op pad {0} is aan de kaart toegevoegd..
///
public static string BaseMap_LoadData_Shape_file_on_path__0__is_added_to_the_map_ {
Index: Core/Components/src/Core.Components.DotSpatial/Properties/Resources.resx
===================================================================
diff -u -r71ce26f5bde53bd1173fbe6ea09510e30a6a1166 -r04c70d10f22ba007f8210813d3d02697e42f8a5d
--- Core/Components/src/Core.Components.DotSpatial/Properties/Resources.resx (.../Resources.resx) (revision 71ce26f5bde53bd1173fbe6ea09510e30a6a1166)
+++ Core/Components/src/Core.Components.DotSpatial/Properties/Resources.resx (.../Resources.resx) (revision 04c70d10f22ba007f8210813d3d02697e42f8a5d)
@@ -117,15 +117,6 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- Het bestand {0} kon niet worden gevonden.
-
-
- Bestand is niet compleet.
-
-
- Kan bestand met deze extensie niet openen.
-
Bestand op pad {0} bestaat niet.
Index: Core/Components/test/Core.Components.DotSpatial.Test/BaseMapTest.cs
===================================================================
diff -u -r70875d4b12e2e60901b99d1e67469e7c11ec5b4d -r04c70d10f22ba007f8210813d3d02697e42f8a5d
--- Core/Components/test/Core.Components.DotSpatial.Test/BaseMapTest.cs (.../BaseMapTest.cs) (revision 70875d4b12e2e60901b99d1e67469e7c11ec5b4d)
+++ Core/Components/test/Core.Components.DotSpatial.Test/BaseMapTest.cs (.../BaseMapTest.cs) (revision 04c70d10f22ba007f8210813d3d02697e42f8a5d)
@@ -1,7 +1,9 @@
using System;
-using System.Collections.ObjectModel;
+using System.IO;
using System.Windows.Forms;
using Core.Common.TestUtil;
+using Core.Common.Utils.Reflection;
+using Core.Components.DotSpatial.Data;
using Core.Components.DotSpatial.Properties;
using DotSpatial.Controls;
using NUnit.Framework;
@@ -12,63 +14,97 @@
[TestFixture]
public class BaseMapTest
{
-// [Test]
-// public void DefaultConstructor_PropertiesSet()
-// {
-// // Setup
-// var mocks = new MockRepository();
-// var map = mocks.StrictMock