public void ShouldDisplayTheCorrectPostfixNotation(string input, string expectedOutput)
        {
            // ARRANGE
            input = Helper.RemoveWhiteSpace(input: input);
            IShuntingYard sy = new ShuntingYard(input: input);

            sy.ConvertToPostfix();

            // ACT
            string output = Helper.ConvertToString(input: sy.GetPostfix());

            // ASSERT
            Assert.Equal(expectedOutput, output);
        }
        public void ShouldEvaluateTheExpressionCorrectly(string input, double expectedOutput)
        {
            // ARRANGE
            input = Helper.RemoveWhiteSpace(input: input);
            IShuntingYard sy = new ShuntingYard(input: input);

            sy.ConvertToPostfix();

            // ACT
            double output = sy.Evaluate();

            // ASSERT
            Assert.Equal(expectedOutput, output);
        }
示例#3
0
        public PostfixNotation CompileToPostfix(string expression)
        {
            var rawNotation = grammarCompiler.Compile(expression);

            return(shuntingYard.ConvertToPostfix(rawNotation));
        }