예제 #1
0
        public void CalculateSurfaceAreas()
        {
            // Arrange
            var triangle = new Triangle(TriangleHeight, TriangleWidth);

            var circle = new Circle(CircleRadius);

            var square = new Square(SquareSide);

            var rectangle = new Rectangle(RectangleHeight, RectangleWidth);

            var trapezoid = new Trapezoid(TrapezoidHeight, TrapezoidUpperWidth, TrapezoidLowerWidth);

            var expectedSurfaceAreas = new List <double>()
            {
                TriangleSurfaceArea, CircleSurfaceArea, SquareSurfaceArea, RectangleSurfaceArea, TrapezoidSurfaceArea
            };

            // Act
            var surfaceAreaCalculator = new ShapeRepository(mockLogger.Object);

            surfaceAreaCalculator.Add(triangle);
            surfaceAreaCalculator.Add(circle);
            surfaceAreaCalculator.Add(square);
            surfaceAreaCalculator.Add(rectangle);
            surfaceAreaCalculator.Add(trapezoid);
            surfaceAreaCalculator.CalculateSurfaceAreas();
            var surfaceAreas = surfaceAreaCalculator.surfaceAreaList;

            // Assert
            Assert.AreEqual(expectedSurfaceAreas[0], surfaceAreas[0]);
            Assert.AreEqual(expectedSurfaceAreas[1], surfaceAreas[1]);
            Assert.AreEqual(expectedSurfaceAreas[2], surfaceAreas[2]);
            Assert.AreEqual(expectedSurfaceAreas[3], surfaceAreas[3]);
        }
예제 #2
0
        public void ShapeRepositoryShouldHaveTwoShapes()
        {
            // Act
            shapeRepository.Add(triangle);
            shapeRepository.Add(circle);

            // Assert
            Assert.AreEqual(shapeRepository.shapeList.Count, 2);
        }
예제 #3
0
 public void AddShape(Shape shape)
 {
     _shapeRepository.Add(shape);
 }