コード例 #1
0
        public void Rewrite_Moves_Whitespace_Preceeding_ExpressionBlock_To_Parent_Block()
        {
            // Arrange
            var factory = new SpanFactory();
            var start   = new MarkupBlock(
                factory.Markup("test"),
                new ExpressionBlock(
                    factory.Code("    ").AsExpression(),
                    factory.CodeTransition(SyntaxConstants.TransitionString),
                    factory.Code("foo").AsExpression()),
                factory.Markup("test"));
            var rewriter = new WhiteSpaceRewriter();

            // Act
            var rewritten = rewriter.Rewrite(start);

            factory.Reset();

            // Assert
            ParserTestBase.EvaluateParseTree(
                rewritten,
                new MarkupBlock(
                    factory.Markup("test"),
                    factory.Markup("    "),
                    new ExpressionBlock(
                        factory.CodeTransition(SyntaxConstants.TransitionString),
                        factory.Code("foo").AsExpression()),
                    factory.Markup("test")));
        }
コード例 #2
0
ファイル: RazorParserTest.cs プロジェクト: yuxi214/Razor
        public void ParseMethodCallsParseDocumentOnMarkupParserAndReturnsResults()
        {
            // Arrange
            var factory = new SpanFactory();
            var parser  = new RazorParser();

            // Act/Assert
            ParserTestBase.EvaluateResults(parser.Parse(TestRazorSourceDocument.Create("foo @bar baz")),
                                           new MarkupBlock(
                                               factory.Markup("foo "),
                                               new ExpressionBlock(
                                                   factory.CodeTransition(),
                                                   factory.Code("bar")
                                                   .AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
                                                   .Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
                                               factory.Markup(" baz")));
        }
コード例 #3
0
        public void ParseMethodUsesProvidedParserListenerIfSpecified()
        {
            // Arrange
            var factory = new SpanFactory();
            var parser  = new RazorParser();

            // Act
            var results = parser.Parse(TestRazorSourceDocument.Create("foo @bar baz"));

            // Assert
            ParserTestBase.EvaluateResults(results,
                                           new MarkupBlock(
                                               factory.Markup("foo "),
                                               new ExpressionBlock(
                                                   factory.CodeTransition(),
                                                   factory.Code("bar")
                                                   .AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
                                                   .Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
                                               factory.Markup(" baz")));
        }
コード例 #4
0
ファイル: HtmlParserTestUtils.cs プロジェクト: yuxi214/Razor
        public static void RunMultiAtEscapeTest(Action <string, Block> testMethod, AcceptedCharactersInternal lastSpanAcceptedCharacters = AcceptedCharactersInternal.None)
        {
            var factory = new SpanFactory();

            testMethod("<foo>@@@@@bar</foo>",
                       new MarkupBlock(
                           new MarkupTagBlock(
                               factory.Markup("<foo>").Accepts(lastSpanAcceptedCharacters)),
                           factory.Markup("@").Hidden(),
                           factory.Markup("@"),
                           factory.Markup("@").Hidden(),
                           factory.Markup("@"),
                           new ExpressionBlock(
                               factory.CodeTransition(),
                               factory.Code("bar")
                               .AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
                               .Accepts(AcceptedCharactersInternal.NonWhiteSpace)),
                           new MarkupTagBlock(
                               factory.Markup("</foo>").Accepts(lastSpanAcceptedCharacters))));
        }