private double DoCalculation()
    {
        switch (calculation)
        {
        case CalculationType.addition:
            addition.leftOperand  = firstNumber.Evaluate();
            addition.rightOperand = secondNumber.Evaluate();
            return(addition.Evaluate());

        case CalculationType.subtraction:
            subtraction.leftOperand  = firstNumber.Evaluate();
            subtraction.rightOperand = secondNumber.Evaluate();
            return(subtraction.Evaluate());

        case CalculationType.multiplication:
            multiplication.leftOperand  = firstNumber.Evaluate();
            multiplication.rightOperand = secondNumber.Evaluate();
            return(multiplication.Evaluate());

        case CalculationType.division:
            division.leftOperand  = firstNumber.Evaluate();
            division.rightOperand = secondNumber.Evaluate();
            return(division.Evaluate());

        default:
            return(0);
        }
    }
        public void EvaluateWithTwoNormalOperands()
        {
            var left = new Expression { Value = 1 };
            var right = new Expression { Value = 2 };

            var expression = new DivisionExpression(left, right);
            Assert.AreEqual(0.5, expression.Evaluate());
        }
        public void EvaluateWithTwoNormalOperands()
        {
            var left  = new ConstantExpression(1);
            var right = new ConstantExpression(2);

            var expression = new DivisionExpression(left, right);

            Assert.AreEqual(0.5, expression.Evaluate());
        }
        public void EvaluateWithOneMultiplicationExpression()
        {
            var left = new Expression { Value = 1 };
            var leftTwo = new Expression { Value = 2 };
            var rightTwo = new Expression { Value = 4 };
            var right = new DivisionExpression(leftTwo, rightTwo);

            var expression = new DivisionExpression(left, right);
            Assert.AreEqual(2, expression.Evaluate());
        }
        public void EvaluateWithOneMultiplicationExpression()
        {
            var left     = new ConstantExpression(1);
            var leftTwo  = new ConstantExpression(2);
            var rightTwo = new ConstantExpression(4);
            var right    = new DivisionExpression(leftTwo, rightTwo);

            var expression = new DivisionExpression(left, right);

            Assert.AreEqual(2, expression.Evaluate());
        }
        public void EvaluateWithTwoMultiplicationExpressions()
        {
            var leftOne = new Expression { Value = 1 };
            var rightOne = new Expression { Value = 2 };
            var leftTwo = new Expression { Value = 6 };
            var rightTwo = new Expression { Value = 3 };
            var left = new DivisionExpression(leftOne, rightOne);
            var right = new DivisionExpression(leftTwo, rightTwo);

            var expression = new DivisionExpression(left, right);
            Assert.AreEqual(0.25, expression.Evaluate());
        }
        public void EvaluateWithTwoMultiplicationExpressions()
        {
            var leftOne  = new ConstantExpression(1);
            var rightOne = new ConstantExpression(2);
            var leftTwo  = new ConstantExpression(6);
            var rightTwo = new ConstantExpression(3);
            var left     = new DivisionExpression(leftOne, rightOne);
            var right    = new DivisionExpression(leftTwo, rightTwo);

            var expression = new DivisionExpression(left, right);

            Assert.AreEqual(0.25, expression.Evaluate());
        }