Esempio n. 1
0
        public void TestSTIsCollection()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                db.TestGeometries.Value(g => g.Id, 1).Value(g => g.Geometry, () => GeometryInput.STGeomFromText("LINESTRING(0 0, 1 1)")).Insert();
                db.TestGeometries.Value(g => g.Id, 2).Value(g => g.Geometry, () => GeometryInput.STGeomFromEWKT("MULTIPOINT EMPTY")).Insert();
                db.TestGeometries.Value(g => g.Id, 3).Value(g => g.Geometry, () => GeometryInput.STGeomFromEWKT("MULTIPOINT((0 0))")).Insert();
                db.TestGeometries.Value(g => g.Id, 4).Value(g => g.Geometry, () => GeometryInput.STGeomFromEWKT("MULTIPOINT((0 0), (42 42))")).Insert();
                db.TestGeometries.Value(g => g.Id, 5).Value(g => g.Geometry, () => GeometryInput.STGeomFromEWKT("GEOMETRYCOLLECTION(POINT(0 0))")).Insert();
                db.TestGeometries.Value(g => g.Id, 6).Value(g => g.Geometry, () => null).Insert();

                Assert.IsFalse(db.TestGeometries.Where(g => g.Id == 1).Select(g => g.Geometry.STIsCollection()).Single());
                Assert.IsTrue(db.TestGeometries.Where(g => g.Id == 2).Select(g => g.Geometry.STIsCollection()).Single());
                Assert.IsTrue(db.TestGeometries.Where(g => g.Id == 3).Select(g => g.Geometry.STIsCollection()).Single());
                Assert.IsTrue(db.TestGeometries.Where(g => g.Id == 4).Select(g => g.Geometry.STIsCollection()).Single());
                Assert.IsTrue(db.TestGeometries.Where(g => g.Id == 5).Select(g => g.Geometry.STIsCollection()).Single());
                Assert.IsNull(db.TestGeometries.Where(g => g.Id == 6).Select(g => g.Geometry.STIsCollection()).Single());

                Assert.IsNull(db.Select(() => GeometryAccessors.STIsCollection((NTSG)null)));
                Assert.IsFalse(db.Select(() => GeometryAccessors.STIsCollection("LINESTRING(0 0, 1 1)")));
                Assert.IsTrue(db.Select(() => GeometryAccessors.STIsCollection("MULTIPOINT EMPTY")));
            }
        }