public void ComputeArea_ThrowsExceptionIfNumberOfVerticesIsLesserThen3() { Mock<ICoordinateList> listM = new Mock<ICoordinateList>(); listM.SetupGet(l => l.Count).Returns(2); Euclidean2DCalculator target = new Euclidean2DCalculator(); Assert.Throws<ArgumentException>(() => target.CalculateArea(listM.Object)); }
public void ComputeArea_ReturnsAreaOfConvexPolygon() { Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 0.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2) }; double expectedArea = 2.5; Mock<ICoordinateList> listM = new Mock<ICoordinateList>(); listM.SetupGet(list => list.Count).Returns(5); listM.Setup(list => list[0]).Returns(coordinates[0]); listM.Setup(list => list[1]).Returns(coordinates[1]); listM.Setup(list => list[2]).Returns(coordinates[2]); listM.Setup(list => list[3]).Returns(coordinates[3]); listM.Setup(list => list[4]).Returns(coordinates[4]); Euclidean2DCalculator target = new Euclidean2DCalculator(); double area = target.CalculateArea(listM.Object); Assert.Equal(expectedArea, area); }
public void ComputeArea_ReturnsCorrectAreaIfLastCoordinateIsSameAsFirst() { Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 0.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2), new Coordinate(1, 1) }; double expectedArea = 2.5; Mock<ICoordinateList> listM = new Mock<ICoordinateList>(); listM.SetupGet(list => list.Count).Returns(6); listM.Setup(list => list[0]).Returns(coordinates[0]); listM.Setup(list => list[1]).Returns(coordinates[1]); listM.Setup(list => list[2]).Returns(coordinates[2]); listM.Setup(list => list[3]).Returns(coordinates[3]); listM.Setup(list => list[4]).Returns(coordinates[4]); listM.Setup(list => list[5]).Returns(coordinates[5]); Euclidean2DCalculator target = new Euclidean2DCalculator(); double area = target.CalculateArea(listM.Object); Assert.Equal(expectedArea, area); }