Exemplo n.º 1
0
        public void ParseIfStatementTest()
        {
            //Create parser
            StatementParser statementParser = new StatementParser(Init("if (condition1 || condition2) echo \"test\";"));
            Statement       parsedStatement = statementParser.ParseIfStatement();

            //Check IfStatement
            Assert.AreEqual(typeof(IfStatement), parsedStatement.GetType());

            IfStatement parsedIfStatement = (IfStatement)parsedStatement;

            Assert.AreEqual(typeof(OrPredicate), parsedIfStatement.GetPredicate().GetType());
            Assert.AreEqual("condition1||condition2", parsedIfStatement.GetPredicate().ToString());
            Assert.AreEqual(typeof(EchoExpressionStatement), parsedIfStatement.GetTrueStatement().GetType());
            Assert.AreEqual("echo \"test\";", parsedIfStatement.GetTrueStatement().ToString());
        }