Esempio n. 1
0
        public void TestSTIsClosed()
        {
            using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString))
            {
                const string Wkt1 = "LINESTRING(0 0, 1 1)";
                db.TestGeometries.Value(g => g.Id, 1).Value(g => g.Geometry, () => GeometryInput.STGeomFromText(Wkt1)).Insert();

                const string Wkt2 = "LINESTRING(0 0, 0 1, 1 1, 0 0)";
                db.TestGeometries.Value(g => g.Id, 2).Value(g => g.Geometry, () => GeometryInput.STGeomFromText(Wkt2)).Insert();
                db.TestGeometries.Value(g => g.Id, 3).Value(g => g.Geometry, () => null).Insert();

                Assert.IsFalse(db.TestGeometries
                               .Where(g => g.Id == 1)
                               .Select(g => g.Geometry.STIsClosed())
                               .Single());
                Assert.IsTrue(db.TestGeometries
                              .Where(g => g.Id == 2)
                              .Select(g => g.Geometry.STIsClosed())
                              .Single());

                Assert.IsFalse(db.Select(() => GeometryAccessors.STIsClosed(Wkt1)));
                Assert.IsTrue(db.Select(() => GeometryAccessors.STIsClosed(Wkt2)));

                Assert.IsNull(db.TestGeometries
                              .Where(g => g.Id == 3)
                              .Select(g => g.Geometry.STIsClosed())
                              .Single());
            }
        }