public void Eval_When_Sum_TwoConstants2and3_MustReturn_5() { // Arrange var sut = new SumExpression(new ConstantExpression(2), new ConstantExpression(3)); // Act var actual = sut.Eval(); // Assert Assert.AreEqual(expected: 5, actual: actual); }
public void Eval_When_Sum_OneVariableAndOneConstants5and3_MustReturn_8() { // Arrange var sut = new SumExpression(new AssignmentExpression( new VariableExpression("P"), new ConstantExpression(5)), new ConstantExpression(3)); var v = new Visitor.Visitor(); sut.Accept(v); // Act var actual = sut.Eval(); // Assert Assert.AreEqual(expected: 8, actual: actual); Assert.AreEqual("(P = 5) + 3", v.ToString()); }