• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Framework.MarkupBlock类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.AspNet.Razor.Test.Framework.MarkupBlock的典型用法代码示例。如果您正苦于以下问题:C# MarkupBlock类的具体用法?C# MarkupBlock怎么用?C# MarkupBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MarkupBlock类属于Microsoft.AspNet.Razor.Test.Framework命名空间,在下文中一共展示了MarkupBlock类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TreesAreDifferentReturnsFalseIfTreeStructureIsSame

 public void TreesAreDifferentReturnsFalseIfTreeStructureIsSame()
 {
     var factory = SpanFactory.CreateCsHtml();
     Block original = new MarkupBlock(
         factory.Markup("<p>"),
         new ExpressionBlock(
             factory.CodeTransition(),
             factory.Code("f")
                    .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: false)),
         factory.Markup("</p>"));
     factory.Reset();
     Block modified = new MarkupBlock(
         factory.Markup("<p>"),
         new ExpressionBlock(
             factory.CodeTransition(),
             factory.Code("foo")
                    .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: false)),
         factory.Markup("</p>"));
     original.LinkNodes();
     modified.LinkNodes();
     ITextBuffer oldBuffer = new StringTextBuffer("<p>@f</p>");
     ITextBuffer newBuffer = new StringTextBuffer("<p>@foo</p>");
     Assert.False(BackgroundParser.TreesAreDifferent(
         original, modified, new[] {
             new TextChange(position: 5, oldLength: 0, oldBuffer: oldBuffer, newLength: 2, newBuffer: newBuffer)
         }));
 }
开发者ID:KennyBu,项目名称:Razor,代码行数:27,代码来源:RazorEditorParserTest.cs


示例2: Rewrite_Moves_Whitespace_Preceeding_ExpressionBlock_To_Parent_Block

        public void Rewrite_Moves_Whitespace_Preceeding_ExpressionBlock_To_Parent_Block()
        {
            // Arrange
            var factory = SpanFactory.CreateCsHtml();
            Block start = new MarkupBlock(
                factory.Markup("test"),
                new ExpressionBlock(
                    factory.Code("    ").AsExpression(),
                    factory.CodeTransition(SyntaxConstants.TransitionString),
                    factory.Code("foo").AsExpression()
                    ),
                factory.Markup("test")
                );
            WhiteSpaceRewriter rewriter = new WhiteSpaceRewriter(new HtmlMarkupParser().BuildSpan);

            // Act
            Block actual = rewriter.Rewrite(start);

            factory.Reset();

            // Assert
            ParserTestBase.EvaluateParseTree(actual, new MarkupBlock(
                                                         factory.Markup("test"),
                                                         factory.Markup("    "),
                                                         new ExpressionBlock(
                                                             factory.CodeTransition(SyntaxConstants.TransitionString),
                                                             factory.Code("foo").AsExpression()
                                                             ),
                                                         factory.Markup("test")
                                                         ));
        }
开发者ID:hamaky,项目名称:Razor,代码行数:31,代码来源:WhitespaceRewriterTest.cs


示例3: TreesAreDifferentReturnsTrueIfTreeStructureIsDifferent

 public void TreesAreDifferentReturnsTrueIfTreeStructureIsDifferent()
 {
     var factory = SpanFactory.CreateCsHtml();
     var original = new MarkupBlock(
         factory.Markup("<p>"),
         new ExpressionBlock(
             factory.CodeTransition()),
         factory.Markup("</p>"));
     var modified = new MarkupBlock(
         factory.Markup("<p>"),
         new ExpressionBlock(
             factory.CodeTransition("@"),
             factory.Code("f")
                    .AsImplicitExpression(CSharpCodeParser.DefaultKeywords, acceptTrailingDot: false)),
         factory.Markup("</p>"));
     var oldBuffer = new StringTextBuffer("<p>@</p>");
     var newBuffer = new StringTextBuffer("<p>@f</p>");
     Assert.True(BackgroundParser.TreesAreDifferent(
         original,
         modified,
         new[]
         {
             new TextChange(position: 4, oldLength: 0, oldBuffer: oldBuffer, newLength: 1, newBuffer: newBuffer)
         }));
 }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:25,代码来源:RazorEditorParserTest.cs


示例4: TreesAreDifferentReturnsFalseForAddedContent

        public void TreesAreDifferentReturnsFalseForAddedContent(string content)
        {
            // Arrange
            var factory = SpanFactory.CreateCsHtml();
            var blockFactory = new BlockFactory(factory);
            var original = new MarkupBlock(
                blockFactory.MarkupTagBlock("<p>"),
                blockFactory.TagHelperBlock(
                    tagName: "div",
                    tagMode: TagMode.StartTagAndEndTag,
                    start: new SourceLocation(3, 0, 3),
                    startTag: blockFactory.MarkupTagBlock("<div>"),
                    children: new SyntaxTreeNode[]
                    {
                        factory.Markup($"{Environment.NewLine}{Environment.NewLine}")
                    },
                    endTag: blockFactory.MarkupTagBlock("</div>")),
                blockFactory.MarkupTagBlock("</p>"));

            factory.Reset();

            var modified = new MarkupBlock(
                blockFactory.MarkupTagBlock("<p>"),
                blockFactory.TagHelperBlock(
                    tagName: "div",
                    tagMode: TagMode.StartTagAndEndTag,
                    start: new SourceLocation(3, 0, 3),
                    startTag: blockFactory.MarkupTagBlock("<div>"),
                    children: new SyntaxTreeNode[]
                    {
                        factory.Markup($"{Environment.NewLine}{content}{Environment.NewLine}")
                    },
                    endTag: blockFactory.MarkupTagBlock("</div>")),
                blockFactory.MarkupTagBlock("</p>"));
            original.LinkNodes();
            modified.LinkNodes();

            var oldBuffer = new StringTextBuffer($"<p><div>{Environment.NewLine}{Environment.NewLine}</div></p>");
            var newBuffer = new StringTextBuffer(
                $"<p><div>{Environment.NewLine}{content}{Environment.NewLine}</div></p>");

            // Act
            var treesAreDifferent = BackgroundParser.TreesAreDifferent(
                original,
                modified,
                new[]
                {
                    new TextChange(
                        position: 8 + Environment.NewLine.Length,
                        oldLength: 0,
                        oldBuffer: oldBuffer,
                        newLength: content.Length,
                        newBuffer: newBuffer)
                });

            // Assert
            Assert.False(treesAreDifferent);
        }
开发者ID:huoxudong125,项目名称:Razor,代码行数:58,代码来源:RazorEditorParserTest.cs


示例5: RunParseTreeRewriterTest

        public void RunParseTreeRewriterTest(
            string documentContent,
            MarkupBlock expectedOutput,
            IEnumerable<RazorError> errors,
            params string[] tagNames)
        {
            var providerContext = BuildProviderContext(tagNames);

            EvaluateData(providerContext, documentContent, expectedOutput, errors);
        }
开发者ID:rahulchrty,项目名称:Razor,代码行数:10,代码来源:TagHelperRewritingTestBase.cs


示例6: Rewrite_CanHandleInvalidChildrenWithWhitespace

        public void Rewrite_CanHandleInvalidChildrenWithWhitespace()
        {
            // Arrange
            var factory = CreateDefaultSpanFactory();
            var blockFactory = new BlockFactory(factory);
            var documentContent = $"<p>{Environment.NewLine}    <strong>{Environment.NewLine}        Hello" +
                $"{Environment.NewLine}    </strong>{Environment.NewLine}</p>";
            var newLineLength = Environment.NewLine.Length;
            var expectedErrors = new[] {
                new RazorError(
                    RazorResources.FormatTagHelperParseTreeRewriter_InvalidNestedTag("strong", "p", "br"),
                    absoluteIndex: 7 + newLineLength,
                    lineIndex: 1,
                    columnIndex: 9 + newLineLength,
                    length: 8),
                new RazorError(
                    RazorResources.FormatTagHelperParseTreeRewriter_CannotHaveNonTagContent("p", "br"),
                    absoluteIndex: 23 + newLineLength * 2,
                    lineIndex: 2,
                    columnIndex: 23 + newLineLength * 2,
                    length: 5),
                new RazorError(
                    RazorResources.FormatTagHelperParseTreeRewriter_InvalidNestedTag("strong", "p", "br"),
                    absoluteIndex: 32 + newLineLength * 3,
                    lineIndex: 3,
                    columnIndex: 32 + newLineLength * 3,
                    length: 9),
            };
            var expectedOutput = new MarkupBlock(
                new MarkupTagHelperBlock("p",
                    factory.Markup(Environment.NewLine + "    "),
                    blockFactory.MarkupTagBlock("<strong>"),
                    factory.Markup(Environment.NewLine + "        Hello" + Environment.NewLine + "    "),
                    blockFactory.MarkupTagBlock("</strong>"),
                    factory.Markup(Environment.NewLine)));
            var descriptors = new TagHelperDescriptor[]
                {
                    new TagHelperDescriptor
                    {
                        TagName = "p",
                        TypeName = "PTagHelper",
                        AssemblyName = "SomeAssembly",
                        AllowedChildren = new[] { "br" },
                    }
                };
            var descriptorProvider = new TagHelperDescriptorProvider(descriptors);

            // Act & Assert
            EvaluateData(descriptorProvider, documentContent, expectedOutput, expectedErrors);
        }
开发者ID:antiufo,项目名称:Razor,代码行数:50,代码来源:TagHelperParseTreeRewriterTest.cs


示例7: EvaluateData

        public void EvaluateData(
            TagHelperDescriptorProvider provider,
            string documentContent,
            MarkupBlock expectedOutput,
            IEnumerable<RazorError> expectedErrors)
        {
            var errorSink = new ErrorSink();
            var results = ParseDocument(documentContent, errorSink);
            var rewritingContext = new RewritingContext(results.Document, errorSink);
            new TagHelperParseTreeRewriter(provider).Rewrite(rewritingContext);
            var rewritten = rewritingContext.SyntaxTree;
            var actualErrors = errorSink.Errors.OrderBy(error => error.Location.AbsoluteIndex)
                                               .ToList();

            EvaluateRazorErrors(actualErrors, expectedErrors.ToList());
            EvaluateParseTree(rewritten, expectedOutput);
        }
开发者ID:rahulchrty,项目名称:Razor,代码行数:17,代码来源:TagHelperRewritingTestBase.cs


示例8: Rewrite_CanHandleWithoutEndTagTagStructure

        public void Rewrite_CanHandleWithoutEndTagTagStructure(string documentContent, MarkupBlock expectedOutput)
        {
            // Arrange
            var descriptors = new TagHelperDescriptor[]
                {
                    new TagHelperDescriptor
                    {
                        TagName = "input",
                        TypeName = "InputTagHelper",
                        AssemblyName = "SomeAssembly",
                        TagStructure = TagStructure.WithoutEndTag,
                    }
                };
            var descriptorProvider = new TagHelperDescriptorProvider(descriptors);

            // Act & Assert
            EvaluateData(descriptorProvider, documentContent, expectedOutput, expectedErrors: new RazorError[0]);
        }
开发者ID:antiufo,项目名称:Razor,代码行数:18,代码来源:TagHelperBlockRewriterTest.cs


示例9: LocateOwnerReturnsNullIfNoSpanReturnsTrueForOwnsSpan

        public void LocateOwnerReturnsNullIfNoSpanReturnsTrueForOwnsSpan()
        {
            // Arrange
            var factory = SpanFactory.CreateCsHtml();
            var block = new MarkupBlock(
                factory.Markup("Foo "),
                new StatementBlock(
                    factory.CodeTransition(),
                    factory.Code("bar").AsStatement()),
                factory.Markup(" Baz"));
            var change = new TextChange(128, 1, new StringTextBuffer("Foo @bar Baz"), 1, new StringTextBuffer("Foo @bor Baz"));

            // Act
            var actual = block.LocateOwner(change);

            // Assert
            Assert.Null(actual);
        }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:18,代码来源:BlockTest.cs


示例10: TagHelperParseTreeRewriter_RewritesNestedTagHelperTagBlocks

 public void TagHelperParseTreeRewriter_RewritesNestedTagHelperTagBlocks(
     string documentContent,
     MarkupBlock expectedOutput)
 {
     RunParseTreeRewriterTest(documentContent, expectedOutput, "p", "div");
 }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:6,代码来源:TagHelperParseTreeRewriterTest.cs


示例11: TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes

 public void TagHelperParseTreeRewriter_RewritesTagHelpersWithPlainAttributes(
     string documentContent,
     MarkupBlock expectedOutput)
 {
     RunParseTreeRewriterTest(documentContent, expectedOutput, "p");
 }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:6,代码来源:TagHelperParseTreeRewriterTest.cs


示例12: TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers

 public void TagHelperParseTreeRewriter_RewritesSelfClosingTagHelpers(
     string documentContent,
     MarkupBlock expectedOutput)
 {
     RunParseTreeRewriterTest(documentContent, expectedOutput, "p");
 }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:6,代码来源:TagHelperParseTreeRewriterTest.cs


示例13: TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks

 public void TagHelperParseTreeRewriter_RewritesComplexAttributeTagHelperTagBlocks(
     string documentContent,
     MarkupBlock expectedOutput)
 {
     RunParseTreeRewriterTest(documentContent, expectedOutput, "p");
 }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:6,代码来源:TagHelperParseTreeRewriterTest.cs


示例14: Rewrite_AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock

 public void Rewrite_AllowsTagHelperElementOptForIncompleteTextTagInCSharpBlock(
     string documentContent,
     MarkupBlock expectedOutput,
     RazorError[] expectedErrors)
 {
     RunParseTreeRewriterTest(documentContent, expectedOutput, expectedErrors, "text");
 }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:7,代码来源:TagHelperParseTreeRewriterTest.cs


示例15: Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes

 public void Rewrite_CreatesErrorForMalformedTagHelpersWithAttributes(
     string documentContent,
     MarkupBlock expectedOutput,
     RazorError[] expectedErrors)
 {
     RunParseTreeRewriterTest(documentContent, expectedOutput, expectedErrors, "strong", "p");
 }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:7,代码来源:TagHelperParseTreeRewriterTest.cs


示例16: TagHelperParseTreeRewriter_CreatesMarkupCodeSpansForNonStringTagHelperAttributes

        public void TagHelperParseTreeRewriter_CreatesMarkupCodeSpansForNonStringTagHelperAttributes(
            string documentContent,
            MarkupBlock expectedOutput)
        {
            // Arrange
            var descriptors = new TagHelperDescriptor[]
            {
                new TagHelperDescriptor("person", "PersonTagHelper", "personAssembly",
                    attributes: new[]
                    {
                        new TagHelperAttributeDescriptor("age", "Age", typeof(int).FullName, isIndexer: false),
                        new TagHelperAttributeDescriptor(
                            "birthday",
                            "BirthDay",
                            typeof(DateTime).FullName,
                            isIndexer: false),
                        new TagHelperAttributeDescriptor("name", "Name", typeof(string).FullName, isIndexer: false),
                    })
            };
            var providerContext = new TagHelperDescriptorProvider(descriptors);

            // Act & Assert
            EvaluateData(providerContext,
                         documentContent,
                         expectedOutput,
                         expectedErrors: Enumerable.Empty<RazorError>());
        }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:27,代码来源:TagHelperParseTreeRewriterTest.cs


示例17: Rewrite_UnderstandsEmptyAttributeTagHelpers

 public void Rewrite_UnderstandsEmptyAttributeTagHelpers(string documentContent, MarkupBlock expectedOutput)
 {
     RunParseTreeRewriterTest(documentContent, expectedOutput, new RazorError[0], "p");
 }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:4,代码来源:TagHelperParseTreeRewriterTest.cs


示例18: Rewrite_AllowsTagHelperElementOptOutHTML

 public void Rewrite_AllowsTagHelperElementOptOutHTML(
     string documentContent,
     MarkupBlock expectedOutput,
     RazorError[] expectedErrors)
 {
     RunParseTreeRewriterTest(documentContent, expectedOutput, expectedErrors, "strong", "p");
 }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:7,代码来源:TagHelperParseTreeRewriterTest.cs


示例19: Rewrite_AllowsTagHelperElementOptForIncompleteHTML

 public void Rewrite_AllowsTagHelperElementOptForIncompleteHTML(
     string documentContent,
     MarkupBlock expectedOutput)
 {
     RunParseTreeRewriterTest(documentContent, expectedOutput, new RazorError[0], "strong", "p");
 }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:6,代码来源:TagHelperParseTreeRewriterTest.cs


示例20: Rewrite_RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly

        public void Rewrite_RequiredAttributeDescriptorsCreateMalformedTagHelperBlocksCorrectly(
            string documentContent,
            MarkupBlock expectedOutput,
            RazorError[] expectedErrors)
        {
            // Arrange
            var descriptors = new TagHelperDescriptor[]
                {
                    new TagHelperDescriptor(
                        tagName: "p",
                        typeName: "pTagHelper",
                        assemblyName: "SomeAssembly",
                        attributes: new TagHelperAttributeDescriptor[0],
                        requiredAttributes: new[] { "class" })
                };
            var descriptorProvider = new TagHelperDescriptorProvider(descriptors);

            // Act & Assert
            EvaluateData(descriptorProvider, documentContent, expectedOutput, expectedErrors);
        }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:20,代码来源:TagHelperParseTreeRewriterTest.cs



注:本文中的Microsoft.AspNet.Razor.Test.Framework.MarkupBlock类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Text.TextChange类代码示例发布时间:2022-05-26
下一篇:
C# TagHelpers.TagHelperOutput类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap