Exemplo n.º 1
0
        public void UnknownShapeCalculate_WithCorrectArgs_circle()
        {
            AnyShape sh = new AnyShape();

            List <FormulaParameter> params_ = new List <FormulaParameter>()
            {
                new FormulaParameter(5, ParameterTypes.RADIUS)
            };

            Assert.AreEqual(sh.GetArea(params_), 78.5);
        }
Exemplo n.º 2
0
        public void UnknownShapeCalculate_WithIncorrectArgs()
        {
            AnyShape sh = new AnyShape();

            List <FormulaParameter> params_ = new List <FormulaParameter>()
            {
                new FormulaParameter(3, ParameterTypes.SIDE_A)
                , new FormulaParameter(4, ParameterTypes.RADIUS)
            };

            Assert.ThrowsException <InvalidOperationException>(() => sh.GetArea(params_));
        }
Exemplo n.º 3
0
        public void UnknownShapeCalculate_WithCorrectArgs_triangle()
        {
            AnyShape sh = new AnyShape();

            List <FormulaParameter> params_ = new List <FormulaParameter>()
            {
                new FormulaParameter(3, ParameterTypes.SIDE_A)
                , new FormulaParameter(4, ParameterTypes.SIDE_B)
                , new FormulaParameter(6, ParameterTypes.SIDE_C)
            };

            Assert.AreEqual(Math.Round(sh.GetArea(params_), 2), 5.33);
        }
Exemplo n.º 4
0
        public void AnyShapeArea()
        {
            var radius = new CircleParams
            {
                Radius = 4
            };

            var circle = new AnyShape(new Circle(radius));

            var area = circle.GetArea();

            var expectedArea = Math.PI * Math.Pow(radius.Radius, 2);

            Assert.AreEqual(expectedArea, area);
        }
Exemplo n.º 5
0
        public void SquareArea()
        {
            var sides = new SquareParams
            {
                SideA = 5,
                SideB = 5
            };

            var circle = new AnyShape(new Square(sides));

            var area = circle.GetArea();

            var expectedArea = sides.SideA * sides.SideB;

            Assert.AreEqual(expectedArea, area);
        }
Exemplo n.º 6
0
        public void UnknownShapeCalculate_WithCorrectArgs_rectangle()
        {
            AnyShape sh = new AnyShape(new List <Shape>()
            {
                new Rectangle()
            });

            List <FormulaParameter> params_ = new List <FormulaParameter>()
            {
                new FormulaParameter(3, ParameterTypes.SIDE_A)
                , new FormulaParameter(4, ParameterTypes.SIDE_B)
            };

            double s = sh.GetArea(params_);

            Assert.AreEqual(sh.GetArea(params_), 12);
        }