public void ThrowsWhenTooFewArgumentsForOperator() { var tokens = new Token[] { new Argument(-3.7), new SumOperator() }; var expression = new RpnExpression(tokens); var result = expression.CalculateResult(); }
public void DisplaysReadableExpressionRepresentation() { var tokens = new Token[] { new Argument(89), new Argument(3.5), new SumOperator() }; var expression = new RpnExpression(tokens); Assert.AreEqual("89 3.5 +", expression.ToString()); }
public void ThrowsIfTooManyTokensInExpression() { var tokens = new Token[] { new Argument(4.5), new Argument(7), new SumOperator(), new Argument(-1) }; var expression = new RpnExpression(tokens); var result = expression.CalculateResult(); }
public void ThrowsIfTokensNull() { var expression = new RpnExpression(null); }
public void ThrowsIfTokensEmpty() { var expression = new RpnExpression(new Token[] { }); }
public void CreatesExpressionWithOneToken() { var expression = new RpnExpression(new Token[] { new Argument(5) }); Assert.IsNotNull(expression); }
public void CreatesExpressionWithManyTokens() { var expression = new RpnExpression(new Token[] { new Argument(1), new Argument(-8.4), new SumOperator() }); }
private void CheckResult(IEnumerable<Token> tokens, double expectedResult) { var expression = new RpnExpression(tokens); Assert.AreEqual(expectedResult, expression.CalculateResult()); }