コード例 #1
0
        public void ParserMarkupEmbeddingStatementTest()
        {
            //Create parser
            StatementParser statementParser = new StatementParser(Init("p p \"left<func1() \"text\">right\";"));
            Statement       parsedStatement = statementParser.ParseMarkupStatement();

            //Test statement
            Assert.AreEqual(typeof(MarkupEmbeddingStatement), parsedStatement.GetType());

            //Test MarkupEmbeddingStatement
            MarkupEmbeddingStatement markupEmbeddingStatement = (MarkupEmbeddingStatement)parsedStatement;

            Assert.AreEqual("p", markupEmbeddingStatement.GetMarkups().Get(0).ToString());
            Assert.AreEqual("p", markupEmbeddingStatement.GetMarkups().Get(1).ToString());

            //Test embedding
            Embedding embedding = markupEmbeddingStatement.GetEmbedding();

            Assert.AreEqual("\"left<", embedding.GetPreText().ToString());
            Assert.AreEqual(typeof(ExpressionEmbed), embedding.GetEmbed().GetType());

            ExpressionEmbed embed = (ExpressionEmbed)embedding.GetEmbed();

            Assert.AreEqual(1, embed.GetMarkups().Count);
            Assert.AreEqual("func1", embed.GetMarkups().Get(0).ToString());
            Assert.AreEqual(typeof(TextExpression), embed.GetExpression().GetType());
            Assert.AreEqual("\"text\"", embed.GetExpression().ToString());

            Assert.AreEqual(typeof(PostTextTail), embedding.GetTextTail().GetType());
            PostTextTail postTextTail = (PostTextTail)embedding.GetTextTail();

            Assert.AreEqual(">right\"", postTextTail.GetPostText().ToString());
        }
コード例 #2
0
        public void ParseMarkupMarkupStatementTest()
        {
            //Create parser
            StatementParser statementParser = new StatementParser(Init("tr td img(src=\"test.png\", width=300);"));
            Statement       parsedStatement = statementParser.ParseMarkupStatement();

            //Test statement
            Assert.AreEqual(typeof(MarkupMarkupStatement), parsedStatement.GetType());

            //Test MarkupMarkupStatement
            MarkupMarkupStatement statement = (MarkupMarkupStatement)parsedStatement;

            List <ISyntaxNode> .Enumerator markupEnumerator = statement.GetMarkups().GetEnumerator();

            //Test TR
            markupEnumerator.MoveNext();
            Assert.AreEqual("tr", ((Markup)markupEnumerator.Current).ToString());

            //Test TD
            markupEnumerator.MoveNext();
            Assert.AreEqual("td", ((Markup)markupEnumerator.Current).ToString());

            //Test IMG
            Assert.AreEqual("img(src=\"test.png\",width=300)", statement.GetMarkup().ToString());
        }
コード例 #3
0
        public void ParseMarkupStatStatementTest()
        {
            //Create parser
            StatementParser statementParser = new StatementParser(Init("p { echo \"test\"; }"));
            Statement       parsedStatement = statementParser.ParseMarkupStatement();

            //Test Statement
            Assert.AreEqual(typeof(MarkupStatStatement), parsedStatement.GetType());

            //Test MarkupStatStatement
            MarkupStatStatement markupStatStatement = (MarkupStatStatement)parsedStatement;

            Assert.AreEqual(1, markupStatStatement.GetMarkups().Count);

            //Test markup
            Markup markup = (Markup)markupStatStatement.GetMarkups().Get(0);

            Assert.AreEqual("p", markup.GetDesignator().GetIdentifier());
            Assert.AreEqual(0, markup.GetArguments().Count);

            //Test statement
            Assert.AreEqual(typeof(BlockStatement), markupStatStatement.GetStatement().GetType());
            BlockStatement statement = (BlockStatement)markupStatStatement.GetStatement();

            Assert.AreEqual(1, statement.GetStatements().Count);

            Statement stmt = (Statement)statement.GetStatements().Get(0);

            Assert.AreEqual(typeof(EchoExpressionStatement), stmt.GetType());
            Assert.AreEqual("echo \"test\";", stmt.ToString());
        }
コード例 #4
0
        public void ParseMarkupStatementTest()
        {
            //Create parser
            StatementParser statementParser = new StatementParser(Init("p();"));
            Statement       parsedStatement = statementParser.ParseMarkupStatement();

            //Test statatement
            Assert.AreEqual(typeof(MarkupStatement), parsedStatement.GetType());

            //Test MarkupStatement
            MarkupStatement statement = (MarkupStatement)parsedStatement;

            Assert.AreEqual("p", statement.GetMarkup().GetDesignator().GetIdentifier());
            Assert.AreEqual(0, statement.GetMarkup().GetArguments().Count);
        }
コード例 #5
0
        public void ParseMarkupExpressionStatementTest()
        {
            //Create parser
            StatementParser statementParser = new StatementParser(Init("tr td p \"test\";"));
            Statement       parsedStatement = statementParser.ParseMarkupStatement();

            //Test statement
            Assert.AreEqual(typeof(MarkupExpressionStatement), parsedStatement.GetType());

            //Test MarkupExpressionStatement
            MarkupExpressionStatement statement = (MarkupExpressionStatement)parsedStatement;

            Assert.AreEqual(typeof(Markup), statement.GetMarkups().Get(0).GetType());
            Assert.AreEqual("tr", statement.GetMarkups().Get(0).ToString());
            Assert.AreEqual(typeof(Markup), statement.GetMarkups().Get(1).GetType());
            Assert.AreEqual("td", statement.GetMarkups().Get(1).ToString());

            Assert.AreEqual(typeof(TextExpression), statement.GetExpression().GetType());
            Assert.AreEqual("\"test\"", statement.GetExpression().ToString());
        }