public void EvaluateProveICanSubtractTerms() { // Arrange Evaluate subtraction_exp = new Evaluate(); EvalStack last_values = new EvalStack(); object[] test_expression = { 9, '-', 3 }; // Act double actual = subtraction_exp.EvaluateExpression(test_expression, last_values); double expected = 6; // Assert Assert.AreEqual(expected, actual); }
public void EvaluateProveICanGetModulo() { // Arrange Evaluate modulus_exp = new Evaluate(); EvalStack last_values = new EvalStack(); object[] test_expression = { 10, '%', 3 }; // Act double actual = modulus_exp.EvaluateExpression(test_expression, last_values); double expected = 1; // Assert Assert.AreEqual(expected, actual); }
public void EvaluateProveICanAddTerms() { // Arrange Evaluate addition_exp = new Evaluate(); EvalStack last_values = new EvalStack(); object[] test_expression = { 5, '+', 6 }; // Act double actual = addition_exp.EvaluateExpression(test_expression, last_values); double expected = 11; // Assert Assert.AreEqual(expected, actual); }
public void ExpressionProveICanDoMathWithConst() { // Arrange Expression my_expression = new Expression(); EvalStack eval_stack = new EvalStack(); Evaluate evaluate = new Evaluate(); eval_stack.SetConstant(new object[] { 'M', '=', 8 }); string test_expression = "M * 4"; object[] test_object = my_expression.Parse(test_expression, eval_stack); //Act double actual = evaluate.EvaluateExpression(test_object, eval_stack); double expected = 32; // Assert Assert.AreEqual(actual, expected); }