public void ShouldComputeTotalAreaForMixedShapeTypes() { const double expectedResult = 21.5663706143592D; var shapes = new List <Shape> { new Rectangle { Height = 2, Width = 1 }, new Triangle { Height = 3, Base = 2 }, new Square { Lenght = 2 }, new Circle { Radius = 2 } }; _MockShapesRepository.Setup(m => m.GetShapes()).Returns(shapes); var computeAreaService = new ComputeAreaService(_MockShapesRepository.Object); var result = computeAreaService.ComputeTotalArea(); result.Should().BeApproximately(expectedResult, ExpectedPrecision); _MockShapesRepository.VerifyAll(); }
public void ShouldComputeTotalAreaForTriangles() { // Arrange const double expectedResult = 13; var triangles = new List <Shape> { new Triangle { Base = 2, Height = 4 }, new Triangle { Base = 3, Height = 6 } }; _MockShapesRepository.Setup(m => m.GetShapes()).Returns(triangles); var computeAreaService = new ComputeAreaService(_MockShapesRepository.Object); // Act var result = computeAreaService.ComputeTotalArea(); // Assert result.Should().BeApproximately(expectedResult, ExpectedPrecision); _MockShapesRepository.VerifyAll(); }
public void ShouldComputeEmpty() { // Arrange const double expectedResult = 0; IList <IShape> shapes = new List <IShape>(); _MockShapeRepository.Setup(m => m.GetShapes()).Returns(shapes); ComputeAreaService computeAreaService = new ComputeAreaService(_MockShapeRepository.Object); // Act var result = computeAreaService.ComputeTotalArea(); // Assert result.Should().BeApproximately(expectedResult, ExpectedPrecision); _MockShapeRepository.VerifyAll(); }
public void ShouldComputeTotalAreaForSquares() { const double expectedResult = 5; var shapes = new List <Shape> { new Square { Lenght = 2 }, new Square { Lenght = 1 } }; _MockShapesRepository.Setup(m => m.GetShapes()).Returns(shapes); var computeAreaService = new ComputeAreaService(_MockShapesRepository.Object); var result = computeAreaService.ComputeTotalArea(); result.Should().BeApproximately(expectedResult, ExpectedPrecision); _MockShapesRepository.VerifyAll(); }
public void ShouldComputeTotalArea() { // Arrange const double expectedResult = 188.5398; List <Triangle> triangles = GetSampleTriangles(); List <Circle> circles = GetSampleCircles(); List <Rectangle> rectangles = GetSampleRectangles(); List <Square> squares = GetSampleSquares(); _triangleRepository.Setup(m => m.GetAll()).Returns(triangles); _rectangleRepository.Setup(m => m.GetAll()).Returns(rectangles); _circleRepository.Setup(m => m.GetAll()).Returns(circles); _squareRepository.Setup(m => m.GetAll()).Returns(squares); ComputeAreaService computeAreaService = new ComputeAreaService(_repositories); // Act var result = computeAreaService.ComputeTotalArea(); // Assert result.Should().BeApproximately(expectedResult, ExpectedPrecision); }