public void PolygonCentroidAlgorithmComputeCentroidTest()
        {
            // specified polygons

            for (Int32 polygonIndex = 0; polygonIndex < _polygons.Count; polygonIndex++)
            {
                Coordinate result = PolygonCentroidAlgorithm.ComputeCentroid(_polygons[polygonIndex]);

                Assert.AreEqual(_expected[polygonIndex].X, _expected[polygonIndex].X, 0.0000001);
                Assert.AreEqual(_expected[polygonIndex].Y, _expected[polygonIndex].Y, 0.0000001);
            }

            // exceptions

            Assert.Throws <ArgumentNullException>(() => PolygonCentroidAlgorithm.ComputeCentroid((IBasicPolygon)null));
            Assert.Throws <ArgumentNullException>(() => PolygonCentroidAlgorithm.ComputeCentroid((IList <Coordinate>)null));
            Assert.Throws <ArgumentNullException>(() => PolygonCentroidAlgorithm.ComputeCentroid((IList <Coordinate>)null, null, PrecisionModel.Default));
        }
Exemple #2
0
        public void PolygonCentroidAlgorithmComputeCentroidTest()
        {
            // specified polygons

            for (Int32 polygonIndex = 0; polygonIndex < this.polygons.Count; polygonIndex++)
            {
                Coordinate result = PolygonCentroidAlgorithm.ComputeCentroid(this.polygons[polygonIndex]);

                result.X.ShouldBe(this.expected[polygonIndex].X, 0.1);
                result.Y.ShouldBe(this.expected[polygonIndex].Y, 0.1);
            }

            // exceptions

            Should.Throw <ArgumentNullException>(() => PolygonCentroidAlgorithm.ComputeCentroid((IBasicPolygon)null));
            Should.Throw <ArgumentNullException>(() => PolygonCentroidAlgorithm.ComputeCentroid((List <Coordinate>)null));
            Should.Throw <ArgumentNullException>(() => PolygonCentroidAlgorithm.ComputeCentroid(null, null));
        }