コード例 #1
0
            public void PentagonDefaultConstructor()
            {
                sut = new Pentagon();

                Assert.That(sut.CalculatePerimeter(), Is.EqualTo(_defaultSize * 5));
                Assert.That(sut.CalculateArea(), Is.EqualTo(GetExpectedAreaForPentagon(_defaultSize)));
            }
コード例 #2
0
            public void SquareDefaultConstructor()
            {
                sut = new Square();

                Assert.That(sut.CalculatePerimeter(), Is.EqualTo(_defaultSize * 4));
                Assert.That(sut.CalculateArea(), Is.EqualTo(Math.Pow(_defaultSize, 2)));
            }
コード例 #3
0
            public void SquareParameterizedConstructor()
            {
                var len = 10;

                sut = new Square(len);

                Assert.That(sut.CalculatePerimeter(), Is.EqualTo(len * 4));
                Assert.That(sut.CalculateArea(), Is.EqualTo(Math.Pow(len, 2)));
            }
コード例 #4
0
            public void PentagonParameterizedConstructor()
            {
                var len = 10;

                sut = new Pentagon(len);

                Assert.That(sut.CalculatePerimeter(), Is.EqualTo(len * 5));
                Assert.That(sut.CalculateArea(), Is.EqualTo(GetExpectedAreaForPentagon(len)));
            }
コード例 #5
0
            public void CircleParameterizedConstructor()
            {
                var radius = 10;

                sut = new Circle(radius);

                Assert.That(sut.CalculatePerimeter(), Is.EqualTo(2 * Math.PI * radius));
                Assert.That(sut.CalculateArea(), Is.EqualTo(Math.PI * Math.Pow(radius, 2)));
            }
コード例 #6
0
            public void RectangleParameterizedConstructor()
            {
                var width  = 10;
                var height = 20;

                sut = new Rectangle(width, height);

                Assert.That(sut.CalculatePerimeter(), Is.EqualTo(2 * width + 2 * height));
                Assert.That(sut.CalculateArea(), Is.EqualTo(width * height));
            }
コード例 #7
0
            public void SquareCopyConstructor()
            {
                var len          = 15;
                var squareToCopy = new Square(len);

                sut = new Square(squareToCopy);

                Assert.That(sut.CalculateArea(), Is.EqualTo(squareToCopy.CalculateArea()));
                Assert.That(sut.CalculatePerimeter(), Is.EqualTo(squareToCopy.CalculatePerimeter()));
            }
コード例 #8
0
            public void PentagonCopyConstructor()
            {
                var len            = 15;
                var PentagonToCopy = new Pentagon(len);

                sut = new Pentagon(PentagonToCopy);

                Assert.That(sut.CalculateArea(), Is.EqualTo(PentagonToCopy.CalculateArea()));
                Assert.That(sut.CalculatePerimeter(), Is.EqualTo(PentagonToCopy.CalculatePerimeter()));
            }
コード例 #9
0
            public void CircleCopyConstructor()
            {
                var radius       = 5;
                var circleToCopy = new Circle(radius);

                sut = new Circle(circleToCopy);

                Assert.That(sut.CalculateArea(), Is.EqualTo(circleToCopy.CalculateArea()));
                Assert.That(sut.CalculatePerimeter(), Is.EqualTo(circleToCopy.CalculatePerimeter()));
            }
コード例 #10
0
            public void RectangleCopyConstructor()
            {
                var width           = 5;
                var height          = 15;
                var rectangleToCopy = new Rectangle(width, height);

                sut = new Rectangle(rectangleToCopy);

                Assert.That(sut.CalculateArea(), Is.EqualTo(rectangleToCopy.CalculateArea()));
                Assert.That(sut.CalculatePerimeter(), Is.EqualTo(rectangleToCopy.CalculatePerimeter()));
            }
コード例 #11
0
            public void EllipseCopyConstructor()
            {
                var semiMajorAxis = 5;
                var semiMinorAxis = 15;
                var EllipseToCopy = new Ellipse(semiMajorAxis, semiMinorAxis);

                sut = new Ellipse(EllipseToCopy);

                Assert.That(sut.CalculateArea(), Is.EqualTo(EllipseToCopy.CalculateArea()));
                Assert.That(sut.CalculatePerimeter(), Is.EqualTo(EllipseToCopy.CalculatePerimeter()));
            }
コード例 #12
0
            public void EllipseParameterizedConstructor()
            {
                var semiMajorAxis = 10;
                var semiMinorAxis = 20;

                sut = new Ellipse(semiMajorAxis, semiMinorAxis);

                Assert.That(sut.CalculatePerimeter(), Is.EqualTo(2 * Math.PI *
                                                                 Math.Sqrt(
                                                                     (Math.Pow(semiMajorAxis, 2) + Math.Pow(semiMinorAxis, 2)) / 2)));
                Assert.That(sut.CalculateArea(), Is.EqualTo(Math.PI * semiMajorAxis * semiMinorAxis));
            }
コード例 #13
0
 public virtual double CalculateShapeArea()
 {
     return(shape.CalculateArea());
 }