[mapguide-commits] r7959 - trunk/Tools/Maestro/MaestroAPITests

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Dec 20 07:15:19 PST 2013


Author: jng
Date: 2013-12-20 07:15:19 -0800 (Fri, 20 Dec 2013)
New Revision: 7959

Modified:
   trunk/Tools/Maestro/MaestroAPITests/ConnectionTestBase.cs
   trunk/Tools/Maestro/MaestroAPITests/HttpConnectionTests.cs
   trunk/Tools/Maestro/MaestroAPITests/LocalConnectionTests.cs
   trunk/Tools/Maestro/MaestroAPITests/LocalNativeFeatureTests.cs
   trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs
Log:
#2358: Fix unit test failure

Modified: trunk/Tools/Maestro/MaestroAPITests/ConnectionTestBase.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/ConnectionTestBase.cs	2013-12-20 14:43:19 UTC (rev 7958)
+++ trunk/Tools/Maestro/MaestroAPITests/ConnectionTestBase.cs	2013-12-20 15:15:19 UTC (rev 7959)
@@ -37,6 +37,52 @@
 {
     public abstract class ConnectionTestBase
     {
+        [TestFixtureSetUp]
+        public void TestFixtureSetup()
+        {
+            string reason;
+            if (ShouldIgnore(out reason))
+            {
+                Assert.Ignore(reason);
+            }
+            else
+            {
+                SetupTestData();
+            }
+        }
+
+        protected virtual bool ShouldIgnore(out string reason)
+        {
+            reason = string.Empty;
+            return false;
+        }
+
+        private void SetupTestData()
+        {
+            var conn = CreateTestConnection();
+            var resSvc = conn.ResourceService;
+
+            resSvc.DeleteResource("Library://UnitTests/");
+
+            resSvc.SetResourceXmlData("Library://UnitTests/Maps/Sheboygan.MapDefinition", File.OpenRead("TestData/MappingService/UT_Sheboygan.mdf"));
+            resSvc.SetResourceXmlData("Library://UnitTests/Maps/SheboyganTiled.MapDefinition", File.OpenRead("UserTestData/TestTiledMap.xml"));
+
+            resSvc.SetResourceXmlData("Library://UnitTests/Layers/HydrographicPolygons.LayerDefinition", File.OpenRead("TestData/MappingService/UT_HydrographicPolygons.ldf"));
+            resSvc.SetResourceXmlData("Library://UnitTests/Layers/Rail.LayerDefinition", File.OpenRead("TestData/MappingService/UT_Rail.ldf"));
+            resSvc.SetResourceXmlData("Library://UnitTests/Layers/Parcels.LayerDefinition", File.OpenRead("TestData/TileService/UT_Parcels.ldf"));
+
+            resSvc.SetResourceXmlData("Library://UnitTests/Data/HydrographicPolygons.FeatureSource", File.OpenRead("TestData/MappingService/UT_HydrographicPolygons.fs"));
+            resSvc.SetResourceXmlData("Library://UnitTests/Data/Rail.FeatureSource", File.OpenRead("TestData/MappingService/UT_Rail.fs"));
+            resSvc.SetResourceXmlData("Library://UnitTests/Data/Parcels.FeatureSource", File.OpenRead("TestData/TileService/UT_Parcels.fs"));
+
+            resSvc.SetResourceData("Library://UnitTests/Data/HydrographicPolygons.FeatureSource", "UT_HydrographicPolygons.sdf", ResourceDataType.File, File.OpenRead("TestData/MappingService/UT_HydrographicPolygons.sdf"));
+            resSvc.SetResourceData("Library://UnitTests/Data/Rail.FeatureSource", "UT_Rail.sdf", ResourceDataType.File, File.OpenRead("TestData/MappingService/UT_Rail.sdf"));
+            resSvc.SetResourceData("Library://UnitTests/Data/Parcels.FeatureSource", "UT_Parcels.sdf", ResourceDataType.File, File.OpenRead("TestData/TileService/UT_Parcels.sdf"));
+
+            resSvc.SetResourceXmlData("Library://UnitTests/Data/SpaceShip.DrawingSource", File.OpenRead("TestData/DrawingService/SpaceShipDrawingSource.xml"));
+            resSvc.SetResourceData("Library://UnitTests/Data/SpaceShip.DrawingSource", "SpaceShip.dwf", ResourceDataType.File, File.OpenRead("TestData/DrawingService/SpaceShip.dwf"));
+        }
+
         protected abstract IServerConnection CreateTestConnection();
 
         protected void TestFeatureSourceCaching(string fsName)
@@ -527,7 +573,7 @@
             var resSvc = conn.ResourceService;
             resSvc.SetResourceXmlData("Library://UnitTests/Maps/SheboyganWithInvalidLayers.MapDefinition", File.OpenRead("UserTestData/TestMapWithInvalidLayers.xml"));
             resSvc.SetResourceXmlData("Library://UnitTests/Layers/InvalidLayer.LayerDefinition", File.OpenRead("UserTestData/InvalidLayer.xml"));
-
+            
             if (Array.IndexOf(conn.Capabilities.SupportedServices, (int)ServiceType.Mapping) < 0)
             {
                 Assert.Ignore("Connection does not support the Mapping Service");

Modified: trunk/Tools/Maestro/MaestroAPITests/HttpConnectionTests.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/HttpConnectionTests.cs	2013-12-20 14:43:19 UTC (rev 7958)
+++ trunk/Tools/Maestro/MaestroAPITests/HttpConnectionTests.cs	2013-12-20 15:15:19 UTC (rev 7959)
@@ -34,11 +34,13 @@
     [TestFixture]
     public class HttpConnectionTests : ConnectionTestBase
     {
-        [TestFixtureSetUp]
-        public void Setup()
+        protected override bool ShouldIgnore(out string reason)
         {
+            reason = string.Empty;
             if (TestControl.IgnoreHttpConnectionTests)
-                Assert.Ignore("Skipping HttpConnectionTests because TestControl.IgnoreHttpConnectionTests = true");
+                reason = "Skipping HttpConnectionTests because TestControl.IgnoreHttpConnectionTests = true";
+
+            return TestControl.IgnoreLocalNativeFeatureTests;
         }
 
         //[Test]

Modified: trunk/Tools/Maestro/MaestroAPITests/LocalConnectionTests.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/LocalConnectionTests.cs	2013-12-20 14:43:19 UTC (rev 7958)
+++ trunk/Tools/Maestro/MaestroAPITests/LocalConnectionTests.cs	2013-12-20 15:15:19 UTC (rev 7959)
@@ -38,11 +38,13 @@
     [TestFixture]
     public class LocalConnectionTests : ConnectionTestBase
     {
-        [TestFixtureSetUp]
-        public void Setup()
+        protected override bool ShouldIgnore(out string reason)
         {
+            reason = string.Empty;
             if (TestControl.IgnoreLocalFeatureTests)
-                Assert.Ignore("Skipping LocalConnectionTests because TestControl.IgnoreLocalFeatureTests = true");
+                reason = "Skipping LocalConnectionTests because TestControl.IgnoreLocalFeatureTests = true";
+
+            return TestControl.IgnoreLocalFeatureTests;
         }
 
         protected override IServerConnection CreateTestConnection()

Modified: trunk/Tools/Maestro/MaestroAPITests/LocalNativeFeatureTests.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/LocalNativeFeatureTests.cs	2013-12-20 14:43:19 UTC (rev 7958)
+++ trunk/Tools/Maestro/MaestroAPITests/LocalNativeFeatureTests.cs	2013-12-20 15:15:19 UTC (rev 7959)
@@ -38,11 +38,13 @@
     [TestFixture]
     public class LocalNativeFeatureTests : ConnectionTestBase
     {
-        [TestFixtureSetUp]
-        public void Setup()
+        protected override bool ShouldIgnore(out string reason)
         {
+            reason = string.Empty;
             if (TestControl.IgnoreLocalNativeFeatureTests)
-                Assert.Ignore("Skipping LocalNativeFeatureTests because TestControl.IgnoreLocalNativeFeatureTests = true");
+                reason = "Skipping LocalNativeFeatureTests because TestControl.IgnoreLocalNativeFeatureTests = true";
+
+            return TestControl.IgnoreLocalNativeFeatureTests;
         }
 
         protected override IServerConnection CreateTestConnection()

Modified: trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs	2013-12-20 14:43:19 UTC (rev 7958)
+++ trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs	2013-12-20 15:15:19 UTC (rev 7959)
@@ -89,15 +89,8 @@
             }
             else
             {
-                try
-                {
-                    _conn = CreateTestConnection();
-                    SetupTestData();
-                }
-                catch (Exception)
-                {
-                    throw;
-                }
+                _conn = CreateTestConnection();
+                SetupTestData();
             }
         }
 



More information about the mapguide-commits mailing list