示例#1
0
        private static object EvaluateArithmeticBinaryOperator(ArithmeticOperator operation, object left, object right)
        {
            IExpression expression = new ArithmeticBinaryExpression(operation, new ConstantExpression(left), new ConstantExpression(right));

            return(expression.Evaluate(null));
        }
示例#2
0
        public void DivideTwoIntegers()
        {
            IExpression expression = new ArithmeticBinaryExpression(ArithmeticOperation.Divide, new ConstantExpression(3), new ConstantExpression(2));

            Assert.AreEqual(3 / 2, expression.Evaluate(null));
        }
示例#3
0
        public void SubtractTwoIntegers()
        {
            IExpression expression = new ArithmeticBinaryExpression(ArithmeticOperation.Substract, new ConstantExpression(1), new ConstantExpression(2));

            Assert.AreEqual(-1, expression.Evaluate(null));
        }
示例#4
0
        public void MultiplyTwoIntegers()
        {
            IExpression expression = new ArithmeticBinaryExpression(ArithmeticOperation.Multiply, new ConstantExpression(3), new ConstantExpression(2));

            Assert.AreEqual(6, expression.Evaluate(null));
        }
示例#5
0
        public void AddTwoIntegers()
        {
            IExpression expression = new ArithmeticBinaryExpression(ArithmeticOperation.Add, new ConstantExpression(1), new ConstantExpression(2));

            Assert.AreEqual(3, expression.Evaluate(null));
        }