public void EvalStackProveICanGetAndSetConstant() { // Arrange EvalStack my_stack = new EvalStack(); object[] constant_exp = { 'A', '=', 2 }; char constantKey = 'A'; // Act my_stack.SetConstant(constant_exp); int actual = my_stack.GetConstant(constantKey); int expected = 2; // Assert Assert.AreEqual(actual, expected); }
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); }