// I tried to make this generic and call it for both the Geometry, and Geography base // classes, but then it wouldn't call the correct == and != operators, kept calling the one on Object. private static void GeographyEqualityTestIncludingBaseObviousStuff(Func<Geography> create, Func<Geography> createEmpty) { Geography instance = create(); Assert.False(instance.Equals(null)); Assert.True(instance.Equals(instance)); var instance2 = create(); Assert.True(instance.Equals(instance2)); var empty = createEmpty(); Assert.False(instance.Equals(empty)); Assert.False(empty.Equals(instance)); var empty2 = createEmpty(); Assert.True(empty.Equals(empty2)); Assert.NotEqual(0, instance.GetHashCode()); }
public void SpatialEmptyTypeEquality() { GeographyPoint emptyGeographyPoint1 = TestData.PointGEmpty(); GeographyPoint emptyGeographyPoint2 = TestData.PointGEmpty(); GeographyPoint point = TestData.PointG(); Assert.False(Geography.Equals(emptyGeographyPoint1, point), "empty points must not be equal to non empty points"); Assert.False(Geography.Equals(point, emptyGeographyPoint1), "empty points must not be equal to non empty points"); Assert.True(Geography.Equals(emptyGeographyPoint1, emptyGeographyPoint2), "empty points must be equal"); GeometryPoint emptyGeometryPoint1 = TestData.PointMEmpty(); GeometryPoint emptyGeometryPoint2 = TestData.PointMEmpty(); GeometryPoint GeometryPoint = TestData.PointM(); Assert.False(Geometry.Equals(emptyGeometryPoint1, GeometryPoint), "empty points must not be equal to non empty points"); Assert.False(Geometry.Equals(GeometryPoint, emptyGeometryPoint1), "empty points must not be equal to non empty points"); Assert.True(Geometry.Equals(emptyGeometryPoint1, emptyGeometryPoint2), "empty points must be equal"); }
public void SpatialTypeMismatchEquality() { Assert.False(Geography.Equals(GetGeographyType<GeographyPoint>(), GetGeographyType<GeographyCollection>()), "geography point equality must fail when types are different"); Assert.False(Geography.Equals(GetGeographyType<GeographyLineString>(), GetGeographyType<GeographyCollection>()), "geography line string equality must fail when types are different"); Assert.False(Geography.Equals(GetGeographyType<GeographyMultiLineString>(), GetGeographyType<GeographyCollection>()), "geography multiline string equality must fail when types are different"); Assert.False(Geography.Equals(GetGeographyType<GeographyMultiPoint>(), GetGeographyType<GeographyCollection>()), "geography multipoint equality must fail when types are different"); Assert.False(Geography.Equals(GetGeographyType<GeographyPolygon>(), GetGeographyType<GeographyCollection>()), "geography polygon equality must fail when types are different"); Assert.False(Geography.Equals(GetGeographyType<GeographyMultiPolygon>(), GetGeographyType<GeographyCollection>()), "geography multipolygon equality must fail when types are different"); Assert.False(Geography.Equals(GetGeographyType<GeographyCollection>(), GetGeographyType<GeographyMultiPolygon>()), "geography collection equality must fail when types are different"); Assert.False(Geography.Equals(GetGeographyType<GeographyFullGlobe>(), GetGeographyType<GeographyMultiPolygon>()), "full globe equality must fail when types are different"); Assert.False(Geometry.Equals(GetGeometryType<GeometryPoint>(), GetGeometryType<GeometryCollection>()), "geometry point equality must fail when types are different"); Assert.False(Geometry.Equals(GetGeometryType<GeometryLineString>(), GetGeometryType<GeometryCollection>()), "geometry line string equality must fail when types are different"); Assert.False(Geometry.Equals(GetGeometryType<GeometryMultiLineString>(), GetGeometryType<GeometryCollection>()), "geometry multiline string equality must fail when types are different"); Assert.False(Geometry.Equals(GetGeometryType<GeometryMultiPoint>(), GetGeometryType<GeometryCollection>()), "geometry multipoint equality must fail when types are different"); Assert.False(Geometry.Equals(GetGeometryType<GeometryPolygon>(), GetGeometryType<GeometryCollection>()), "geometry polygon equality must fail when types are different"); Assert.False(Geometry.Equals(GetGeometryType<GeometryMultiPolygon>(), GetGeometryType<GeometryCollection>()), "geometry multipolygon equality must fail when types are different"); Assert.False(Geometry.Equals(GetGeometryType<GeometryCollection>(), GetGeometryType<GeometryMultiPolygon>()), "geometry collection equality must fail when types are different"); }