[mapguide-commits] r8270 - in trunk/MgDev: . UnitTest/Common UnitTest/WebTier/DotNet/MgTestRunner UnitTest/WebTier/DotNet/TestCommon UnitTest/WebTier/DotNet/TestMapGuideApi

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Jun 27 05:11:01 PDT 2014


Author: jng
Date: 2014-06-27 05:11:01 -0700 (Fri, 27 Jun 2014)
New Revision: 8270

Added:
   trunk/MgDev/UnitTest/WebTier/DotNet/TestCommon/Assert.cs
   trunk/MgDev/UnitTest/WebTier/DotNet/TestCommon/CommonTests.cs
   trunk/MgDev/UnitTest/WebTier/DotNet/TestCommon/ExternalTests/
   trunk/MgDev/UnitTest/WebTier/DotNet/TestMapGuideApi/ExternalTests/
   trunk/MgDev/UnitTest/WebTier/DotNet/TestMapGuideApi/MapGuideTests.cs
Removed:
   trunk/MgDev/UnitTest/Common/DotNetWrappers/
Modified:
   trunk/MgDev/
   trunk/MgDev/UnitTest/WebTier/DotNet/MgTestRunner/Program.cs
   trunk/MgDev/UnitTest/WebTier/DotNet/TestCommon/TestCommon.csproj
   trunk/MgDev/UnitTest/WebTier/DotNet/TestMapGuideApi/TestMapGuideApi.csproj
Log:
Merged revision(s) 8263 from sandbox/jng/convenience_apis:
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.
........



Property changes on: trunk/MgDev
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev:6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801,6954-6962,6986-7006
/sandbox/jng/createruntimemap:7486-7555
/sandbox/jng/v30:8212,8214,8217,8220-8221,8223-8225
/sandbox/rfc94:5099-5163
   + /branches/2.4/MgDev:6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801,6954-6962,6986-7006
/sandbox/jng/convenience_apis:8263
/sandbox/jng/createruntimemap:7486-7555
/sandbox/jng/v30:8212,8214,8217,8220-8221,8223-8225
/sandbox/rfc94:5099-5163

Modified: trunk/MgDev/UnitTest/WebTier/DotNet/MgTestRunner/Program.cs
===================================================================
--- trunk/MgDev/UnitTest/WebTier/DotNet/MgTestRunner/Program.cs	2014-06-27 10:57:26 UTC (rev 8269)
+++ trunk/MgDev/UnitTest/WebTier/DotNet/MgTestRunner/Program.cs	2014-06-27 12:11:01 UTC (rev 8270)
@@ -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());

Copied: trunk/MgDev/UnitTest/WebTier/DotNet/TestCommon/Assert.cs (from rev 8263, sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/Assert.cs)
===================================================================
--- trunk/MgDev/UnitTest/WebTier/DotNet/TestCommon/Assert.cs	                        (rev 0)
+++ trunk/MgDev/UnitTest/WebTier/DotNet/TestCommon/Assert.cs	2014-06-27 12:11:01 UTC (rev 8270)
@@ -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");
+        }
+    }
+}

Copied: trunk/MgDev/UnitTest/WebTier/DotNet/TestCommon/CommonTests.cs (from rev 8263, sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestCommon/CommonTests.cs)
===================================================================
--- trunk/MgDev/UnitTest/WebTier/DotNet/TestCommon/CommonTests.cs	                        (rev 0)
+++ trunk/MgDev/UnitTest/WebTier/DotNet/TestCommon/CommonTests.cs	2014-06-27 12:11:01 UTC (rev 8270)
@@ -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;
+        }
+    }
+}

Modified: trunk/MgDev/UnitTest/WebTier/DotNet/TestCommon/TestCommon.csproj
===================================================================
--- trunk/MgDev/UnitTest/WebTier/DotNet/TestCommon/TestCommon.csproj	2014-06-27 10:57:26 UTC (rev 8269)
+++ trunk/MgDev/UnitTest/WebTier/DotNet/TestCommon/TestCommon.csproj	2014-06-27 12:11:01 UTC (rev 8270)
@@ -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" />

Copied: trunk/MgDev/UnitTest/WebTier/DotNet/TestMapGuideApi/MapGuideTests.cs (from rev 8263, sandbox/jng/convenience_apis/UnitTest/WebTier/DotNet/TestMapGuideApi/MapGuideTests.cs)
===================================================================
--- trunk/MgDev/UnitTest/WebTier/DotNet/TestMapGuideApi/MapGuideTests.cs	                        (rev 0)
+++ trunk/MgDev/UnitTest/WebTier/DotNet/TestMapGuideApi/MapGuideTests.cs	2014-06-27 12:11:01 UTC (rev 8270)
@@ -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: trunk/MgDev/UnitTest/WebTier/DotNet/TestMapGuideApi/TestMapGuideApi.csproj
===================================================================
--- trunk/MgDev/UnitTest/WebTier/DotNet/TestMapGuideApi/TestMapGuideApi.csproj	2014-06-27 10:57:26 UTC (rev 8269)
+++ trunk/MgDev/UnitTest/WebTier/DotNet/TestMapGuideApi/TestMapGuideApi.csproj	2014-06-27 12:11:01 UTC (rev 8270)
@@ -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