[mapserver-commits] r7179 -
trunk/mapserver/mapscript/csharp/examples
svn at osgeo.org
svn at osgeo.org
Mon Dec 17 04:49:46 EST 2007
Author: unicoletti
Date: 2007-12-17 04:49:45 -0500 (Mon, 17 Dec 2007)
New Revision: 7179
Added:
trunk/mapserver/mapscript/csharp/examples/RFC24.cs
Log:
RFC-24, #2442 Adding only RFC24.cs as per Tamas recommendation
Added: trunk/mapserver/mapscript/csharp/examples/RFC24.cs
===================================================================
--- trunk/mapserver/mapscript/csharp/examples/RFC24.cs (rev 0)
+++ trunk/mapserver/mapscript/csharp/examples/RFC24.cs 2007-12-17 09:49:45 UTC (rev 7179)
@@ -0,0 +1,115 @@
+using System;
+using OSGeo.MapServer;
+
+/**
+ * <p>Title: Mapscript RFC24 tests.</p>
+ * <p>Description: Tests for RFC24 implementation. (http://mapserver.gis.umn.edu/development/rfc/ms-rfc-24/)</p>
+ * @author Umberto Nicoletti (umberto.nicoletti at gmail.com)
+ */
+
+class RFC24 {
+ string mapfile;
+
+ public static void Main(string[] args) {
+ new RFC24(args[0]).run();
+ }
+
+ public RFC24(string mapfile) {
+ this.mapfile=mapfile;
+ }
+
+ public void run() {
+ Console.WriteLine("Running RFC24");
+ testLayerObj();
+ testClassObj();
+ testInsertLayerObj();
+ testInsertClassObj();
+ testGetLayerObj();
+ testGetLayerObjByName();
+ testGetClassObj();
+ Console.WriteLine("Finished RFC24");
+ }
+
+ public void testLayerObj() {
+ mapObj map=new mapObj(mapfile);
+ layerObj newLayer=new layerObj(map);
+
+ map=null;
+ gc();
+ assertNotNull(newLayer.map, "testLayerObj");
+ }
+
+ public void testInsertLayerObj() {
+ mapObj map=new mapObj(mapfile);
+ layerObj newLayer=new layerObj(null);
+ map.insertLayer(newLayer,-1);
+
+ map=null;
+ gc();
+ assertNotNull(newLayer.map, "testInsertLayerObj");
+ }
+
+ public void testGetLayerObj() {
+ mapObj map=new mapObj(mapfile);
+ layerObj newLayer=map.getLayer(1);
+
+ map=null;
+ gc();
+ assertNotNull(newLayer.map, "testGetLayerObj");
+ }
+
+ public void testGetLayerObjByName() {
+ mapObj map=new mapObj(mapfile);
+ layerObj newLayer=map.getLayerByName("POLYGON");
+
+ map=null;
+ gc();
+ assertNotNull(newLayer.map, "testGetLayerObjByName");
+ }
+
+ public void testClassObj() {
+ mapObj map=new mapObj(mapfile);
+ layerObj layer=map.getLayer(1);
+ classObj newClass=new classObj(layer);
+
+ map=null; layer=null;
+ gc();
+ assertNotNull(newClass.layer, "testClassObj");
+ }
+
+ public void testInsertClassObj() {
+ mapObj map=new mapObj(mapfile);
+ layerObj layer=map.getLayer(1);
+ classObj newClass=new classObj(null);
+ layer.insertClass(newClass,-1);
+
+ assertNotNull(newClass.layer, "testInsertClassObj precondition");
+ map=null; layer=null;
+ gc();
+ assertNotNull(newClass.layer, "testInsertClassObj");
+ }
+
+ public void testGetClassObj() {
+ mapObj map=new mapObj(mapfile);
+ layerObj layer=map.getLayer(1);
+ classObj newClass=layer.getClass(0);
+
+ map=null; layer=null;
+ gc();
+ assertNotNull(newClass.layer, "testGetClassObj");
+ }
+
+ public void gc() {
+ for (int i=0; i<100; i++) {
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ }
+ }
+
+ public void assertNotNull(object o, string test) {
+ if ( o != null )
+ Console.WriteLine("\t- "+test+" PASSED");
+ else
+ Console.WriteLine("\t- "+test+" FAILED");
+ }
+}
More information about the mapserver-commits
mailing list