public void Postfix_ForGivenQuery_ReturnsExpectedValues(string query, string expectedPostfix)
        {
            var parser          = new PostfixParser();
            var postfixedResult = parser.Parse(query);
            var actualPostfix   = string.Join(string.Empty, postfixedResult.Select(x => x.Value).ToArray());

            Assert.Equal(expectedPostfix, actualPostfix);
        }
        public void Postfix_ForNullValue_ThrowsArgumentNullException()
        {
            string query  = null;
            var    parser = new PostfixParser();

            var ex = Record.Exception(() => parser.Parse(query));

            Assert.NotNull(ex);
            Assert.IsType <ArgumentNullException>(ex);
        }
Exemple #3
0
        public void SimpleEquationTest()
        {
            var parser = new PostfixParser();

            string result = parser.Parse(new[]{
                    new Token(TokenType.Digit, 9),
                    new Token(TokenType.Minus),
                    new Token(TokenType.Digit, 5),
                    new Token(TokenType.Plus),
                    new Token(TokenType.Digit, 2),
                });

            Assert.AreEqual("95-2+", result);
        }