public void ComputeArea_IPolygon_ReturnsAreaOfSimplePolygonCalculatedByIDimensionsCalculator()
        {
            Polygon polygon = new Polygon(new CoordinateList());
            Random generator = new Random();
            double expectedArea = generator.Next(100);

            Mock<IDimensionsCalculator> calculatorM = new Mock<IDimensionsCalculator>();
            calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(expectedArea);
            Measurements target = new Measurements(calculatorM.Object);

            double area = target.ComputeArea(polygon);

            Assert.Equal(expectedArea, area);
        }
        public void ComputeArea_IPolygon_ReturnsAreaOfSimplePolygonCalculatedByIDimensionsCalculator()
        {
            Polygon polygon      = new Polygon(new CoordinateList());
            Random  generator    = new Random();
            double  expectedArea = generator.Next(100);

            Mock <IDimensionsCalculator> calculatorM = new Mock <IDimensionsCalculator>();

            calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(expectedArea);
            Measurements target = new Measurements(calculatorM.Object);

            double area = target.ComputeArea(polygon);

            Assert.Equal(expectedArea, area);
        }
        public void ComputeArea_IMultiPolygon_ReturnsSumOfPolygonAreas()
        {
            Random generator = new Random();

            Polygon polygon = new Polygon(new CoordinateList());
            double polygonArea = generator.Next(100);
            MultiPolygon multipolygon = new MultiPolygon(new Polygon[] { polygon, polygon });

            Mock<IDimensionsCalculator> calculatorM = new Mock<IDimensionsCalculator>();
            calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(() => polygonArea);

            Measurements target = new Measurements(calculatorM.Object);

            double area = target.ComputeArea(multipolygon);

            Assert.Equal(2 * polygonArea, area);
        }
        public void ComputeArea_IMultiPolygon_ReturnsSumOfPolygonAreas()
        {
            Random generator = new Random();

            Polygon      polygon      = new Polygon(new CoordinateList());
            double       polygonArea  = generator.Next(100);
            MultiPolygon multipolygon = new MultiPolygon(new Polygon[] { polygon, polygon });

            Mock <IDimensionsCalculator> calculatorM = new Mock <IDimensionsCalculator>();

            calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(() => polygonArea);

            Measurements target = new Measurements(calculatorM.Object);

            double area = target.ComputeArea(multipolygon);

            Assert.Equal(2 * polygonArea, area);
        }
        public void ComputeArea_IPolygon_ReturnsAreaOfPolygonWithoutHolesCalculatedByIDimensionsCalculator()
        {
            Random generator = new Random();

            Polygon polygon = new Polygon(new CoordinateList());
            polygon.InteriorRings.Add(new CoordinateList());

            double exteriorArea = generator.Next(100) + 10;
            double interiorArea = generator.Next(10);

            Mock<IDimensionsCalculator> calculatorM = new Mock<IDimensionsCalculator>();
            calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(exteriorArea);
            calculatorM.Setup(calc => calc.CalculateArea(polygon.InteriorRings[0])).Returns(interiorArea);

            Measurements target = new Measurements(calculatorM.Object);

            double area = target.ComputeArea(polygon);

            Assert.Equal(exteriorArea - interiorArea, area);
        }
        public void ComputeArea_IPolygon_ReturnsAreaOfPolygonWithoutHolesCalculatedByIDimensionsCalculator()
        {
            Random generator = new Random();

            Polygon polygon = new Polygon(new CoordinateList());

            polygon.InteriorRings.Add(new CoordinateList());

            double exteriorArea = generator.Next(100) + 10;
            double interiorArea = generator.Next(10);

            Mock <IDimensionsCalculator> calculatorM = new Mock <IDimensionsCalculator>();

            calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(exteriorArea);
            calculatorM.Setup(calc => calc.CalculateArea(polygon.InteriorRings[0])).Returns(interiorArea);

            Measurements target = new Measurements(calculatorM.Object);

            double area = target.ComputeArea(polygon);

            Assert.Equal(exteriorArea - interiorArea, area);
        }