[mapguide-commits] r4893 - sandbox/maestro-2.5/MaestroAPITests

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon May 17 05:29:38 EDT 2010


Author: jng
Date: 2010-05-17 05:29:37 -0400 (Mon, 17 May 2010)
New Revision: 4893

Modified:
   sandbox/maestro-2.5/MaestroAPITests/FeatureReaderTests.cs
Log:
Refine the reader unit tests to test the alternate (IEnumerable) approach and to verify end of stream.

Modified: sandbox/maestro-2.5/MaestroAPITests/FeatureReaderTests.cs
===================================================================
--- sandbox/maestro-2.5/MaestroAPITests/FeatureReaderTests.cs	2010-05-17 08:46:48 UTC (rev 4892)
+++ sandbox/maestro-2.5/MaestroAPITests/FeatureReaderTests.cs	2010-05-17 09:29:37 UTC (rev 4893)
@@ -55,6 +55,35 @@
             Assert.IsFalse(reader.IsDBNull(0));
             Assert.IsTrue(reader.IsDBNull(1));
             Assert.IsTrue(reader.IsDBNull(2));
+
+            Assert.IsFalse(reader.Read()); //end of stream
+
+            //Test the IEnumerable approach
+            reader = new XmlFeatureSetReader(new MemoryStream(bytes));
+
+            int i = 0;
+            foreach (var feat in reader)
+            {
+                switch (i)
+                {
+                    case 0:
+                        Assert.IsFalse(feat.IsDBNull(0));
+                        Assert.IsFalse(feat.IsDBNull(1));
+                        Assert.IsFalse(feat.IsDBNull(2));
+                        break;
+                    case 1:
+                        Assert.IsFalse(feat.IsDBNull(0));
+                        Assert.IsFalse(feat.IsDBNull(1));
+                        Assert.IsTrue(feat.IsDBNull(2));
+                        break;
+                    case 2:
+                        Assert.IsFalse(feat.IsDBNull(0));
+                        Assert.IsTrue(feat.IsDBNull(1));
+                        Assert.IsTrue(feat.IsDBNull(2));
+                        break;
+                }
+                i++;
+            }
         }
 
         [Test]
@@ -81,6 +110,35 @@
             Assert.IsFalse(reader.IsDBNull(0));
             Assert.IsTrue(reader.IsDBNull(1));
             Assert.IsTrue(reader.IsDBNull(2));
+
+            Assert.IsFalse(reader.Read()); //end of stream
+
+            //Test the IEnumerable approach
+            reader = new XmlAggregateSetReader(new MemoryStream(bytes));
+
+            int i = 0;
+            foreach (var feat in reader)
+            {
+                switch (i)
+                {
+                    case 0:
+                        Assert.IsFalse(feat.IsDBNull(0));
+                        Assert.IsFalse(feat.IsDBNull(1));
+                        Assert.IsFalse(feat.IsDBNull(2));
+                        break;
+                    case 1:
+                        Assert.IsFalse(feat.IsDBNull(0));
+                        Assert.IsFalse(feat.IsDBNull(1));
+                        Assert.IsTrue(feat.IsDBNull(2));
+                        break;
+                    case 2:
+                        Assert.IsFalse(feat.IsDBNull(0));
+                        Assert.IsTrue(feat.IsDBNull(1));
+                        Assert.IsTrue(feat.IsDBNull(2));
+                        break;
+                }
+                i++;
+            }
         }
         
         [Test]
@@ -107,6 +165,35 @@
             Assert.IsFalse(reader.IsDBNull(0));
             Assert.IsTrue(reader.IsDBNull(1));
             Assert.IsTrue(reader.IsDBNull(2));
+
+            Assert.IsFalse(reader.Read()); //end of stream
+
+            //Test the IEnumerable approach
+            reader = new XmlSqlResultReader(new MemoryStream(bytes));
+
+            int i = 0;
+            foreach (var feat in reader)
+            {
+                switch (i)
+                {
+                    case 0:
+                        Assert.IsFalse(feat.IsDBNull(0));
+                        Assert.IsFalse(feat.IsDBNull(1));
+                        Assert.IsFalse(feat.IsDBNull(2));
+                        break;
+                    case 1:
+                        Assert.IsFalse(feat.IsDBNull(0));
+                        Assert.IsFalse(feat.IsDBNull(1));
+                        Assert.IsTrue(feat.IsDBNull(2));
+                        break;
+                    case 2:
+                        Assert.IsFalse(feat.IsDBNull(0));
+                        Assert.IsTrue(feat.IsDBNull(1));
+                        Assert.IsTrue(feat.IsDBNull(2));
+                        break;
+                }
+                i++;
+            }
         }
     }
 }



More information about the mapguide-commits mailing list