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)); }
public void DivideTwoIntegers() { IExpression expression = new ArithmeticBinaryExpression(ArithmeticOperation.Divide, new ConstantExpression(3), new ConstantExpression(2)); Assert.AreEqual(3 / 2, expression.Evaluate(null)); }
public void SubtractTwoIntegers() { IExpression expression = new ArithmeticBinaryExpression(ArithmeticOperation.Substract, new ConstantExpression(1), new ConstantExpression(2)); Assert.AreEqual(-1, expression.Evaluate(null)); }
public void MultiplyTwoIntegers() { IExpression expression = new ArithmeticBinaryExpression(ArithmeticOperation.Multiply, new ConstantExpression(3), new ConstantExpression(2)); Assert.AreEqual(6, expression.Evaluate(null)); }
public void AddTwoIntegers() { IExpression expression = new ArithmeticBinaryExpression(ArithmeticOperation.Add, new ConstantExpression(1), new ConstantExpression(2)); Assert.AreEqual(3, expression.Evaluate(null)); }