public void CreatePolygon_CorrectVertices_CheckArea() { Vertex[] vertices = new Vertex[] { new Vertex(0, 0), new Vertex(3, 0), new Vertex(3.927, 2.853), new Vertex(1.5, 4.617), new Vertex(-0.927, 2.853), }; RegularPolygon polygon = new RegularPolygon(vertices); double correctArea = 15.484; Assert.IsTrue(Utility.CompareDouble(correctArea, polygon.CalculateArea())); }
public void CalculateArea_WhenCalled_ShouldReturnProperValues() { //creating regular hexagon with the side length of 2 Vertex[] vertices = new Vertex[] { new Vertex(0, 0), new Vertex(2, 0), new Vertex(3, 1.732), new Vertex(2, 3.464), new Vertex(0, 3.464), new Vertex(-1, 1.732) }; RegularPolygon polygon = new RegularPolygon(vertices); Assert.AreEqual(10.39, polygon.CalculateArea(), 0.01); }