Esempio n. 1
0
        public void TestMultiPolygonEqualsHashCode()
        {
            var multiPolygon1 =
                new MultiPolygon(
                    new[]
            {
                new PolygonCoordinates(
                    new[]
                {
                    new LinearRing(
                        new[]
                    {
                        new Position(20, 20), new Position(20, 21), new Position(21, 21),
                        new Position(21, 20), new Position(22, 20)
                    })
                })
            },
                    new GeometryParams
            {
                AdditionalProperties = new Dictionary <string, object> {
                    { "a", "b" }
                },
                BoundingBox = new BoundingBox(new Position(0, 0), new Position(40, 40)),
                Crs         = Crs.Named("SomeCrs")
            });

            var multiPolygon2 =
                new MultiPolygon(
                    new[]
            {
                new PolygonCoordinates(
                    new[]
                {
                    new LinearRing(
                        new[]
                    {
                        new Position(20, 20), new Position(20, 21), new Position(21, 21),
                        new Position(21, 20), new Position(22, 20)
                    })
                })
            },
                    new GeometryParams
            {
                AdditionalProperties = new Dictionary <string, object> {
                    { "a", "b" }
                },
                BoundingBox = new BoundingBox(new Position(0, 0), new Position(40, 40)),
                Crs         = Crs.Named("SomeCrs")
            });

            var polygon3 =
                new MultiPolygon(
                    new[]
            {
                new PolygonCoordinates(
                    new[]
                {
                    new LinearRing(
                        new[]
                    {
                        new Position(20, 21), new Position(20, 21), new Position(21, 21),
                        new Position(21, 20), new Position(22, 20)
                    })
                })
            },
                    new GeometryParams
            {
                AdditionalProperties = new Dictionary <string, object> {
                    { "a", "b" }
                },
                BoundingBox = new BoundingBox(new Position(0, 0), new Position(40, 40)),
                Crs         = Crs.Named("SomeCrs")
            });

            var polygon4 =
                new MultiPolygon(
                    new[]
            {
                new PolygonCoordinates(
                    new[]
                {
                    new LinearRing(
                        new[]
                    {
                        new Position(20, 20), new Position(20, 21), new Position(21, 21),
                        new Position(21, 20), new Position(22, 20)
                    })
                })
            },
                    new GeometryParams
            {
                AdditionalProperties = new Dictionary <string, object> {
                    { "b", "c" }
                },
                BoundingBox = new BoundingBox(new Position(0, 0), new Position(40, 40)),
                Crs         = Crs.Named("SomeCrs")
            });

            var polygon5 =
                new MultiPolygon(
                    new[]
            {
                new PolygonCoordinates(
                    new[]
                {
                    new LinearRing(
                        new[]
                    {
                        new Position(20, 20), new Position(20, 21), new Position(21, 21),
                        new Position(21, 20), new Position(22, 20)
                    })
                })
            },
                    new GeometryParams
            {
                AdditionalProperties = new Dictionary <string, object> {
                    { "a", "b" }
                },
                BoundingBox = new BoundingBox(new Position(0, 0), new Position(40, 41)),
                Crs         = Crs.Named("SomeCrs")
            });

            var polygon6 =
                new MultiPolygon(
                    new[]
            {
                new PolygonCoordinates(
                    new[]
                {
                    new LinearRing(
                        new[]
                    {
                        new Position(20, 20), new Position(20, 21), new Position(21, 21),
                        new Position(21, 20), new Position(22, 20)
                    })
                })
            },
                    new GeometryParams
            {
                AdditionalProperties = new Dictionary <string, object> {
                    { "a", "b" }
                },
                BoundingBox = new BoundingBox(new Position(0, 0), new Position(40, 40)),
                Crs         = Crs.Named("SomeCrs1")
            });

            Assert.AreEqual(multiPolygon1, multiPolygon2);
            Assert.AreEqual(multiPolygon1.GetHashCode(), multiPolygon2.GetHashCode());

            Assert.AreNotEqual(multiPolygon1, polygon3);
            Assert.AreNotEqual(multiPolygon1.GetHashCode(), polygon3.GetHashCode());

            Assert.AreNotEqual(multiPolygon1, polygon4);
            Assert.AreNotEqual(multiPolygon1.GetHashCode(), polygon4.GetHashCode());

            Assert.AreNotEqual(multiPolygon1, polygon5);
            Assert.AreNotEqual(multiPolygon1.GetHashCode(), polygon5.GetHashCode());

            Assert.AreNotEqual(multiPolygon1, polygon6);
            Assert.AreNotEqual(multiPolygon1.GetHashCode(), polygon6.GetHashCode());
        }