[mapguide-commits] r8263 - in sandbox/jng/convenience_apis/UnitTest: Common WebTier/DotNet/MgTestRunner WebTier/DotNet/TestCommon WebTier/DotNet/TestCommon/ExternalTests WebTier/DotNet/TestMapGuideApi WebTier/DotNet/TestMapGuideApi/ExternalTests
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Jun 25 08:30:06 PDT 2014
Author: jng
Date: 2014-06-25 08:30:06 -0700 (Wed, 25 Jun 2014)
New Revision: 8263
Added:
sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/Assert.cs
sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/CommonTests.cs
sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/ExternalTests/
sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/ExternalTests/ByteReaderTest.cs
sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/ExternalTests/CollectionTests.cs
sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/ExternalTests/PropertiesTest.cs
sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestMapGuideApi/ExternalTests/
sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestMapGuideApi/ExternalTests/CollectionTests.cs
sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestMapGuideApi/MapGuideTests.cs
Removed:
sandbox/jng/convenience_apis/UnitTest/Common/DotNetWrappers/
Modified:
sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/MgTestRunner/Program.cs
sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/TestCommon.csproj
sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestMapGuideApi/TestMapGuideApi.csproj
Log:
Improve DotNet test runner. Add support for external tests outside of the SQLite-defined test suite and integrate the existing common dotnet wrapper tests into it. This removes the need for the DotNetWrappers test project and it has been deleted as a result.
Modified: sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/MgTestRunner/Program.cs
===================================================================
--- sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/MgTestRunner/Program.cs 2014-06-23 14:31:00 UTC (rev 8262)
+++ sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/MgTestRunner/Program.cs 2014-06-25 15:30:06 UTC (rev 8263)
@@ -16,6 +16,32 @@
static MgUserInformation userInfo;
static MgSiteConnection siteConn;
+ class PlatformFactory : IPlatformFactory
+ {
+ private MgSiteConnection _siteConn;
+
+ public PlatformFactory(MgSiteConnection siteConn)
+ {
+ _siteConn = siteConn;
+ }
+
+ public MgService CreateService(int serviceType)
+ {
+ return _siteConn.CreateService(serviceType);
+ }
+
+ public MgMapBase CreateMap()
+ {
+ return new MgMap(_siteConn);
+ }
+
+ public MgLayerBase CreateLayer(MgResourceIdentifier resId)
+ {
+ MgResourceService resSvc = (MgResourceService)_siteConn.CreateService(MgServiceType.ResourceService);
+ return new MgLayer(resId, resSvc);
+ }
+ }
+
//Usage: MgTestRunner.exe <webconfig.ini path> <MENTOR_DICTIONARY_PATH> [test log path]
static void Main(string[] args)
{
@@ -38,6 +64,8 @@
siteConn = new MgSiteConnection();
siteConn.Open(userInfo);
+ var factory = new PlatformFactory(siteConn);
+
int testsRun = 0;
bool isEnterprise = false;
failures += ExecuteTest(ApiTypes.Platform, "../../TestData/ResourceService/ResourceServiceTest.dump", ref testsRun, logger, isEnterprise);
@@ -49,6 +77,9 @@
failures += ExecuteTest(ApiTypes.Platform, "../../TestData/MapLayer/MapLayerTest.dump", ref testsRun, logger, isEnterprise);
failures += ExecuteTest(ApiTypes.Platform, "../../TestData/WebLayout/WebLayoutTest.dump", ref testsRun, logger, isEnterprise);
failures += ExecuteTest(ApiTypes.Platform, "../../TestData/Unicode/UnicodeTest.dump", ref testsRun, logger, isEnterprise);
+ //Run auxillary tests not part of the SQLite-defined suite
+ failures += CommonTests.Execute(factory, logger, ref testsRun);
+ failures += MapGuideTests.Execute(factory, logger, ref testsRun);
logger.Write("\n\nTests failed/run: {0}/{1}\n", failures, testsRun);
Console.Write("\n\nTests failed/run: {0}/{1}\n", failures, testsRun);
logger.Write("Run ended: {0}\n\n", DateTime.Now.ToString());
Added: sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/Assert.cs
===================================================================
--- sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/Assert.cs (rev 0)
+++ sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/Assert.cs 2014-06-25 15:30:06 UTC (rev 8263)
@@ -0,0 +1,77 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OSGeo.MapGuide.Test.Common
+{
+ [Serializable]
+ public class AssertException : Exception
+ {
+ public AssertException() { }
+ public AssertException(string message) : base(message) { }
+ public AssertException(string message, Exception inner) : base(message, inner) { }
+ protected AssertException(
+ System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context) { }
+ }
+
+ public class Assert
+ {
+ public static void AreBytesEqual(byte[] expected, byte[] actual)
+ {
+ byte[] a = expected;
+ byte[] b = actual;
+ if (a.Length != b.Length)
+ throw new AssertException("Expected byte array size of " + a.Length + ", got size of: " + b.Length);
+
+ for (int i = 0; i < a.Length; i++)
+ {
+ if (a[i] != b[i])
+ throw new AssertException("Byte number " + (i + 1) + " in expected byte array does not match byte in actual byte array");
+ }
+ }
+
+ public static void AreEqual<T>(T expected, T actual)
+ {
+ if (typeof(T) == typeof(byte[]))
+ {
+ AreBytesEqual(expected as byte[], actual as byte[]);
+ }
+ else if (!EqualityComparer<T>.Default.Equals(expected, actual))
+ throw new AssertException("Expected: " + expected + ", got: " + actual);
+ }
+
+ public static void Greater<T>(T value, T against) where T : IComparable
+ {
+ if (value.CompareTo(against) <= 0)
+ throw new AssertException(value + " is not greater than " + against);
+ }
+
+ public static void IsNull(object obj)
+ {
+ if (obj != null)
+ throw new AssertException("Reference is not null");
+ }
+
+ public static void IsTrue(bool condition)
+ {
+ if (!condition)
+ throw new AssertException("Condition evaluated to false. Expected: true");
+ }
+
+ public static void IsFalse(bool condition)
+ {
+ if (condition)
+ throw new AssertException("Condition evaluated to true. Expected: false");
+ }
+
+ public static void IsNaN(double value)
+ {
+ if (!double.IsNaN(value))
+ throw new AssertException("Double is a number. Expected: NaN");
+ }
+ }
+}
Added: sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/CommonTests.cs
===================================================================
--- sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/CommonTests.cs (rev 0)
+++ sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/CommonTests.cs 2014-06-25 15:30:06 UTC (rev 8263)
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OSGeo.MapGuide.Test.Common
+{
+ //Defines tests outside of the SQLite-based test suite
+
+ public interface IExternalTest
+ {
+ void Execute(IPlatformFactory factory, ITestLogger logger);
+ }
+
+ public interface IPlatformFactory
+ {
+ MgService CreateService(int serviceType);
+ MgMapBase CreateMap();
+ MgLayerBase CreateLayer(MgResourceIdentifier resId);
+ }
+
+ public class CommonTests
+ {
+ public static int Execute(IPlatformFactory factory, ITestLogger logger, ref int testsRun)
+ {
+ int failures = 0;
+ var types = typeof(IPlatformFactory).Assembly.GetTypes();
+ foreach (var type in types)
+ {
+ if (typeof(IExternalTest).IsAssignableFrom(type) && type.IsClass)
+ {
+ var test = (IExternalTest)Activator.CreateInstance(type);
+ try
+ {
+ logger.WriteLine("****** Executing platform test: " + type.Name + " *********");
+ Console.WriteLine("Executing external platform test: " + type.Name);
+ test.Execute(factory, logger);
+ }
+ catch (AssertException ex)
+ {
+ logger.WriteLine("Assertion failure: " + ex.Message);
+ Console.WriteLine("Assertion failure: " + ex.Message);
+ failures++;
+ }
+ catch (Exception ex)
+ {
+ logger.WriteLine("General failure: " + ex.ToString());
+ Console.WriteLine("General failure: " + ex.ToString());
+ failures++;
+ }
+ finally
+ {
+ testsRun++;
+ }
+ }
+ }
+ return failures;
+ }
+ }
+}
Added: sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/ExternalTests/ByteReaderTest.cs
===================================================================
--- sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/ExternalTests/ByteReaderTest.cs (rev 0)
+++ sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/ExternalTests/ByteReaderTest.cs 2014-06-25 15:30:06 UTC (rev 8263)
@@ -0,0 +1,118 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OSGeo.MapGuide.Test.Common.ExternalTests
+{
+ internal class ByteReaderTestData
+ {
+ internal static byte[] testBytes;
+ internal static int nBytes = 32768;
+ internal static int nBlocks = 256;
+ internal static string testString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+ internal static string infileName;
+ internal static string outfileName;
+ private static bool bFirstTime = true;
+
+ public static void Init()
+ {
+ if (bFirstTime)
+ {
+ infileName = System.IO.Path.GetTempFileName();
+ outfileName = System.IO.Path.GetTempFileName();
+ testBytes = new byte[nBytes];
+ for (int i = 0; i < nBytes; i++)
+ {
+ testBytes[i] = (byte)(i % 255);
+ }
+
+ System.IO.FileStream fp = System.IO.File.OpenWrite(infileName);
+ for (int j = 0; j < nBlocks; j++)
+ {
+ fp.Write(testBytes, 0, nBytes);
+ }
+ fp.Close();
+
+ bFirstTime = false;
+ }
+ }
+ }
+
+ public class ByteReaderTest : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ ByteReaderTestData.Init();
+ var nBytes = ByteReaderTestData.nBytes;
+ var nBlocks = ByteReaderTestData.nBlocks;
+ var testBytes = ByteReaderTestData.testBytes;
+ var infileName = ByteReaderTestData.infileName;
+ var outfileName = ByteReaderTestData.outfileName;
+ byte[] buf = new byte[nBytes];
+ MgByteReader reader = new MgByteReader(infileName, "png", false);
+ Assert.AreEqual(nBlocks * nBytes, reader.GetLength());
+ reader.Read(buf, nBytes);
+ Assert.AreEqual(buf, testBytes);
+ Assert.AreEqual((nBlocks - 1) * nBytes, reader.GetLength());
+ reader.Rewind();
+ Assert.AreEqual(nBlocks * nBytes, reader.GetLength());
+ reader.ToFile(outfileName);
+ reader.Rewind();
+
+ byte[] buf2 = new byte[nBytes];
+ System.IO.FileStream fp = System.IO.File.OpenRead(outfileName);
+ for (int j = 0; j < nBlocks; j++)
+ {
+ fp.Read(buf2, 0, nBytes);
+ reader.Read(buf, nBytes);
+ Assert.AreEqual(buf, buf2);
+ }
+ fp.Close();
+ }
+ }
+
+ public class MemoryConstructor : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ ByteReaderTestData.Init();
+ var nBytes = ByteReaderTestData.nBytes;
+ var testBytes = ByteReaderTestData.testBytes;
+ var outfileName = ByteReaderTestData.outfileName;
+
+ byte[] buf = new byte[nBytes];
+ MgByteReader reader = new MgByteReader(testBytes, nBytes, "png");
+ Assert.AreEqual(nBytes, reader.GetLength());
+ reader.Read(buf, nBytes);
+ Assert.AreEqual(buf, testBytes);
+ Assert.AreEqual(0, reader.GetLength());
+ reader.Rewind();
+ Assert.AreEqual(nBytes, reader.GetLength());
+
+ reader.ToFile(outfileName);
+
+ System.IO.FileStream fp = System.IO.File.OpenRead(outfileName);
+ fp.Read(buf, 0, nBytes);
+ Assert.AreEqual(buf, testBytes);
+ fp.Close();
+ }
+ }
+
+ public class StringConstructor : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ ByteReaderTestData.Init();
+ var testString = ByteReaderTestData.testString;
+ MgByteReader reader = new MgByteReader(testString, "text/html");
+ Assert.AreEqual(testString.Length, reader.GetLength());
+ string buf = reader.ToString();
+ Assert.AreEqual(testString, buf);
+ Assert.AreEqual(testString.Length, reader.GetLength());
+ reader.Rewind();
+ Assert.AreEqual(testString.Length, reader.GetLength());
+ }
+ }
+}
Added: sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/ExternalTests/CollectionTests.cs
===================================================================
--- sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/ExternalTests/CollectionTests.cs (rev 0)
+++ sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/ExternalTests/CollectionTests.cs 2014-06-25 15:30:06 UTC (rev 8263)
@@ -0,0 +1,995 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OSGeo.MapGuide.Test.Common.ExternalTests
+{
+ public class GeomBuild
+ {
+ private MgGeometryFactory factory = new MgGeometryFactory();
+
+ public MgPoint CreatePoint()
+ {
+ MgCoordinate coord = factory.CreateCoordinateXYZ(5.0, 3.0, 2.0);
+ return factory.CreatePoint(coord);
+ }
+
+ public MgLineString CreateLineString(double offset)
+ {
+ MgCoordinateCollection coordCol = new MgCoordinateCollection();
+
+ MgCoordinate coord1 = factory.CreateCoordinateXY(offset + 0.0, 1.0);
+ MgCoordinate coord2 = factory.CreateCoordinateXY(offset + 2.0, 3.0);
+ MgCoordinate coord3 = factory.CreateCoordinateXY(offset + 4.0, 5.0);
+
+ coordCol.Add(coord1);
+ coordCol.Add(coord2);
+ coordCol.Add(coord3);
+
+ return factory.CreateLineString(coordCol);
+ }
+
+
+
+ public MgLinearRing CreateLinearRing(double offset)
+ {
+ MgCoordinate oCoord1 = factory.CreateCoordinateXY(0.0, offset);
+ MgCoordinate oCoord2 = factory.CreateCoordinateXY(5.0, offset);
+ MgCoordinate oCoord3 = factory.CreateCoordinateXY(5.0, offset + 5.0);
+ MgCoordinate oCoord4 = factory.CreateCoordinateXY(0.0, offset + 5.0);
+ MgCoordinate oCoord5 = factory.CreateCoordinateXY(0.0, offset);
+
+ MgCoordinateCollection outerRingCoord = new MgCoordinateCollection();
+ outerRingCoord.Add(oCoord1);
+ outerRingCoord.Add(oCoord2);
+ outerRingCoord.Add(oCoord3);
+ outerRingCoord.Add(oCoord4);
+ outerRingCoord.Add(oCoord5);
+
+ return factory.CreateLinearRing(outerRingCoord);
+ }
+
+
+ public MgPolygon CreatePolygon(double offset)
+ {
+
+
+ // OuterRing
+ MgCoordinate oCoord1 = factory.CreateCoordinateXY(offset + 0.0, 0.0);
+ MgCoordinate oCoord2 = factory.CreateCoordinateXY(offset + 5.0, 0.0);
+ MgCoordinate oCoord3 = factory.CreateCoordinateXY(offset + 5.0, 5.0);
+ MgCoordinate oCoord4 = factory.CreateCoordinateXY(offset + 0.0, 5.0);
+ MgCoordinate oCoord5 = factory.CreateCoordinateXY(offset + 0.0, 0.0);
+
+ MgCoordinateCollection outerRingCoord = new MgCoordinateCollection();
+ outerRingCoord.Add(oCoord1);
+ outerRingCoord.Add(oCoord2);
+ outerRingCoord.Add(oCoord3);
+ outerRingCoord.Add(oCoord4);
+ outerRingCoord.Add(oCoord5);
+
+ // Inner Ring1
+ MgCoordinate i1Coord1 = factory.CreateCoordinateXY(offset + 1.0, 1.0);
+ MgCoordinate i1Coord2 = factory.CreateCoordinateXY(offset + 2.0, 1.0);
+ MgCoordinate i1Coord3 = factory.CreateCoordinateXY(offset + 2.0, 2.0);
+ MgCoordinate i1Coord4 = factory.CreateCoordinateXY(offset + 1.0, 1.0);
+
+ MgCoordinateCollection inner1RingCoord = new MgCoordinateCollection();
+ inner1RingCoord.Add(i1Coord1);
+ inner1RingCoord.Add(i1Coord2);
+ inner1RingCoord.Add(i1Coord3);
+ inner1RingCoord.Add(i1Coord4);
+
+ // Inner Ring2
+ MgCoordinate i2Coord1 = factory.CreateCoordinateXY(offset + 3.0, 3.0);
+ MgCoordinate i2Coord2 = factory.CreateCoordinateXY(offset + 4.0, 3.0);
+ MgCoordinate i2Coord3 = factory.CreateCoordinateXY(offset + 4.0, 4.0);
+ MgCoordinate i2Coord4 = factory.CreateCoordinateXY(offset + 3.0, 3.0);
+
+ MgCoordinateCollection inner2RingCoord = new MgCoordinateCollection();
+ inner2RingCoord.Add(i2Coord1);
+ inner2RingCoord.Add(i2Coord2);
+ inner2RingCoord.Add(i2Coord3);
+ inner2RingCoord.Add(i2Coord4);
+
+ MgLinearRing extRing = factory.CreateLinearRing(outerRingCoord);
+ MgLinearRing intRing1 = factory.CreateLinearRing(inner1RingCoord);
+ MgLinearRing intRing2 = factory.CreateLinearRing(inner2RingCoord);
+
+ MgLinearRingCollection intRings = new MgLinearRingCollection();
+ intRings.Add(intRing1);
+ intRings.Add(intRing2);
+
+ return factory.CreatePolygon(extRing, intRings);
+ }
+
+
+ public MgCurveString CreateCurveString(double offset)
+ {
+
+
+ // Create and return a curvestring consisting of
+ // one circulararc segment and one linearstring segment
+
+ // arcseg = (0,0), (0,1), (1,2)
+ // lineseg = (1,2), (3,0), (3,2)
+
+ // ArcSegment
+ MgCoordinate startPos = factory.CreateCoordinateXY(offset + 0.0, offset + 0.0);
+ MgCoordinate midPos = factory.CreateCoordinateXY(offset + 0.0, offset + 1.0);
+ MgCoordinate endPos = factory.CreateCoordinateXY(offset + 1.0, offset + 2.0);
+ MgArcSegment arcSeg = factory.CreateArcSegment(startPos, endPos, midPos);
+
+ // Linear Segment
+ MgCoordinateCollection points = new MgCoordinateCollection();
+ MgCoordinate pt1 = factory.CreateCoordinateXY(offset + 1.0, offset + 2.0);
+ MgCoordinate pt2 = factory.CreateCoordinateXY(offset + 3.0, offset + 0.0);
+ MgCoordinate pt3 = factory.CreateCoordinateXY(offset + 3.0, offset + 2.0);
+ points.Add(pt1);
+ points.Add(pt2);
+ points.Add(pt3);
+ MgLinearSegment lineSeg = factory.CreateLinearSegment(points);
+
+ // CurveSegment
+ MgCurveSegmentCollection curveSegs = new MgCurveSegmentCollection();
+ curveSegs.Add(arcSeg);
+ curveSegs.Add(lineSeg);
+
+ return factory.CreateCurveString(curveSegs);
+ }
+
+
+ public MgCurveRing CreateCurveRing(double offset)
+ {
+ // Ring is a closed entity.
+ // Create and return a ring consisting of
+ // one circulararc segment and one linearstring segment
+
+ // arcseg = (0,0), (0,1), (1,2)
+ // lineseg = (1,2), (0,0)
+
+
+
+ // ArcSegment
+ MgCoordinate startPos = factory.CreateCoordinateXY(offset + 0.0, offset + 0.0);
+ MgCoordinate midPos = factory.CreateCoordinateXY(offset + 0.0, offset + 1.0);
+ MgCoordinate endPos = factory.CreateCoordinateXY(offset + 1.0, offset + 2.0);
+ MgArcSegment arcSeg = factory.CreateArcSegment(startPos, endPos, midPos);
+
+ // Linear Segment
+ MgCoordinateCollection points = new MgCoordinateCollection();
+ MgCoordinate fromPt = factory.CreateCoordinateXY(offset + 1.0, offset + 2.0);
+ MgCoordinate toPt = factory.CreateCoordinateXY(offset + 0.0, offset + 0.0);
+ points.Add(fromPt);
+ points.Add(toPt);
+ MgLinearSegment lineSeg = factory.CreateLinearSegment(points);
+
+ // Curve Segment
+ MgCurveSegmentCollection curveSegs = new MgCurveSegmentCollection();
+ curveSegs.Add(arcSeg);
+ curveSegs.Add(lineSeg);
+
+ return factory.CreateCurveRing(curveSegs);
+ }
+
+
+ public MgCurvePolygon CreateCurvePolygon(double offset, int increment)
+ {
+
+
+ MgCurveRing extRing = CreateCurveRing(offset + increment);
+
+ MgCurveRingCollection intRings = new MgCurveRingCollection();
+
+ MgCurveRing ring1 = CreateCurveRing(offset + 2 * increment);
+ MgCurveRing ring2 = CreateCurveRing(offset + 3 * increment);
+
+ intRings.Add(ring1);
+ intRings.Add(ring2);
+
+ return factory.CreateCurvePolygon(extRing, intRings);
+ }
+
+
+ public MgMultiPoint CreateMultiPoint()
+ {
+
+
+ MgCoordinate coord1 = factory.CreateCoordinateXYZ(1.0, 2.0, 3.0);
+ MgPoint point1 = factory.CreatePoint(coord1);
+
+ MgCoordinate coord2 = factory.CreateCoordinateXYZ(4.0, 5.0, 6.0);
+ MgPoint point2 = factory.CreatePoint(coord2);
+
+ MgCoordinate coord3 = factory.CreateCoordinateXYZ(7.0, 8.0, 9.0);
+ MgPoint point3 = factory.CreatePoint(coord3);
+
+ MgPointCollection pnts = new MgPointCollection();
+ pnts.Add(point1);
+ pnts.Add(point2);
+ pnts.Add(point3);
+
+ return factory.CreateMultiPoint(pnts);
+ }
+
+
+ public MgMultiLineString CreateMultiLineString()
+ {
+
+
+ MgCoordinate coord1 = factory.CreateCoordinateXYZ(0.0, 1.0, 2.0);
+ MgCoordinate coord2 = factory.CreateCoordinateXYZ(3.0, 4.0, 5.0);
+ MgCoordinate coord3 = factory.CreateCoordinateXYZ(6.0, 7.0, 8.0);
+
+ MgCoordinateCollection coordColA = new MgCoordinateCollection();
+ coordColA.Add(coord1);
+ coordColA.Add(coord2);
+ coordColA.Add(coord3);
+
+ MgCoordinate coord4 = factory.CreateCoordinateXYZ(9.0, 10.0, 11.0);
+ MgCoordinate coord5 = factory.CreateCoordinateXYZ(12.0, 13.0, 14.0);
+ MgCoordinate coord6 = factory.CreateCoordinateXYZ(15.0, 16.0, 17.0);
+
+ MgCoordinateCollection coordColB = new MgCoordinateCollection();
+ coordColB.Add(coord4);
+ coordColB.Add(coord5);
+ coordColB.Add(coord6);
+
+ MgLineString lineString1 = factory.CreateLineString(coordColA);
+ MgLineString lineString2 = factory.CreateLineString(coordColB);
+
+ MgLineStringCollection lineStrings = new MgLineStringCollection();
+ lineStrings.Add(lineString1);
+ lineStrings.Add(lineString2);
+
+ return factory.CreateMultiLineString(lineStrings);
+ }
+
+
+ public MgMultiPolygon CreateMultiPolygon()
+ {
+
+
+ MgPolygon polygon1 = CreatePolygon(0.0);
+ MgPolygon polygon2 = CreatePolygon(0.0);
+
+ MgPolygonCollection polygons = new MgPolygonCollection();
+ polygons.Add(polygon1);
+ polygons.Add(polygon2);
+
+ return factory.CreateMultiPolygon(polygons);
+ }
+
+
+ MgMultiCurveString CreateMultiCurveString()
+ {
+
+
+ MgCurveString curveString1 = CreateCurveString(100);
+ MgCurveString curveString2 = CreateCurveString(200);
+ MgCurveString curveString3 = CreateCurveString(300);
+
+ MgCurveStringCollection curveStrings = new MgCurveStringCollection();
+ curveStrings.Add(curveString1);
+ curveStrings.Add(curveString2);
+ curveStrings.Add(curveString3);
+
+ return factory.CreateMultiCurveString(curveStrings);
+ }
+
+
+ public MgMultiCurvePolygon CreateMultiCurvePolygon(int numCurvePolys, double offset)
+ {
+
+
+ MgCurvePolygonCollection curvePolys = new MgCurvePolygonCollection();
+ for (int i = 0; i < numCurvePolys; i++)
+ {
+ MgCurvePolygon curvePoly = CreateCurvePolygon(i + offset, 1);
+ curvePolys.Add(curvePoly);
+ }
+
+ return factory.CreateMultiCurvePolygon(curvePolys);
+ }
+
+
+ public MgMultiGeometry CreateMultiGeometry()
+ {
+
+
+ MgGeometryCollection geometries = new MgGeometryCollection();
+ MgGeometry geometry = null;
+
+ // CurvePolygon
+ geometry = (MgGeometry)CreateCurvePolygon(0, 1);
+ geometries.Add(geometry);
+
+ // CurveString
+ // Not doing CurveString because of some unfixed defect.
+ // It may be the same one that sometimes affects MultiPolygon.
+ geometry = (MgGeometry)CreateCurveString(100);
+ geometries.Add(geometry);
+
+ // LineString
+ geometry = (MgGeometry)CreateLineString(1.0);
+ geometries.Add(geometry);
+
+ // Point
+ geometry = (MgGeometry)CreatePoint();
+ geometries.Add(geometry);
+
+ // Polygon
+ geometry = CreatePolygon(0.0);
+ geometries.Add(geometry);
+
+ // Make MultiGeometry from the many geometries collected above.
+ return factory.CreateMultiGeometry(geometries);
+ }
+
+ public MgArcSegment CreateArcSegment(double offset)
+ {
+ MgCoordinate startPos = factory.CreateCoordinateXY(offset + 0.0, offset + 0.0);
+ MgCoordinate midPos = factory.CreateCoordinateXY(offset + 0.0, offset + 1.0);
+ MgCoordinate endPos = factory.CreateCoordinateXY(offset + 1.0, offset + 2.0);
+ return factory.CreateArcSegment(startPos, endPos, midPos);
+ }
+ }
+
+ public class CollectionTestsIntCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgIntCollection coll = new MgIntCollection();
+ coll.Add(10);
+ coll.Add(20);
+ coll.Add(30);
+ coll.Add(40);
+ coll.Add(50);
+ Assert.AreEqual(20, coll.GetItem(1));
+ Assert.AreEqual(30, coll[2]);
+ Assert.AreEqual(5, coll.Count);
+
+ int j = 0;
+ foreach (int i in coll)
+ {
+ j += i;
+ }
+ Assert.AreEqual(150, j);
+ }
+ }
+
+ public class CollectionTestsPropertyCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgPropertyCollection coll = new MgPropertyCollection();
+ MgDoubleProperty dblProp = new MgDoubleProperty("DoubleProp", 1.1111);
+ MgInt32Property intProp = new MgInt32Property("IntProp", 1);
+ MgDateTime dateTime = new MgDateTime(2006, 9, 21);
+ MgDateTimeProperty dateProp = new MgDateTimeProperty("DateProp", dateTime);
+ MgSingleProperty single = new MgSingleProperty("SingleProp", (float)2.2222);
+ coll.Add(dblProp);
+ coll.Add(intProp);
+ coll.Add(dateProp);
+ coll[2] = single;
+
+ Assert.AreEqual(1.1111, (coll[0] as MgDoubleProperty).GetValue());
+ Assert.AreEqual(MgPropertyType.Double, coll[0].GetPropertyType());
+ Assert.AreEqual(MgPropertyType.Int32, coll[1].GetPropertyType());
+ Assert.AreEqual(MgPropertyType.Single, coll[2].GetPropertyType());
+ Assert.AreEqual((float)2.2222, (coll[2] as MgSingleProperty).GetValue());
+ Assert.AreEqual(3, coll.Count);
+
+ Assert.AreEqual(MgPropertyType.Double, coll[0].GetPropertyType());
+
+ string str = "";
+ foreach (MgProperty prop in coll)
+ {
+ str = str + "[" + prop.GetName() + "]";
+ }
+ Assert.AreEqual("[DoubleProp][IntProp][SingleProp]", str);
+ }
+ }
+
+ public class CollectionTestsBatchPropertyCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgPropertyCollection coll1 = new MgPropertyCollection();
+ MgDoubleProperty dblProp = new MgDoubleProperty("DoubleProp", 1.1111);
+ coll1.Add(dblProp);
+
+ MgPropertyCollection coll2 = new MgPropertyCollection();
+ MgInt32Property intProp = new MgInt32Property("IntProp", 1);
+ coll2.Add(intProp);
+
+ MgPropertyCollection coll3 = new MgPropertyCollection();
+ MgSingleProperty single = new MgSingleProperty("SingleProp", (float)2.2222);
+ coll3.Add(single);
+
+
+ MgBatchPropertyCollection coll = new MgBatchPropertyCollection();
+ coll.Add(coll1);
+ coll.Add(coll2);
+
+ Assert.AreEqual(2, coll.Count);
+ Assert.AreEqual(MgPropertyType.Double, coll[0][0].GetPropertyType());
+ Assert.AreEqual(MgPropertyType.Int32, coll[1][0].GetPropertyType());
+
+ coll[1] = coll3;
+
+ string str = "";
+ foreach (MgPropertyCollection c in coll)
+ {
+ str = str + "[" + c[0].GetName() + "]";
+ }
+ Assert.AreEqual("[DoubleProp][SingleProp]", str);
+ }
+ }
+
+ public class CollectionTestsClassDefinitionCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgClassDefinition class1 = new MgClassDefinition();
+ class1.SetName("class1");
+
+ MgClassDefinition class2 = new MgClassDefinition();
+ class2.SetName("class2");
+
+ MgClassDefinition class3 = new MgClassDefinition();
+ class3.SetName("class3");
+
+ MgClassDefinitionCollection coll = new MgClassDefinitionCollection();
+ coll.Insert(0, class3);
+ coll.Insert(0, class2);
+ coll.Insert(0, class1);
+
+ Assert.AreEqual(3, coll.Count);
+ Assert.AreEqual("class2", coll[1].GetName());
+
+ MgClassDefinition tmp = coll[0];
+ coll[0] = coll[1];
+ coll[1] = coll[2];
+ coll[2] = tmp;
+
+ string str = "";
+ foreach (MgClassDefinition def in coll)
+ {
+ str = str + "[" + def.GetName() + "]";
+ }
+ Assert.AreEqual("[class2][class3][class1]", str);
+ }
+ }
+
+ public class CollectionTestsCoordinateCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinate c1 = gf.CreateCoordinateXY(1.0, 1.0);
+ MgCoordinate c2 = gf.CreateCoordinateXY(2.0, 2.0);
+ MgCoordinate c3 = gf.CreateCoordinateXY(3.0, 3.0);
+ MgCoordinate c4 = gf.CreateCoordinateXY(4.0, 4.0);
+
+ MgCoordinateCollection coll = new MgCoordinateCollection();
+ coll.Add(c1);
+ coll.Insert(1, c2);
+ coll.Add(c3);
+ coll.Add(c4);
+
+ Assert.AreEqual(4, coll.Count);
+ Assert.AreEqual(1.0, coll[0].GetX());
+ coll[3] = coll[2];
+ Assert.AreEqual(3.0, coll[3].GetX());
+
+ double sum = 0.0;
+ foreach (MgCoordinate coord in coll)
+ {
+ sum += coord.GetX();
+ }
+ Assert.AreEqual(9.0, sum);
+ }
+ }
+
+
+ public class CollectionTestsCurvePolygonCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ var build = new GeomBuild();
+ MgCurvePolygon geom1 = build.CreateCurvePolygon(2.0, 5);
+ MgCurvePolygon geom2 = build.CreateCurvePolygon(12.0, 5);
+ MgCurvePolygon geom3 = build.CreateCurvePolygon(2.0, 5);
+
+ MgCurvePolygonCollection coll = new MgCurvePolygonCollection();
+ coll.Add(geom1);
+ coll.Add(geom2);
+ coll.Add(geom3);
+
+ Assert.AreEqual(3, coll.Count);
+ Assert.IsTrue(geom1.Equals(coll[0]));
+ Assert.IsTrue(coll[0].Equals(coll[2]));
+ Assert.IsFalse(coll[0].Equals(coll[1]));
+ coll[0] = coll[1];
+ Assert.IsTrue(coll[0].Equals(coll[1]));
+
+ double width = 0.0;
+ foreach (MgCurvePolygon geom in coll)
+ {
+ width += geom.Envelope().GetWidth();
+ }
+ Assert.AreEqual(geom1.Envelope().GetWidth() * 3.0, width);
+ }
+ }
+
+ public class CollectionTestsCurveRingCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ var build = new GeomBuild();
+ MgCurveRing geom1 = build.CreateCurveRing(2.0);
+ MgCurveRing geom2 = build.CreateCurveRing(12.0);
+ MgCurveRing geom3 = build.CreateCurveRing(2.0);
+
+ MgCurveRingCollection coll = new MgCurveRingCollection();
+ coll.Add(geom1);
+ coll.Add(geom2);
+ coll.Add(geom3);
+
+ Assert.AreEqual(3, coll.Count);
+ Assert.IsTrue(geom1.Envelope().Contains(coll[0].Envelope()));
+ Assert.IsTrue(coll[0].Envelope().Contains(coll[2].Envelope()));
+ Assert.IsFalse(coll[0].Envelope().Contains(coll[1].Envelope()));
+ coll[0] = coll[1];
+ Assert.IsTrue(coll[0].Envelope().Contains(coll[1].Envelope()));
+
+ double width = 0.0;
+ foreach (MgCurveRing geom in coll)
+ {
+ width += geom.Envelope().GetWidth();
+ }
+ Assert.AreEqual(geom1.Envelope().GetWidth() * 3.0, width);
+ }
+ }
+
+ public class CollectionTestsCurveSegmentCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ var build = new GeomBuild();
+ MgArcSegment geom1 = build.CreateArcSegment(2.0);
+ MgArcSegment geom2 = build.CreateArcSegment(12.0);
+ MgArcSegment geom3 = build.CreateArcSegment(2.0);
+
+ MgCurveSegmentCollection coll = new MgCurveSegmentCollection();
+ coll.Add(geom1);
+ coll.Add(geom2);
+ coll.Add(geom3);
+
+ Assert.AreEqual(3, coll.Count);
+ Assert.IsTrue(geom1.Envelope().Contains(coll[0].Envelope()));
+ Assert.IsTrue(coll[0].Envelope().Contains(coll[2].Envelope()));
+ Assert.IsFalse(coll[0].Envelope().Contains(coll[1].Envelope()));
+ coll[0] = coll[1];
+ Assert.IsTrue(coll[0].Envelope().Contains(coll[1].Envelope()));
+
+ double width = 0.0;
+ foreach (MgCurveSegment geom in coll)
+ {
+ width += geom.Envelope().GetWidth();
+ }
+ Assert.AreEqual(geom1.Envelope().GetWidth() * 3.0, width);
+ }
+ }
+
+ public class CollectionTestsCurveStringCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ var build = new GeomBuild();
+ MgCurveString geom1 = build.CreateCurveString(2.0);
+ MgCurveString geom2 = build.CreateCurveString(12.0);
+ MgCurveString geom3 = build.CreateCurveString(2.0);
+
+ MgCurveStringCollection coll = new MgCurveStringCollection();
+ coll.Add(geom1);
+ coll.Add(geom2);
+ coll.Add(geom3);
+
+ Assert.AreEqual(3, coll.Count);
+ Assert.IsTrue(geom1.Equals(coll[0]));
+ Assert.IsTrue(coll[0].Equals(coll[2]));
+ Assert.IsFalse(coll[0].Equals(coll[1]));
+ coll[0] = coll[1];
+ Assert.IsTrue(coll[0].Equals(coll[1]));
+
+ double width = 0.0;
+ foreach (MgCurveString geom in coll)
+ {
+ width += geom.Envelope().GetWidth();
+ }
+ Assert.AreEqual(geom1.Envelope().GetWidth() * 3.0, width);
+ }
+ }
+
+ public class CollectionTestsFeatureCommandCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgPropertyCollection propVals = new MgPropertyCollection();
+ MgInt32Property prop = new MgInt32Property("prop", 1);
+ propVals.Add(prop);
+ MgUpdateFeatures update = new MgUpdateFeatures("class2", propVals, "where cat < dog");
+ MgInsertFeatures insert = new MgInsertFeatures("class3", propVals);
+ MgDeleteFeatures del = new MgDeleteFeatures("class1", "where cat > dog");
+
+ MgFeatureCommandCollection coll = new MgFeatureCommandCollection();
+ coll.Add(update);
+ coll.Add(insert);
+ coll.Add(del);
+
+ Assert.AreEqual(3, coll.Count);
+ Assert.AreEqual(MgFeatureCommandType.DeleteFeatures, coll[2].GetCommandType());
+ coll[0] = coll[1];
+
+ string txt = "";
+ foreach (MgFeatureCommand cmd in coll)
+ {
+ txt += "[" + cmd.GetCommandType() + "]";
+ }
+ Assert.AreEqual("[0][0][2]", txt);
+ }
+ }
+
+ public class CollectionTestsFeatureSchemaCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgFeatureSchema schema1 = new MgFeatureSchema("schema1", "desc1");
+ MgFeatureSchema schema2 = new MgFeatureSchema("schema2", "desc2");
+ MgFeatureSchema schema3 = new MgFeatureSchema("schema3", "desc3");
+
+ MgFeatureSchemaCollection coll = new MgFeatureSchemaCollection();
+ coll.Add(schema1);
+ coll.Add(schema2);
+ coll.Add(schema3);
+
+ Assert.AreEqual(3, coll.Count);
+ Assert.AreEqual("schema3", coll[2].GetName());
+ coll[0] = coll[2];
+
+ string txt = "";
+ foreach (MgFeatureSchema schema in coll)
+ {
+ txt += "[" + schema.GetName() + "]";
+ }
+ Assert.AreEqual("[schema3][schema2][schema3]", txt);
+ }
+ }
+
+ public class CollectionTestsGeometryCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ var wkt = new MgWktReaderWriter();
+ MgPoint geom1 = wkt.Read("POINT XY (1.0 1.0)") as MgPoint;
+ MgPoint geom2 = wkt.Read("POINT XY (2.0 2.0)") as MgPoint;
+ MgPoint geom3 = wkt.Read("POINT XY (1.0 1.0)") as MgPoint;
+
+ MgGeometryCollection coll = new MgGeometryCollection();
+ coll.Add(geom1);
+ coll.Add(geom2);
+ coll.Add(geom3);
+
+ Assert.AreEqual(3, coll.Count);
+ Assert.IsTrue(geom1.Equals(coll[0]));
+ Assert.IsTrue(coll[0].Equals(coll[2]));
+ Assert.IsFalse(coll[0].Equals(coll[1]));
+ coll[0] = coll[1];
+ Assert.IsTrue(coll[0].Equals(coll[1]));
+
+ double x = 0.0;
+ foreach (MgGeometry geom in coll)
+ {
+ x += (geom as MgPoint).GetCoordinate().GetX();
+ }
+ Assert.AreEqual(5.0, x);
+ }
+ }
+
+ public class CollectionTestsLayerCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ logger.WriteLine("Skipping CollectionTestsLayerCollection: Resource Service required to construct MgLayer");
+ }
+ }
+
+ public class CollectionTestsLayerGroupCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ logger.WriteLine("Skipping CollectionTestsLayerCollection: MgLayerGroupCollection constructor not visible");
+ /*
+ MgLayerGroup group1 = new MgLayerGroup("group1");
+ MgLayerGroup group2 = new MgLayerGroup("group2");
+ MgLayerGroup group3 = new MgLayerGroup("group3");
+ MgLayerGroup group4 = new MgLayerGroup("group4");
+
+ MgLayerGroupCollection coll = new MgLayerGroupCollection();
+ coll.Add(group1);
+ coll.Insert(1, group2);
+ coll.Add(group3);
+ coll.Insert(3, group4);
+
+ Assert.AreEqual(4, coll.Count);
+ Assert.AreEqual(coll[2].GetName(), "group3");
+
+ coll[1] = coll[2];
+
+ string txt = "";
+ foreach (MgLayerGroup group in coll)
+ {
+ txt += "[" + group.GetName() + "]";
+ }
+ Assert.AreEqual("[group1][group3][group3][group4]", txt);
+ */
+ }
+ }
+
+ public class CollectionTestsLinearRingCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ var build = new GeomBuild();
+ MgLinearRing geom1 = build.CreateLinearRing(1.0);
+ MgLinearRing geom2 = build.CreateLinearRing(5.0);
+ MgLinearRing geom3 = build.CreateLinearRing(1.0);
+
+ MgLinearRingCollection coll = new MgLinearRingCollection();
+ coll.Add(geom1);
+ coll.Add(geom2);
+ coll.Add(geom3);
+
+ Assert.AreEqual(3, coll.Count);
+ Assert.IsTrue(geom1.Envelope().Contains(coll[0].Envelope()));
+ Assert.IsTrue(coll[0].Envelope().Contains(coll[2].Envelope()));
+ Assert.IsFalse(coll[0].Envelope().Contains(coll[1].Envelope()));
+ coll[0] = coll[1];
+ Assert.IsTrue(coll[0].Envelope().Contains(coll[1].Envelope()));
+
+ double width = 0.0;
+ foreach (MgLinearRing geom in coll)
+ {
+ width += geom.Envelope().GetWidth();
+ }
+ Assert.AreEqual(geom1.Envelope().GetWidth() * 3.0, width);
+ }
+ }
+
+ public class CollectionTestsLineStringCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ var build = new GeomBuild();
+ MgLineString geom1 = build.CreateLineString(5.0);
+ MgLineString geom2 = build.CreateLineString(11.0);
+ MgLineString geom3 = build.CreateLineString(5.0);
+
+ MgLineStringCollection coll = new MgLineStringCollection();
+ coll.Add(geom1);
+ coll.Add(geom2);
+ coll.Add(geom3);
+
+ Assert.AreEqual(3, coll.Count);
+ Assert.IsTrue(geom1.Equals(coll[0]));
+ Assert.IsTrue(coll[0].Equals(coll[2]));
+ Assert.IsFalse(coll[0].Equals(coll[1]));
+ coll[0] = coll[1];
+ Assert.IsTrue(coll[0].Equals(coll[1]));
+
+ double width = 0.0;
+ foreach (MgLineString geom in coll)
+ {
+ width += geom.Envelope().GetWidth();
+ }
+ Assert.AreEqual(geom1.Envelope().GetWidth() * 3.0, width);
+ }
+ }
+
+ public class CollectionTestsMapCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ string coordsys = "GEOGCS[\"LL84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]";
+ MgEnvelope env = new MgEnvelope(10, 10, 20, 20);
+ MgMapBase map1 = factory.CreateMap();
+ map1.Create(coordsys, env, "map1");
+ MgMapBase map2 = factory.CreateMap();
+ map2.Create(coordsys, env, "map2");
+ MgMapBase map3 = factory.CreateMap();
+ map3.Create(coordsys, env, "map3");
+ MgMapBase map4 = factory.CreateMap();
+ map4.Create(coordsys, env, "map4");
+
+ MgMapCollection coll = new MgMapCollection();
+ coll.Add(map1);
+ coll.Insert(1, map2);
+ coll.Add(map3);
+
+ Assert.AreEqual(3, coll.Count);
+ Assert.AreEqual(coll[2].GetName(), "map3");
+
+ coll[1] = map4;
+
+
+ string txt = "";
+ foreach (MgMapBase map in coll)
+ {
+ txt += "[" + map.GetName() + "]";
+ }
+ Assert.AreEqual("[map1][map4][map3]", txt);
+ }
+ }
+
+ public class CollectionTestsPointCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ var wkt = new MgWktReaderWriter();
+ MgPoint geom1 = wkt.Read("POINT XY (1.0 1.0)") as MgPoint;
+ MgPoint geom2 = wkt.Read("POINT XY (2.0 2.0)") as MgPoint;
+ MgPoint geom3 = wkt.Read("POINT XY (1.0 1.0)") as MgPoint;
+
+ MgPointCollection coll = new MgPointCollection();
+ coll.Add(geom1);
+ coll.Add(geom2);
+ coll.Add(geom3);
+
+ Assert.AreEqual(3, coll.Count);
+ Assert.IsTrue(geom1.Equals(coll[0]));
+ Assert.IsTrue(coll[0].Equals(coll[2]));
+ Assert.IsFalse(coll[0].Equals(coll[1]));
+ coll[0] = coll[1];
+ Assert.IsTrue(coll[0].Equals(coll[1]));
+
+ double x = 0.0;
+ foreach (MgPoint geom in coll)
+ {
+ x += geom.GetCoordinate().GetX();
+ }
+ Assert.AreEqual(5.0, x);
+ }
+ }
+
+ public class CollectionTestsPolygonCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ var build = new GeomBuild();
+ MgPolygon geom1 = build.CreatePolygon(2.0);
+ MgPolygon geom2 = build.CreatePolygon(12.0);
+ MgPolygon geom3 = build.CreatePolygon(2.0);
+
+ MgPolygonCollection coll = new MgPolygonCollection();
+ coll.Add(geom1);
+ coll.Add(geom2);
+ coll.Add(geom3);
+
+ Assert.AreEqual(3, coll.Count);
+ Assert.IsTrue(geom1.Equals(coll[0]));
+ Assert.IsTrue(coll[0].Equals(coll[2]));
+ Assert.IsFalse(coll[0].Equals(coll[1]));
+ coll[0] = coll[1];
+ Assert.IsTrue(coll[0].Equals(coll[1]));
+
+ double width = 0.0;
+ foreach (MgPolygon geom in coll)
+ {
+ width += geom.Envelope().GetWidth();
+ }
+ Assert.AreEqual(geom1.Envelope().GetWidth() * 3.0, width);
+ }
+ }
+
+ public class CollectionTestsPropertyDefinitionCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgDataPropertyDefinition def1 = new MgDataPropertyDefinition("def1");
+ MgDataPropertyDefinition def2 = new MgDataPropertyDefinition("def2");
+ MgDataPropertyDefinition def3 = new MgDataPropertyDefinition("def3");
+ MgDataPropertyDefinition def4 = new MgDataPropertyDefinition("def4");
+
+ MgPropertyDefinitionCollection coll = new MgPropertyDefinitionCollection();
+ coll.Add(def1);
+ coll.Add(def2);
+ coll.Insert(2, def4);
+ coll.Insert(2, def3);
+
+ Assert.AreEqual(4, coll.Count);
+ Assert.AreEqual("def1", coll[0].GetName());
+
+ MgPropertyDefinition tmp = coll[0];
+ coll.Remove(def1);
+ Assert.AreEqual(3, coll.Count);
+ coll.Insert(0, tmp);
+
+
+ string txt = "";
+ foreach (MgPropertyDefinition def in coll)
+ {
+ txt += "[" + def.GetName() + "]";
+ }
+ Assert.AreEqual("[def1][def2][def3][def4]", txt);
+ }
+ }
+
+ public class CollectionTestsReadOnlyLayerCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ logger.WriteLine("Skipping CollectionTestsReadOnlyLayerCollection: Resource Service required to construct MgLayer");
+ }
+ }
+
+ public class CollectionTestsStringCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ StringCollection strColl = new StringCollection();
+ strColl.Add("string1");
+ strColl.Add("string2");
+ strColl.Add("string3");
+ strColl.Add("string3");
+
+ MgStringCollection coll1 = new MgStringCollection();
+ coll1.Add("Hello");
+
+ MgStringCollection coll2 = new MgStringCollection(strColl);
+ Assert.AreEqual(4, coll2.GetCount());
+ StringCollection coll3 = coll2;
+ Assert.AreEqual(4, coll3.Count);
+ for (int i = 0; i < 4; i++)
+ {
+ Assert.AreEqual(strColl[i], coll2.GetItem(i));
+ Assert.AreEqual(strColl[i], coll3[i]);
+ }
+
+ }
+ }
+
+ public class CollectionTestsStringPropertyCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgStringProperty prop1 = new MgStringProperty("prop1", "val1");
+ MgStringProperty prop2 = new MgStringProperty("prop2", "val2");
+ MgStringProperty prop3 = new MgStringProperty("prop3", "val3");
+ MgStringProperty prop4 = new MgStringProperty("prop4", "val4");
+
+ MgStringPropertyCollection coll = new MgStringPropertyCollection();
+ coll.Add(prop1);
+ coll.Add(prop2);
+ coll.Remove(prop3);
+ coll.Remove(coll[1]);
+ Assert.AreEqual(1, coll.Count);
+ coll.Add(prop3);
+ coll[1] = prop2;
+ coll.Insert(2, prop3);
+ Assert.AreEqual(2, coll.IndexOf(prop3));
+ coll.Add(prop4);
+
+ string txt = "";
+ foreach (MgStringProperty prop in coll)
+ {
+ txt += "[" + prop.GetName() + "]";
+ }
+ Assert.AreEqual("[prop1][prop2][prop3][prop4]", txt);
+ }
+ }
+}
Added: sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/ExternalTests/PropertiesTest.cs
===================================================================
--- sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/ExternalTests/PropertiesTest.cs (rev 0)
+++ sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/ExternalTests/PropertiesTest.cs 2014-06-25 15:30:06 UTC (rev 8263)
@@ -0,0 +1,1080 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OSGeo.MapGuide.Test.Common.ExternalTests
+{
+ public class PropertiesTestColor : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ short nRed = 22;
+ short nGreen = 33;
+ short nBlue = 44;
+ short nAlpha = 55;
+ MgColor color = new MgColor(nRed, nGreen, nBlue, nAlpha);
+ Assert.AreEqual(nRed, color.Red);
+ Assert.AreEqual(nGreen, color.Green);
+ Assert.AreEqual(nBlue, color.Blue);
+ Assert.AreEqual(nAlpha, color.Alpha);
+ String scolor = nRed.ToString("x") + nGreen.ToString("x") + nBlue.ToString("x") + nAlpha.ToString("x");
+ Assert.AreEqual(scolor, color.Color);
+ }
+ }
+
+ public class PropertiesTestDateTime : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgDateTime dt = new MgDateTime();
+ dt.Year = 2006;
+ dt.Month = 9;
+ dt.Day = 21;
+ dt.Hour = 16;
+ dt.Minute = 4;
+ dt.Second = 25;
+ dt.Microsecond = 99;
+
+ Assert.AreEqual(2006, dt.Year);
+ Assert.AreEqual(9, dt.Month);
+ Assert.AreEqual(21, dt.Day);
+ Assert.AreEqual(16, dt.Hour);
+ Assert.AreEqual(4, dt.Minute);
+ Assert.AreEqual(25, dt.Second);
+ Assert.AreEqual(99, dt.Microsecond);
+ }
+ }
+
+ public class PropertiesTestByteReader : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgByteSource source = new MgByteSource("../../TestData/DrawingService/SpaceShip.dwf");
+ source.MimeType = MgMimeType.Dwf;
+ MgByteReader reader = source.GetReader();
+
+ Assert.AreEqual(MgMimeType.Dwf, reader.MimeType);
+ }
+ }
+
+ public class PropertiesTestByteSource : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ string tmp = Path.GetTempFileName();
+ try
+ {
+ File.WriteAllText(tmp, "Hello World");
+
+ MgByteSource source = new MgByteSource(tmp);
+ source.MimeType = "text/plain";
+
+ Assert.AreEqual(MgMimeType.Text, source.MimeType);
+ }
+ finally
+ {
+ try
+ {
+ File.Delete(tmp);
+ }
+ catch { }
+ }
+ }
+ }
+
+ public class PropertiesTestPropertyDefinition : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgPropertyDefinition propDef = new MgPropertyDefinition("TestProp", MgPropertyType.Int32);
+ propDef.Description = "description";
+ propDef.QualifiedName = "qualifiedName";
+
+ Assert.AreEqual("TestProp", propDef.Name);
+ Assert.AreEqual(MgPropertyType.Int32, propDef.PropertyType);
+ Assert.AreEqual("description", propDef.Description);
+ Assert.AreEqual("qualifiedName", propDef.QualifiedName);
+ }
+ }
+
+ public class PropertiesTestStringProperty : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgStringProperty sp = new MgStringProperty("TestStringName", "TestStringValue");
+
+ Assert.AreEqual("TestStringValue", sp.Value);
+ Assert.AreEqual("TestStringName", sp.Name);
+ }
+ }
+
+ public class PropertiesTestBlobProperty : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ string tmp = Path.GetTempFileName();
+ try
+ {
+ File.WriteAllText(tmp, "Hello World");
+
+ MgByteSource bs = new MgByteSource(tmp);
+ MgByteReader reader = bs.GetReader();
+ MgBlobProperty bp = new MgBlobProperty("BlobPropName", reader);
+
+ Assert.AreEqual("BlobPropName", bp.Name);
+ Assert.Greater((int)bp.Value.GetLength(), 0);
+ Assert.AreEqual(reader.GetLength(), bp.Value.GetLength());
+ Assert.AreEqual(MgPropertyType.Blob, bp.PropertyType);
+
+ MgByteSource bs2 = new MgByteSource("../../TestData/DrawingService/SpaceShip.dwf");
+ MgByteReader reader2 = bs2.GetReader();
+ bp.Value = reader2;
+ Assert.AreEqual(reader2.GetLength(), bp.Value.GetLength());
+ }
+ finally
+ {
+ try
+ {
+ File.Delete(tmp);
+ }
+ catch { }
+ }
+ }
+ }
+
+ public class PropertiesTestBooleanProperty : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgBooleanProperty bp = new MgBooleanProperty("BoolPropName", true);
+
+ Assert.IsTrue(bp.Value);
+ Assert.AreEqual("BoolPropName", bp.Name);
+ Assert.AreEqual(MgPropertyType.Boolean, bp.PropertyType);
+
+ bp.Value = false;
+ Assert.IsFalse(bp.Value);
+ }
+ }
+
+ public class PropertiesTestByteProperty : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ byte bpv = 123;
+ MgByteProperty bp = new MgByteProperty("BytePropName", bpv);
+
+ Assert.AreEqual("BytePropName", bp.Name);
+ Assert.AreEqual(bpv, bp.Value);
+ Assert.AreEqual(MgPropertyType.Byte, bp.PropertyType);
+ }
+ }
+
+ public class PropertiesTestClobProperty : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ string tmp = Path.GetTempFileName();
+ try
+ {
+ File.WriteAllText(tmp, "Hello World");
+
+ MgByteSource bs = new MgByteSource(tmp);
+ MgByteReader reader = bs.GetReader();
+ MgClobProperty cp = new MgClobProperty("ClobPropName", reader);
+
+ Assert.AreEqual("ClobPropName", cp.Name);
+ Assert.Greater((int)cp.Value.GetLength(), 0);
+ Assert.AreEqual(reader.GetLength(), cp.Value.GetLength());
+ Assert.AreEqual(MgPropertyType.Clob, cp.PropertyType);
+
+ MgByteSource bs2 = new MgByteSource("../../TestData/DrawingService/SpaceShip.dwf");
+ MgByteReader reader2 = bs2.GetReader();
+ cp.Value = reader2;
+ Assert.AreEqual(reader2.GetLength(), cp.Value.GetLength());
+ }
+ finally
+ {
+ try
+ {
+ File.Delete(tmp);
+ }
+ catch { }
+ }
+ }
+ }
+
+ public class PropertiesTestDateTimeProperty : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgDateTime dt = new MgDateTime(2006, 9, 22, 8, 33, 44, 55);
+ MgDateTimeProperty dtp = new MgDateTimeProperty("DateTimePropName", dt);
+
+ Assert.AreEqual("DateTimePropName", dtp.Name);
+ Assert.AreEqual(MgPropertyType.DateTime, dtp.PropertyType);
+ Assert.AreEqual(dt.Year, dtp.Value.Year);
+ Assert.AreEqual(dt.Month, dtp.Value.Month);
+ Assert.AreEqual(dt.Day, dtp.Value.Day);
+ Assert.AreEqual(dt.Hour, dtp.Value.Hour);
+ Assert.AreEqual(dt.Minute, dtp.Value.Minute);
+ Assert.AreEqual(dt.Second, dtp.Value.Second);
+ Assert.AreEqual(dt.Microsecond, dtp.Value.Microsecond);
+ }
+ }
+
+ public class PropertiesTestDoubleProperty : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgDoubleProperty dp = new MgDoubleProperty("DoublePropName", 4.251973);
+
+ Assert.AreEqual("DoublePropName", dp.Name);
+ Assert.AreEqual(MgPropertyType.Double, dp.PropertyType);
+ Assert.AreEqual(4.251973, dp.Value);
+ }
+ }
+
+ public class PropertiesTestInt16Property : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgInt16Property ip = new MgInt16Property("Int16PropName", -32768);
+
+ Assert.AreEqual("Int16PropName", ip.Name);
+ Assert.AreEqual(MgPropertyType.Int16, ip.PropertyType);
+ Assert.AreEqual(Int16.MinValue, ip.Value);
+ }
+ }
+
+ public class PropertiesTestInt32Property : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgInt32Property ip = new MgInt32Property("Int32PropName", -2147483648);
+
+ Assert.AreEqual("Int32PropName", ip.Name);
+ Assert.AreEqual(MgPropertyType.Int32, ip.PropertyType);
+ Assert.AreEqual(Int32.MinValue, ip.Value);
+ }
+ }
+
+ public class PropertiesTestInt64Property : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgInt64Property ip = new MgInt64Property("Int64PropName", -9223372036854775808);
+
+ Assert.AreEqual("Int64PropName", ip.Name);
+ Assert.AreEqual(MgPropertyType.Int64, ip.PropertyType);
+ Assert.AreEqual(Int64.MinValue, ip.Value);
+ }
+ }
+
+ public class PropertiesTestSingleProperty : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgSingleProperty sp = new MgSingleProperty("SinglePropName", 4.251973f);
+
+ Assert.AreEqual("SinglePropName", sp.Name);
+ Assert.AreEqual(MgPropertyType.Single, sp.PropertyType);
+ Assert.AreEqual(4.251973f, sp.Value);
+ }
+ }
+
+ public class PropertiesTestLayerBase : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ logger.WriteLine("Skipping PropertiesTestLayerBase: Resource Service required to construct MgLayer");
+ //MgUserInformation user = new MgUserInformation("Administrator", "admin");
+ //MgSiteConnection siteConnection = new MgSiteConnection();
+ //siteConnection.Open(user);
+ //MgResourceService resourceService = (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
+
+ //MgResourceIdentifier id = new MgResourceIdentifier("Library://UnitTests/Data/Shuttle.DrawingSource");
+
+ //MgLayerBase lb = new MgLayerBase(id, resourceService);
+
+ //lb.Name = "TestLayerName";
+ //Assert.AreEqual("TestLayerName", lb.Name);
+
+ //Assert.AreEqual(MgLayerType.Dynamic, lb.LayerType);
+
+ //MgLayerGroup lg = new MgLayerGroup("TestLayerGroup");
+ //lb.Group = lg;
+ //Assert.AreEqual(lg.Name, lb.Group.Name);
+
+ //lb.Visible = true;
+ //Assert.AreEqual(true, lb.Visible);
+ //lb.Visible = false;
+ //Assert.AreEqual(false, lb.Visible);
+
+ //lb.Selectable = true;
+ //Assert.AreEqual(true, lb.Selectable);
+ //lb.Selectable = false;
+ //Assert.AreEqual(false, lb.Selectable);
+
+ //Assert.AreEqual(id.ToString(), lb.LayerDefinition.ToString());
+
+ //lb.DisplayInLegend = true;
+ //Assert.AreEqual(true, lb.DisplayInLegend);
+ //lb.DisplayInLegend = false;
+ //Assert.AreEqual(false, lb.DisplayInLegend);
+
+ //Assert.AreEqual(false, lb.ExpandInLegend);
+
+ //lb.LegendLabel = "TestLegendLabel";
+ //Assert.AreEqual("TestLegendLabel", lb.LegendLabel);
+
+ //Assert.AreEqual("", lb.FeatureSourceId);
+ //Assert.AreEqual("", lb.FeatureClassName);
+ }
+ }
+
+ public class PropertiesTestLayerGroup : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgLayerGroup lg = new MgLayerGroup("TestLayerGroupName");
+
+ Assert.AreEqual("TestLayerGroupName", lg.Name);
+ Assert.AreEqual(MgLayerGroupType.Normal, lg.LayerGroupType);
+
+ lg.Group = new MgLayerGroup("AnotherTestLayerGroupName");
+ Assert.AreEqual("AnotherTestLayerGroupName", lg.Group.Name);
+
+ lg.Visible = true;
+ Assert.IsTrue(lg.Visible);
+ lg.Visible = false;
+ Assert.IsFalse(lg.Visible);
+
+ lg.DisplayInLegend = true;
+ Assert.IsTrue(lg.DisplayInLegend);
+ lg.DisplayInLegend = false;
+ Assert.IsFalse(lg.DisplayInLegend);
+
+ Assert.IsFalse(lg.ExpandInLegend);
+
+ lg.LegendLabel = "TestLegendLabel";
+ Assert.AreEqual("TestLegendLabel", lg.LegendLabel);
+ }
+ }
+
+ public class PropertiesTestMapBase : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgMapBase mb = factory.CreateMap();
+ Assert.AreEqual("", mb.Name);
+ Assert.AreEqual("", mb.SessionId);
+ Assert.IsNull(mb.MapDefinition);
+ Assert.AreEqual("", mb.MapSRS);
+ Assert.IsNull(mb.MapExtent);
+ Assert.IsNull(mb.ViewCenter);
+ Assert.AreEqual(1.0, mb.ViewScale);
+ Assert.IsNull(mb.DataExtent);
+ Assert.AreEqual(96, mb.DisplayDpi);
+ Assert.AreEqual(0, mb.DisplayWidth);
+ Assert.AreEqual(0, mb.DisplayHeight);
+ Assert.AreEqual(0, mb.FiniteDisplayScaleCount);
+ }
+ }
+
+ public class PropertiesTestClassDefinition : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgClassDefinition classDef = new MgClassDefinition();
+ classDef.DefaultGeometryPropertyName = "TestDefaultGeometryPropName";
+ Assert.AreEqual("TestDefaultGeometryPropName", classDef.DefaultGeometryPropertyName);
+
+ classDef.Name = "TestName";
+ Assert.AreEqual("TestName", classDef.Name);
+
+ classDef.Description = "TestDescription";
+ Assert.AreEqual("TestDescription", classDef.Description);
+
+ Assert.IsNull(classDef.BaseClassDefinition);
+ }
+ }
+
+ public class PropertiesTestFileFeatureSourceParams : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgFileFeatureSourceParams csp = new MgFileFeatureSourceParams();
+ csp.ProviderName = "OSGeo.SDF";
+ Assert.AreEqual("OSGeo.SDF", csp.ProviderName);
+
+ csp.SpatialContextName = "TestSpatialContextName";
+ Assert.AreEqual("TestSpatialContextName", csp.SpatialContextName);
+
+ csp.SpatialContextDescription = "TestSpatialContextDescription";
+ Assert.AreEqual("TestSpatialContextDescription", csp.SpatialContextDescription);
+
+ csp.CoordinateSystemWkt = "TestCoordSysWkt";
+ Assert.AreEqual("TestCoordSysWkt", csp.CoordinateSystemWkt);
+
+ csp.XYTolerance = 0.0001;
+ Assert.AreEqual(0.0001, csp.XYTolerance);
+
+ csp.ZTolerance = 0.01;
+ Assert.AreEqual(0.01, csp.ZTolerance);
+
+ MgFeatureSchema schema = new MgFeatureSchema("SchemaName", "SchemaDescription");
+ csp.FeatureSchema = schema;
+ Assert.AreEqual(schema.Name, csp.FeatureSchema.Name);
+ Assert.AreEqual(schema.Description, csp.FeatureSchema.Description);
+ }
+ }
+
+ public class PropertiesTestDataPropertyDefinition : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgDataPropertyDefinition dpd = new MgDataPropertyDefinition("DataPropDefName");
+
+ dpd.DataType = MgPropertyType.Int32;
+ Assert.AreEqual(MgPropertyType.Int32, dpd.DataType);
+
+ dpd.Length = 0;
+ Assert.AreEqual(0, dpd.Length);
+
+ dpd.Precision = 0;
+ Assert.AreEqual(0, dpd.Precision);
+
+ dpd.Scale = 0;
+ Assert.AreEqual(0, dpd.Scale);
+
+ dpd.DefaultValue = "123";
+ Assert.AreEqual("123", dpd.DefaultValue);
+
+ dpd.Nullable = true;
+ Assert.IsTrue(dpd.Nullable);
+
+ dpd.ReadOnly = false;
+ Assert.IsFalse(dpd.ReadOnly);
+ }
+ }
+
+ public class PropertiesTestDeleteFeatures : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgDeleteFeatures df = new MgDeleteFeatures("dfClassName", "dfFilterText");
+ Assert.AreEqual("dfClassName", df.FeatureClassName);
+ Assert.AreEqual("dfFilterText", df.FilterText);
+ }
+ }
+
+ public class PropertiesTestFeatureProperty : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgFeatureProperty fp = new MgFeatureProperty("FeatureProp", null);
+ Assert.AreEqual("FeatureProp", fp.Name);
+ Assert.AreEqual(MgPropertyType.Feature, fp.PropertyType);
+ Assert.IsNull(fp.Value);
+ }
+ }
+
+ public class PropertiesTestFeatureSchema : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgFeatureSchema fs = new MgFeatureSchema();
+ fs.Name = "fsName";
+ Assert.AreEqual("fsName", fs.Name);
+
+ fs.Description = "fsDescription";
+ Assert.AreEqual("fsDescription", fs.Description);
+ }
+ }
+
+ public class PropertiesTestGeometryPropertyDefinition : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometricPropertyDefinition gpd = new MgGeometricPropertyDefinition("gdpName");
+
+ gpd.GeometryTypes = MgGeometryType.LineString;
+ Assert.AreEqual(MgGeometryType.LineString, gpd.GeometryTypes);
+
+ gpd.ReadOnly = false;
+ Assert.IsFalse(gpd.ReadOnly);
+ gpd.ReadOnly = true;
+ Assert.IsTrue(gpd.ReadOnly);
+
+ gpd.HasElevation = true;
+ Assert.IsTrue(gpd.HasElevation);
+
+ gpd.HasMeasure = true;
+ Assert.IsTrue(gpd.HasMeasure);
+
+ gpd.SpatialContextAssociation = "spatialContextAssociation";
+ Assert.AreEqual("spatialContextAssociation", gpd.SpatialContextAssociation);
+ }
+ }
+
+ public class PropertiesTestGeometryProperty : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ string tmp = Path.GetTempFileName();
+ try
+ {
+ File.WriteAllText(tmp, "Hello World");
+
+ MgByteSource bs = new MgByteSource(tmp);
+ MgByteReader reader = bs.GetReader();
+
+ MgGeometryProperty gp = new MgGeometryProperty("GeomPropName", reader);
+ MgByteSource bs2 = new MgByteSource("../../TestData/DrawingService/SpaceShip.dwf");
+ MgByteReader reader2 = bs2.GetReader();
+
+ gp.Value = reader2;
+ Assert.AreEqual(reader2.GetLength(), gp.Value.GetLength());
+
+ Assert.AreEqual(MgPropertyType.Geometry, gp.PropertyType);
+ }
+ finally
+ {
+ try
+ {
+ File.Delete(tmp);
+ }
+ catch { }
+ }
+ }
+ }
+
+ public class PropertiesTestInsertFeatures : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgPropertyCollection propColl = new MgPropertyCollection();
+ propColl.Add(new MgInt32Property("intProp", 10));
+ MgInsertFeatures inf = new MgInsertFeatures("ClassName", propColl);
+ Assert.AreEqual("ClassName", inf.FeatureClassName);
+ }
+ }
+
+ public class PropertiesTestObjectPropertyDefinition : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgObjectPropertyDefinition opd = new MgObjectPropertyDefinition("odpName");
+ MgClassDefinition classDef = new MgClassDefinition();
+ classDef.Name = "testClassDef";
+
+ opd.ClassDefinition = classDef;
+ Assert.AreEqual(classDef.Name, opd.ClassDefinition.Name);
+
+ opd.ObjectType = MgObjectPropertyType.OrderedCollection;
+ Assert.AreEqual(MgObjectPropertyType.OrderedCollection, opd.ObjectType);
+
+ opd.OrderType = MgOrderingOption.Ascending;
+ Assert.AreEqual(MgOrderingOption.Ascending, opd.OrderType);
+
+ MgDataPropertyDefinition dpd = new MgDataPropertyDefinition("dpdName");
+ opd.IdentityProperty = dpd;
+ Assert.AreEqual(dpd.Name, opd.IdentityProperty.Name);
+ }
+ }
+
+ public class PropertiesTestRasterProperty : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgRasterProperty rp = new MgRasterProperty("RasterPropName", null);
+
+ Assert.AreEqual("RasterPropName", rp.Name);
+ Assert.AreEqual(MgPropertyType.Raster, rp.PropertyType);
+ Assert.IsNull(rp.Value);
+ }
+ }
+
+ public class PropertiesTestRasterPropertyDefinition : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgRasterPropertyDefinition rpd = new MgRasterPropertyDefinition("rasterPropDef");
+
+ rpd.ReadOnly = true;
+ Assert.IsTrue(rpd.ReadOnly);
+
+ rpd.Nullable = true;
+ Assert.IsTrue(rpd.Nullable);
+
+ rpd.DefaultImageXSize = 600;
+ Assert.AreEqual(600, rpd.DefaultImageXSize);
+
+ rpd.DefaultImageYSize = 600;
+ Assert.AreEqual(600, rpd.DefaultImageYSize);
+
+ Assert.AreEqual("rasterPropDef", rpd.Name);
+ }
+ }
+
+ public class PropertiesTestResourceIdentifier : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgResourceIdentifier resId = new MgResourceIdentifier("Library://UnitTests/Data/Shuttle.DrawingSource");
+
+ resId.RepositoryType = MgRepositoryType.Library;
+ Assert.AreEqual(MgRepositoryType.Library, resId.RepositoryType);
+
+ resId.RepositoryName = "resName";
+ Assert.AreEqual("resName", resId.RepositoryName);
+
+ resId.Path = "Data";
+ Assert.AreEqual("Data", resId.Path);
+
+ resId.Name = "Shuttle";
+ Assert.AreEqual("Shuttle", resId.Name);
+
+ resId.ResourceType = MgResourceType.DrawingSource;
+ Assert.AreEqual(MgResourceType.DrawingSource, resId.ResourceType);
+ }
+ }
+
+ public class PropertiesTestUpdateFeatures : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgPropertyCollection propColl = new MgPropertyCollection();
+ propColl.Add(new MgInt32Property("intProp", 10));
+ MgUpdateFeatures uf = new MgUpdateFeatures("ClassName", propColl, "filter");
+ Assert.AreEqual("ClassName", uf.FeatureClassName);
+ Assert.AreEqual("ClassName", uf.FeatureClassName);
+ }
+ }
+
+ public class PropertiesTestCoordinateSystem : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgCoordinateSystemFactory csFactory = new MgCoordinateSystemFactory();
+ MgCoordinateSystem coordSys = csFactory.CreateFromCode("LL84");
+ Assert.AreEqual(MgCoordinateSystemType.Geographic, coordSys.Type);
+ Assert.AreEqual("DEGREE", coordSys.Units);
+ Assert.AreEqual(-180, coordSys.MinX);
+ Assert.AreEqual(-90, coordSys.MinY);
+ Assert.AreEqual(180, coordSys.MaxX);
+ Assert.AreEqual(90, coordSys.MaxY);
+ Assert.AreEqual("LL84", coordSys.CsCode);
+ Assert.AreEqual("WGS84 datum, Latitude-Longitude; Degrees", coordSys.Description);
+ Assert.AreEqual("LL", coordSys.Projection);
+ Assert.AreEqual("Null Projection, produces/processes Latitude & Longitude", coordSys.ProjectionDescription);
+ Assert.AreEqual("WGS84", coordSys.Datum);
+ Assert.AreEqual("World Geodetic System of 1984", coordSys.DatumDescription);
+ Assert.AreEqual("WGS84", coordSys.Ellipsoid);
+ Assert.AreEqual("World Geodetic System of 1984, GEM 10C", coordSys.EllipsoidDescription);
+ }
+ }
+
+ public class PropertiesTestArcSegment : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinateXY start = gf.CreateCoordinateXY(0, 0) as MgCoordinateXY;
+ MgCoordinateXY end = gf.CreateCoordinateXY(10, 10) as MgCoordinateXY;
+ MgCoordinateXY control = gf.CreateCoordinateXY(5, 5) as MgCoordinateXY;
+ MgArcSegment arcSegment = gf.CreateArcSegment(start, end, control);
+
+ Assert.AreEqual(MgGeometryComponentType.ArcSegment, arcSegment.ComponentType);
+ Assert.AreEqual(control.ToString(), arcSegment.ControlCoordinate.ToString());
+ Assert.AreEqual(start.ToString(), arcSegment.StartCoordinate.ToString());
+ Assert.AreEqual(end.ToString(), arcSegment.EndCoordinate.ToString());
+ }
+ }
+
+ public class PropertiesTestCoordinateXY : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinateXY coord = gf.CreateCoordinateXY(100, 100) as MgCoordinateXY;
+ Assert.AreEqual(100, coord.X);
+ Assert.AreEqual(100, coord.Y);
+ MgCoordinate coord2 = coord;
+ Assert.AreEqual(100, coord2.X);
+ Assert.AreEqual(100, coord2.Y);
+ }
+ }
+
+ public class PropertiesTestCoordinateXYM : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinateXYM coord = gf.CreateCoordinateXYM(100, 100, 10) as MgCoordinateXYM;
+ Assert.AreEqual(100, coord.X);
+ Assert.AreEqual(100, coord.Y);
+ Assert.AreEqual(10, coord.M);
+ MgCoordinate coord2 = coord;
+ Assert.AreEqual(100, coord2.X);
+ Assert.AreEqual(100, coord2.Y);
+ Assert.AreEqual(10, coord2.M);
+ }
+ }
+
+ public class PropertiesTestCoordinateXYZ : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinateXYZ coord = gf.CreateCoordinateXYZ(100, 100, 10) as MgCoordinateXYZ;
+ Assert.AreEqual(100, coord.X);
+ Assert.AreEqual(100, coord.Y);
+ Assert.AreEqual(10, coord.Z);
+ MgCoordinate coord2 = coord;
+ Assert.AreEqual(100, coord2.X);
+ Assert.AreEqual(100, coord2.Y);
+ Assert.AreEqual(10, coord2.Z);
+ }
+ }
+
+ public class PropertiesTestCoordinateXYZM : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinateXYZM coord = gf.CreateCoordinateXYZM(100, 100, 10, 5) as MgCoordinateXYZM;
+ Assert.AreEqual(100, coord.X);
+ Assert.AreEqual(100, coord.Y);
+ Assert.AreEqual(10, coord.Z);
+ Assert.AreEqual(5, coord.M);
+ MgCoordinate coord2 = coord;
+ Assert.AreEqual(100, coord2.X);
+ Assert.AreEqual(100, coord2.Y);
+ Assert.AreEqual(10, coord2.Z);
+ Assert.AreEqual(5, coord2.M);
+ }
+ }
+
+ public class PropertiesTestCurvePolygon : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinate pt1 = gf.CreateCoordinateXY(0, 0);
+ MgCoordinate pt2 = gf.CreateCoordinateXY(0, 10);
+ MgCoordinate pt3 = gf.CreateCoordinateXY(10, 10);
+ MgCoordinate pt4 = gf.CreateCoordinateXY(10, 0);
+ MgCoordinateCollection coordinates = new MgCoordinateCollection();
+ coordinates.Add(pt1);
+ coordinates.Add(pt2);
+ coordinates.Add(pt3);
+ coordinates.Add(pt4);
+ MgLinearSegment linearSegment = gf.CreateLinearSegment(coordinates);
+ MgCurveSegmentCollection curveSegments = new MgCurveSegmentCollection();
+ curveSegments.Add(linearSegment);
+ MgCurveRing outerRing = gf.CreateCurveRing(curveSegments);
+ MgCurvePolygon cp = gf.CreateCurvePolygon(outerRing, null);
+
+ Assert.AreEqual(outerRing.ToString(), cp.ExteriorRing.ToString());
+ Assert.AreEqual(0, cp.InteriorRingCount);
+ Assert.AreEqual(MgGeometryType.CurvePolygon, cp.GeometryType);
+ Assert.AreEqual(2, cp.Dimension);
+ }
+ }
+
+ public class PropertiesTestCurveRing : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinate pt1 = gf.CreateCoordinateXY(0, 0);
+ MgCoordinate pt2 = gf.CreateCoordinateXY(0, 10);
+ MgCoordinate pt3 = gf.CreateCoordinateXY(10, 10);
+ MgCoordinate pt4 = gf.CreateCoordinateXY(10, 0);
+ MgCoordinateCollection coordinates = new MgCoordinateCollection();
+ coordinates.Add(pt1);
+ coordinates.Add(pt2);
+ coordinates.Add(pt3);
+ coordinates.Add(pt4);
+ MgLinearSegment linearSegment = gf.CreateLinearSegment(coordinates);
+ MgCurveSegmentCollection curveSegments = new MgCurveSegmentCollection();
+ curveSegments.Add(linearSegment);
+ MgCurveRing outerRing = gf.CreateCurveRing(curveSegments);
+
+ Assert.AreEqual(MgGeometryComponentType.CurveRing, outerRing.ComponentType);
+ Assert.AreEqual(1, outerRing.Count);
+ Assert.AreEqual(2, outerRing.Dimension);
+ }
+ }
+
+ public class PropertiesTestCurveString : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinate pt1 = gf.CreateCoordinateXY(0, 0);
+ MgCoordinate pt2 = gf.CreateCoordinateXY(0, 10);
+ MgCoordinate pt3 = gf.CreateCoordinateXY(10, 10);
+ MgCoordinate pt4 = gf.CreateCoordinateXY(10, 0);
+ MgCoordinateCollection coordinates = new MgCoordinateCollection();
+ coordinates.Add(pt1);
+ coordinates.Add(pt2);
+ coordinates.Add(pt3);
+ coordinates.Add(pt4);
+ MgLinearSegment linearSegment = gf.CreateLinearSegment(coordinates);
+ MgCurveSegmentCollection curveSegments = new MgCurveSegmentCollection();
+ curveSegments.Add(linearSegment);
+ MgCurveString curveString = gf.CreateCurveString(curveSegments);
+
+ Assert.AreEqual(1, curveString.Count);
+ Assert.AreEqual(pt1.ToString(), curveString.StartCoordinate.ToString());
+ Assert.AreEqual(pt4.ToString(), curveString.EndCoordinate.ToString());
+ Assert.AreEqual(MgGeometryType.CurveString, curveString.GeometryType);
+ Assert.AreEqual(1, curveString.Dimension);
+ }
+ }
+
+ public class PropertiesTestEnvelope : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgEnvelope env = new MgEnvelope(-180, -90, 180, 90);
+
+ Assert.AreEqual(-180, env.LowerLeftCoordinate.GetX());
+ Assert.AreEqual(-90, env.LowerLeftCoordinate.GetY());
+ Assert.AreEqual(180, env.UpperRightCoordinate.GetX());
+ Assert.AreEqual(90, env.UpperRightCoordinate.GetY());
+ Assert.AreEqual(360, env.Width);
+ Assert.AreEqual(180, env.Height);
+ Assert.IsNaN(env.Depth);
+ }
+ }
+
+ public class PropertiesTestLinearRing : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinate pt1 = gf.CreateCoordinateXY(0, 0);
+ MgCoordinate pt2 = gf.CreateCoordinateXY(0, 10);
+ MgCoordinate pt3 = gf.CreateCoordinateXY(10, 10);
+ MgCoordinate pt4 = gf.CreateCoordinateXY(10, 0);
+ MgCoordinateCollection coordinates = new MgCoordinateCollection();
+ coordinates.Add(pt1);
+ coordinates.Add(pt2);
+ coordinates.Add(pt3);
+ coordinates.Add(pt4);
+ MgLinearRing linearRing = gf.CreateLinearRing(coordinates);
+
+ Assert.AreEqual(MgGeometryComponentType.LinearRing, linearRing.ComponentType);
+ Assert.AreEqual(2, linearRing.Dimension);
+ }
+ }
+
+ public class PropertiesTestLinearSegment : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinate pt1 = gf.CreateCoordinateXY(0, 0);
+ MgCoordinate pt2 = gf.CreateCoordinateXY(0, 10);
+ MgCoordinate pt3 = gf.CreateCoordinateXY(10, 10);
+ MgCoordinate pt4 = gf.CreateCoordinateXY(10, 0);
+ MgCoordinateCollection coordinates = new MgCoordinateCollection();
+ coordinates.Add(pt1);
+ coordinates.Add(pt2);
+ coordinates.Add(pt3);
+ coordinates.Add(pt4);
+ MgLinearSegment linearSegment = gf.CreateLinearSegment(coordinates);
+
+ Assert.AreEqual(MgGeometryComponentType.LinearSegment, linearSegment.ComponentType);
+ Assert.AreEqual(pt1.ToString(), linearSegment.StartCoordinate.ToString());
+ Assert.AreEqual(pt4.ToString(), linearSegment.EndCoordinate.ToString());
+ Assert.AreEqual(1, linearSegment.Dimension);
+ }
+ }
+
+ public class PropertiesTestLineString : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinate pt1 = gf.CreateCoordinateXY(0, 0);
+ MgCoordinate pt2 = gf.CreateCoordinateXY(0, 10);
+ MgCoordinate pt3 = gf.CreateCoordinateXY(10, 10);
+ MgCoordinate pt4 = gf.CreateCoordinateXY(10, 0);
+ MgCoordinateCollection coordinates = new MgCoordinateCollection();
+ coordinates.Add(pt1);
+ coordinates.Add(pt2);
+ coordinates.Add(pt3);
+ coordinates.Add(pt4);
+ MgLineString linestring = gf.CreateLineString(coordinates);
+
+ Assert.AreEqual(pt1.ToString(), linestring.StartCoordinate.ToString());
+ Assert.AreEqual(pt4.ToString(), linestring.EndCoordinate.ToString());
+ Assert.AreEqual(MgGeometryType.LineString, linestring.GeometryType);
+ Assert.AreEqual(1, linestring.Dimension);
+ }
+ }
+
+ public class PropertiesTestMultiCurvePolygon : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinate pt1 = gf.CreateCoordinateXY(0, 0);
+ MgCoordinate pt2 = gf.CreateCoordinateXY(0, 10);
+ MgCoordinate pt3 = gf.CreateCoordinateXY(10, 10);
+ MgCoordinate pt4 = gf.CreateCoordinateXY(10, 0);
+ MgCoordinateCollection coordinates = new MgCoordinateCollection();
+ coordinates.Add(pt1);
+ coordinates.Add(pt2);
+ coordinates.Add(pt3);
+ coordinates.Add(pt4);
+ MgLinearSegment linearSegment = gf.CreateLinearSegment(coordinates);
+ MgCurveSegmentCollection curveSegments = new MgCurveSegmentCollection();
+ MgCurveRing curveRing = gf.CreateCurveRing(curveSegments);
+ MgCurvePolygon cp = gf.CreateCurvePolygon(curveRing, null);
+ MgCurvePolygonCollection cpc = new MgCurvePolygonCollection();
+ cpc.Add(cp);
+ MgMultiCurvePolygon mcp = gf.CreateMultiCurvePolygon(cpc);
+
+ Assert.AreEqual(1, mcp.Count);
+ Assert.AreEqual(MgGeometryType.MultiCurvePolygon, mcp.GeometryType);
+ Assert.AreEqual(2, mcp.Dimension);
+ }
+ }
+
+ public class PropertiesTestMultiCurveString : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinate pt1 = gf.CreateCoordinateXY(0, 0);
+ MgCoordinate pt2 = gf.CreateCoordinateXY(0, 10);
+ MgCoordinate pt3 = gf.CreateCoordinateXY(10, 10);
+ MgCoordinate pt4 = gf.CreateCoordinateXY(10, 0);
+ MgCoordinateCollection coordinates = new MgCoordinateCollection();
+ coordinates.Add(pt1);
+ coordinates.Add(pt2);
+ coordinates.Add(pt3);
+ coordinates.Add(pt4);
+ MgLinearSegment linearSegment = gf.CreateLinearSegment(coordinates);
+ MgCurveSegmentCollection curveSegments = new MgCurveSegmentCollection();
+ curveSegments.Add(linearSegment);
+ MgCurveString curveString = gf.CreateCurveString(curveSegments);
+ MgCurveStringCollection csc = new MgCurveStringCollection();
+ csc.Add(curveString);
+ MgMultiCurveString mcs = gf.CreateMultiCurveString(csc);
+
+ Assert.AreEqual(1, mcs.Count);
+ Assert.AreEqual(MgGeometryType.MultiCurveString, mcs.GeometryType);
+ Assert.AreEqual(1, mcs.Dimension);
+ }
+ }
+
+ public class PropertiesTestMultiGeometry : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinate pt1 = gf.CreateCoordinateXY(0, 0);
+ MgCoordinate pt2 = gf.CreateCoordinateXY(0, 10);
+ MgCoordinate pt3 = gf.CreateCoordinateXY(10, 10);
+ MgCoordinate pt4 = gf.CreateCoordinateXY(10, 0);
+ MgCoordinateCollection coordinates = new MgCoordinateCollection();
+ coordinates.Add(pt1);
+ coordinates.Add(pt2);
+ coordinates.Add(pt3);
+ coordinates.Add(pt4);
+ MgLineString ls = gf.CreateLineString(coordinates);
+ MgGeometryCollection geometries = new MgGeometryCollection();
+ geometries.Add(ls);
+ MgMultiGeometry mg = gf.CreateMultiGeometry(geometries);
+
+ Assert.AreEqual(1, mg.Count);
+ Assert.AreEqual(MgGeometryType.MultiGeometry, mg.GeometryType);
+ Assert.AreEqual(4, mg.Dimension);
+ }
+ }
+
+ public class PropertiesTestMultiLineString : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinate pt1 = gf.CreateCoordinateXY(0, 0);
+ MgCoordinate pt2 = gf.CreateCoordinateXY(0, 10);
+ MgCoordinate pt3 = gf.CreateCoordinateXY(10, 10);
+ MgCoordinate pt4 = gf.CreateCoordinateXY(10, 0);
+ MgCoordinateCollection coordinates = new MgCoordinateCollection();
+ coordinates.Add(pt1);
+ coordinates.Add(pt2);
+ coordinates.Add(pt3);
+ coordinates.Add(pt4);
+ MgLineString ls = gf.CreateLineString(coordinates);
+ MgLineStringCollection lineStringCollection = new MgLineStringCollection();
+ lineStringCollection.Add(ls);
+ MgMultiLineString mls = gf.CreateMultiLineString(lineStringCollection);
+
+ Assert.AreEqual(1, mls.Count);
+ Assert.AreEqual(MgGeometryType.MultiLineString, mls.GeometryType);
+ Assert.AreEqual(1, mls.Dimension);
+ }
+ }
+
+ public class PropertiesTestMultiPoint : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinate pt1 = gf.CreateCoordinateXY(0, 0);
+ MgCoordinate pt2 = gf.CreateCoordinateXY(0, 10);
+ MgCoordinate pt3 = gf.CreateCoordinateXY(10, 10);
+ MgCoordinate pt4 = gf.CreateCoordinateXY(10, 0);
+ MgPoint mgpt1 = gf.CreatePoint(pt1);
+ MgPoint mgpt2 = gf.CreatePoint(pt2);
+ MgPoint mgpt3 = gf.CreatePoint(pt3);
+ MgPoint mgpt4 = gf.CreatePoint(pt4);
+ MgPointCollection points = new MgPointCollection();
+ points.Add(mgpt1);
+ points.Add(mgpt2);
+ points.Add(mgpt3);
+ points.Add(mgpt4);
+ MgMultiPoint mp = gf.CreateMultiPoint(points);
+
+ Assert.AreEqual(4, mp.Count);
+ Assert.AreEqual(MgGeometryType.MultiPoint, mp.GeometryType);
+ Assert.AreEqual(0, mp.Dimension);
+ }
+ }
+
+ public class PropertiesTestPolygon : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ MgGeometryFactory gf = new MgGeometryFactory();
+ MgCoordinate pt1 = gf.CreateCoordinateXY(0, 0);
+ MgCoordinate pt2 = gf.CreateCoordinateXY(0, 10);
+ MgCoordinate pt3 = gf.CreateCoordinateXY(10, 10);
+ MgCoordinate pt4 = gf.CreateCoordinateXY(10, 0);
+ MgCoordinateCollection coordinates = new MgCoordinateCollection();
+ coordinates.Add(pt1);
+ coordinates.Add(pt2);
+ coordinates.Add(pt3);
+ coordinates.Add(pt4);
+ MgLinearRing linearRing = gf.CreateLinearRing(coordinates);
+ MgPolygon polygon = gf.CreatePolygon(linearRing, null);
+
+ Assert.AreEqual(linearRing.ToString(), polygon.ExteriorRing.ToString());
+ Assert.AreEqual(0, polygon.InteriorRingCount);
+ Assert.AreEqual(MgGeometryType.Polygon, polygon.GeometryType);
+ Assert.AreEqual(2, polygon.Dimension);
+ }
+ }
+}
Modified: sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/TestCommon.csproj
===================================================================
--- sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/TestCommon.csproj 2014-06-23 14:31:00 UTC (rev 8262)
+++ sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/TestCommon.csproj 2014-06-25 15:30:06 UTC (rev 8263)
@@ -72,6 +72,11 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ApiTypes.cs" />
+ <Compile Include="Assert.cs" />
+ <Compile Include="CommonTests.cs" />
+ <Compile Include="ExternalTests\ByteReaderTest.cs" />
+ <Compile Include="ExternalTests\CollectionTests.cs" />
+ <Compile Include="ExternalTests\PropertiesTest.cs" />
<Compile Include="FeatureService\Operations.cs" />
<Compile Include="ITestExecutor.cs" />
<Compile Include="ITestExecutorCollection.cs" />
Added: sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestMapGuideApi/ExternalTests/CollectionTests.cs
===================================================================
--- sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestMapGuideApi/ExternalTests/CollectionTests.cs (rev 0)
+++ sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestMapGuideApi/ExternalTests/CollectionTests.cs 2014-06-25 15:30:06 UTC (rev 8263)
@@ -0,0 +1,59 @@
+using OSGeo.MapGuide.Test.Common;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OSGeo.MapGuide.Test.Web.ExternalTests
+{
+ public class CollectionTestsMapPlotCollection : IExternalTest
+ {
+ public void Execute(IPlatformFactory factory, ITestLogger logger)
+ {
+ string coordsys = "GEOGCS[\"LL84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]";
+ MgEnvelope env = new MgEnvelope(10, 10, 20, 20);
+ MgMap map1 = (MgMap)factory.CreateMap();
+ map1.Create(coordsys, env, "map1");
+
+ MgMap map2 = (MgMap)factory.CreateMap();
+ map2.Create(coordsys, env, "map2");
+
+ MgMap map3 = (MgMap)factory.CreateMap();
+ map3.Create(coordsys, env, "map3");
+
+ MgPlotSpecification spec = new MgPlotSpecification((float)8.0, (float)11.0, "in", (float)0.0, (float)0.0, (float)5.0, (float)5.0);
+ MgResourceIdentifier resId = new MgResourceIdentifier("Library://test.WebLayout");
+ MgLayout layout1 = new MgLayout(resId, "Title1", "in");
+ MgMapPlot plot1 = new MgMapPlot(map1, spec, layout1);
+
+ MgLayout layout2 = new MgLayout(resId, "Title2", "in");
+ MgMapPlot plot2 = new MgMapPlot(map2, spec, layout2);
+
+ MgLayout layout3 = new MgLayout(resId, "Title3", "in");
+ MgMapPlot plot3 = new MgMapPlot(map3, spec, layout3);
+
+ MgMapPlotCollection coll = new MgMapPlotCollection();
+ coll.Add(plot1);
+ coll.Add(plot2);
+ coll.Remove(plot1);
+
+ Assert.AreEqual(1, coll.Count);
+
+ coll.Insert(0, plot1);
+ coll.Insert(2, plot3);
+ MgMapPlot tmp = coll[2];
+ coll[2] = tmp;
+
+ Assert.AreEqual(3, coll.Count);
+
+
+ string txt = "";
+ foreach (MgMapPlot plot in coll)
+ {
+ txt += "[" + plot.GetLayout().GetTitle() + "]";
+ }
+ Assert.AreEqual("[Title1][Title2][Title3]", txt);
+ }
+ }
+}
Added: sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestMapGuideApi/MapGuideTests.cs
===================================================================
--- sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestMapGuideApi/MapGuideTests.cs (rev 0)
+++ sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestMapGuideApi/MapGuideTests.cs 2014-06-25 15:30:06 UTC (rev 8263)
@@ -0,0 +1,49 @@
+using OSGeo.MapGuide.Test.Common;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OSGeo.MapGuide.Test.Web
+{
+ //Defines tests outside of the SQLite-based test suite
+
+ public class MapGuideTests
+ {
+ public static int Execute(IPlatformFactory factory, ITestLogger logger, ref int testsRun)
+ {
+ int failures = 0;
+ var types = typeof(MapGuideTests).Assembly.GetTypes();
+ foreach (var type in types)
+ {
+ if (typeof(IExternalTest).IsAssignableFrom(type) && type.IsClass)
+ {
+ var test = (IExternalTest)Activator.CreateInstance(type);
+ try
+ {
+ logger.WriteLine("****** Executing MapGuide test: " + type.Name + " *********");
+ Console.WriteLine("Executing external MapGuide test: " + type.Name);
+ test.Execute(factory, logger);
+ }
+ catch (AssertException ex)
+ {
+ logger.WriteLine("Assertion failure: " + ex.Message);
+ failures++;
+ }
+ catch (Exception ex)
+ {
+ logger.WriteLine("General failure: " + ex.ToString());
+ failures++;
+ }
+ finally
+ {
+ testsRun++;
+ }
+ }
+ }
+ return failures;
+ }
+ }
+}
Modified: sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestMapGuideApi/TestMapGuideApi.csproj
===================================================================
--- sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestMapGuideApi/TestMapGuideApi.csproj 2014-06-23 14:31:00 UTC (rev 8262)
+++ sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestMapGuideApi/TestMapGuideApi.csproj 2014-06-25 15:30:06 UTC (rev 8263)
@@ -79,6 +79,8 @@
<ItemGroup>
<Compile Include="DrawingService\DrawingServiceOperationExecutor.cs" />
<Compile Include="DrawingService\Operations.cs" />
+ <Compile Include="ExternalTests\CollectionTests.cs" />
+ <Compile Include="MapGuideTests.cs" />
<Compile Include="MappingService\MappingServiceOperationExecutor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="MapGuideTestExecutorCollection.cs" />
More information about the mapguide-commits
mailing list