Skip to content

Commit 86fb575

Browse files
committed
Re-adding projectionString unit test after merge conflicts
1 parent b7e34ea commit 86fb575

1 file changed

Lines changed: 53 additions & 2 deletions

File tree

unittests/MapWinGISTests/UtilTests.cs

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
using System;
2-
using System.Collections.Concurrent;
32
using System.Diagnostics;
43
using System.IO;
54
using System.Linq;
65
using System.Threading;
7-
using System.Threading.Tasks;
86
using MapWinGIS;
97
using Microsoft.VisualStudio.TestTools.UnitTesting;
108

@@ -126,6 +124,7 @@ public void ZonalStatistics()
126124
var newShapefileFile = Path.Combine(Path.GetTempPath(), "ZonalStatistics.shp");
127125
if (File.Exists(newShapefileFile))
128126
{
127+
// ReSharper disable once AssignNullToNotNullAttribute
129128
foreach (var f in Directory.EnumerateFiles(Path.GetDirectoryName(newShapefileFile), "ZonalStatistics.*"))
130129
{
131130
File.Delete(f);
@@ -259,6 +258,58 @@ public void PointInPolygon()
259258
Console.WriteLine(found + " matching polygons where found");
260259
}
261260

261+
[TestMethod]
262+
public void ProjectionStrings()
263+
{
264+
var utils = new Utils {GlobalCallback = this};
265+
var gp = new GeoProjection {GlobalCallback = this};
266+
267+
// get NAD83 name
268+
var utilProjection = utils.GetNAD83ProjectionName(tkNad83Projection.Nad83_Alabama_East);
269+
gp.ImportFromEPSG((int)tkNad83Projection.Nad83_Alabama_East);
270+
var importProjection = gp.Name;
271+
Assert.AreEqual(utilProjection, importProjection);
272+
273+
// get WGS84 name
274+
utilProjection = utils.GetWGS84ProjectionName(tkWgs84Projection.Wgs84_BLM_14N_ftUS);
275+
gp.ImportFromEPSG((int)tkWgs84Projection.Wgs84_BLM_14N_ftUS);
276+
importProjection = gp.Name;
277+
Assert.AreEqual(utilProjection, importProjection);
278+
279+
// get NAD83 name by ID
280+
utilProjection = utils.GetProjectionNameByID((int)tkNad83Projection.Nad83_Alabama_East);
281+
gp.ImportFromEPSG((int)tkNad83Projection.Nad83_Alabama_East);
282+
importProjection = gp.Name;
283+
Assert.AreEqual(utilProjection, importProjection);
284+
285+
// get WGS84 name by ID
286+
utilProjection = utils.GetProjectionNameByID((int)tkWgs84Projection.Wgs84_BLM_14N_ftUS);
287+
gp.ImportFromEPSG((int)tkWgs84Projection.Wgs84_BLM_14N_ftUS);
288+
importProjection = gp.Name;
289+
Assert.AreEqual(utilProjection, importProjection);
290+
291+
// get obscure names by ID
292+
utilProjection = utils.GetProjectionNameByID(2402);
293+
gp.ImportFromEPSG(2402);
294+
importProjection = gp.Name;
295+
Assert.AreEqual(utilProjection, importProjection);
296+
297+
// get obscure names by ID
298+
utilProjection = utils.GetProjectionNameByID(20005);
299+
gp.ImportFromEPSG(20005);
300+
importProjection = gp.Name;
301+
Assert.AreEqual(utilProjection, importProjection);
302+
303+
// verify error
304+
utilProjection = utils.GetProjectionNameByID(100);
305+
Assert.IsTrue(utilProjection.Length == 0);
306+
// should return Index Out-of-bounds error
307+
var errorMsg = utils.ErrorMsg[utils.LastErrorCode];
308+
Console.WriteLine(errorMsg);
309+
Assert.AreEqual("Index Out of Bounds", errorMsg);
310+
}
311+
312+
262313
public void Progress(string KeyOfSender, int Percent, string Message)
263314
{
264315
Console.Write(".");

0 commit comments

Comments
 (0)