当前位置: 首页>>代码示例>>C#>>正文


C# HtmlDocument.AssertMatch方法代码示例

本文整理汇总了C#中HtmlAgilityPack.HtmlDocument.AssertMatch方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlDocument.AssertMatch方法的具体用法?C# HtmlDocument.AssertMatch怎么用?C# HtmlDocument.AssertMatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HtmlAgilityPack.HtmlDocument的用法示例。


在下文中一共展示了HtmlDocument.AssertMatch方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MergeHtml_IfFalseValue_BlockIsNotRendered

        public void MergeHtml_IfFalseValue_BlockIsNotRendered()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(@"
                <p>
                    <span>{{ if ShouldSendOffer }}To: {{ Recipient }}{{ end if }}</span>
                </p>
                ");

            var data = new
            {
                Title = "Free Vacation Offer",
                ShouldSendOffer = false,
                Recipient = "Valued Customer",
            };

            IMergeError[] errors;

            Assert.IsTrue(doc.TryMerge(data, out errors));

            doc.AssertMatch(@"
                <p>
                </p>
                ");
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:26,代码来源:HtmlMergeTests.cs

示例2: MergeHtml_EachRegion_MergeRepeatedPerItem

        public void MergeHtml_EachRegion_MergeRepeatedPerItem()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(@"
                <p>
                    <span>{{ each States }}</span>
                    <span>{{ Name }},</span>
                    <span>{{ end each }}</span>
                </p>
                ");

            var data = new
            {
                States = new[] {
                        new {Name = "Wyoming" },
                        new {Name = "Arkansas" },
                        new {Name = "Vermont" }
                    },
            };

            IMergeError[] errors;

            Assert.IsTrue(doc.TryMerge(data, out errors));

            doc.AssertMatch(@"
                <p>
                    <span>Wyoming</span>
                    <span>,</span>
                    <span>Arkansas</span>
                    <span>,</span>
                    <span>Vermont</span>
                    <span>,</span>
                </p>
                ");
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:36,代码来源:HtmlMergeTests.cs

示例3: MergeHtml_ListThatSpanParagraphs_MergeRepeatedPerItem

        //[TestMethod]
        public void MergeHtml_ListThatSpanParagraphs_MergeRepeatedPerItem()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(@"
                <p>
                    <span>{{ each SportsLeagues }}</span>
                </p>
                <p>
                    <span>{{ Acronym }}</span>
                </p>
                <p>
                    <span>{{ end each }}</span>
                </p>
                ");

            var data = new
            {
                SportsLeagues = new[] {
                        new {Acronym = "MLB" },
                        new {Acronym = "NBA" },
                        new {Acronym = "NFL" },
                        new {Acronym = "NHL" },
                        new {Acronym = "MLS" },
                    },
            };

            IMergeError[] errors;

            Assert.IsTrue(doc.TryMerge(data, out errors));

            doc.AssertMatch(@"
                <p>
                    <span>MLB</span>
                </p>
                <p>
                    <span>NBA</span>
                </p>
                <p>
                    <span>NFL</span>
                </p>
                <p>
                    <span>NHL</span>
                </p>
                <p>
                    <span>MLS/span>
                </p>
                ");
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:50,代码来源:HtmlMergeTests.cs

示例4: MergeHtml_ListThatSpanParagraphsNonStandard_MergeRepeatedPerItem

        //[TestMethod]
        public void MergeHtml_ListThatSpanParagraphsNonStandard_MergeRepeatedPerItem()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(@"
                <p>
                    <span>^{{ each TimeZones }}</span>
                </p>
                <p>
                    <span>{{ Name }}{{ end each }}$<span>
                </p>
                ");

            //				<p>
            //					<span><span>
            //				</p>

            var data = new
            {
                TimeZones = new[] {
                        new {Name = "Eastern" },
                        new {Name = "Central" },
                        new {Name = "Mountain West" },
                        new {Name = "Pacific" },
                    },
            };

            IMergeError[] errors;

            Assert.IsTrue(doc.TryMerge(data, out errors));

            doc.AssertMatch(@"^
                            Eastern
                            Central
                            Mountain West
                            Pacific$
                            ");
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:39,代码来源:HtmlMergeTests.cs

示例5: MergeHtml_ListInTable_RowIsRepeatedForEachItem

        //[TestMethod]
        public void MergeHtml_ListInTable_RowIsRepeatedForEachItem()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(@"
                <table>
                    <tr>
                        <th>
                            <span>Item</span>
                        </th>
                        <th>
                            <span>In Stock</span>
                        </th>
                        <th>
                            <span>Price</span>
                        </th>
                    </tr>
                    <tr>
                        <td>
                            <span>{{ each Items }}{{ Name }}</span>
                        </td>
                        <td>
                            <span>{{ InStock }}</span>
                        </td>
                        <td>
                            <span>{{ Price }}{{ end each }}</span>
                        </td>
                    </tr>
                </table>
                ");

            var data = new
            {
                Items = new[] {
                        new {Name = "Milk", InStock = true, Price = 3.50 },
                        new {Name = "Eggs", InStock = true, Price = 2.25 },
                        new {Name = "Artisan Bread", InStock = false, Price = 6.99 }
                    },
            };

            IMergeError[] errors;

            Assert.IsTrue(doc.TryMerge(data, out errors));

            doc.AssertMatch(@"
                <table>
                    <tr>
                        <th>
                            <span>Item</span>
                        </th>
                        <th>
                            <span>In Stock</span>
                        </th>
                        <th>
                            <span>Price</span>
                        </th>
                    </tr>
                    <tr>
                        <td>
                            <span>Milk</span>
                        </td>
                        <td>
                            <span>True</span>
                        </td>
                        <td>
                            <span>3.50</span>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span>Eggs</span>
                        </td>
                        <td>
                            <span>True</span>
                        </td>
                        <td>
                            <span>2.25</span>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span>Artisan Bread</span>
                        </td>
                        <td>
                            <span>False</span>
                        </td>
                        <td>
                            <span>6.99</span>
                        </td>
                    </tr>
                </table>
                ");
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:94,代码来源:HtmlMergeTests.cs

示例6: MergeHtml_ListInTable_RowIsRemovedIfNoItems

        //[TestMethod]
        public void MergeHtml_ListInTable_RowIsRemovedIfNoItems()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(@"
                <table>
                    <tr>
                        <th>
                            <span>Item</span>
                        </th>
                        <th>
                            <span>In Stock</span>
                        </th>
                        <th>
                            <span>Price</span>
                        </th>
                    </tr>
                    <tr>
                        <td>
                            <span>{{ each Items }}{{ Name }}</span>
                        </td>
                        <td>
                            <span>{{ InStock }}</span>
                        </td>
                        <td>
                            <span>{{ Price }}{{ end each }}</span>
                        </td>
                    </tr>
                </table>
                ");

            var data = new
            {
                Items = new object[0],
            };

            IMergeError[] errors;

            Assert.IsTrue(doc.TryMerge(data, out errors));

            doc.AssertMatch(@"
                <table>
                    <tr>
                        <th>
                            <span>Item</span>
                        </th>
                        <th>
                            <span>In Stock</span>
                        </th>
                        <th>
                            <span>Price</span>
                        </th>
                    </tr>
                </table>
                ");
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:57,代码来源:HtmlMergeTests.cs

示例7: MergeHtml_ListInTableWithConditionals_RowRemainsIfOtherContent

        public void MergeHtml_ListInTableWithConditionals_RowRemainsIfOtherContent()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(@"
                <table>
                    <tr>
                        <th>
                            <span>Item</span>
                        </th>
                        <th>
                            <span>In Stock</span>
                        </th>
                    </tr>
                    <tr>
                        <td>
                            <span>{{ if Name }}{{ Name }}{{ end if }}</span>
                        </td>
                        <td>
                            <span>Yes</span>
                        </td>
                    </tr>
                </table>
                ");

            var data = new
            {
                Name = "",
                InStock = "",
            };

            IMergeError[] errors;

            Assert.IsTrue(doc.TryMerge(data, out errors));

            doc.AssertMatch(@"
                <table>
                    <tr>
                        <th>
                            <span>Item</span>
                        </th>
                        <th>
                            <span>In Stock</span>
                        </th>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <span>Yes</span>
                        </td>
                    </tr>
                </table>
                ");
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:55,代码来源:HtmlMergeTests.cs

示例8: MergeHtml_ListInTableWithBlankValues_RowRemains

        public void MergeHtml_ListInTableWithBlankValues_RowRemains()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(@"
                <table>
                    <tr>
                        <th>
                            <span>Item</span>
                        </th>
                        <th>
                            <span>In Stock</span>
                        </th>
                        <th>
                            <span>Price</span>
                        </th>
                    </tr>
                    <tr>
                        <td>
                            <span>{{ each Items }}{{ Name }}</span>
                        </td>
                        <td>
                            <span>{{ InStock }}</span>
                        </td>
                        <td>
                            <span>{{ Price }}{{ end each }}</span>
                        </td>
                    </tr>
                </table>
                ");

            var data = new
            {
                Items = new[]
                {
                    new {Name = "", InStock = "", Price = ""},
                },
            };

            IMergeError[] errors;

            Assert.IsTrue(doc.TryMerge(data, out errors));

            doc.AssertMatch(@"
                <table>
                    <tr>
                        <th>
                            <span>Item</span>
                        </th>
                        <th>
                            <span>In Stock</span>
                        </th>
                        <th>
                            <span>Price</span>
                        </th>
                    </tr>
                    <tr>
                        <td>
                            <span></span>
                        </td>
                        <td>
                            <span></span>
                        </td>
                        <td>
                            <span></span>
                        </td>
                    </tr>
                </table>
                ");
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:70,代码来源:HtmlMergeTests.cs

示例9: MergeHtml_ListInSingleCellTableSameParagraph_RowIsRepeatedForEachItem

        public void MergeHtml_ListInSingleCellTableSameParagraph_RowIsRepeatedForEachItem()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(@"
                <table>
                    <tr>
                        <th>
                            <span>Item</span>
                        </th>
                    </tr>
                    <tr>
                        <td>
                            <span>{{ each Items }}{{ Name }}{{ end each }}</span>
                        </td>
                    </tr>
                </table>
                ");

            var data = new
            {
                Items = new[] {
                        new {Name = "Milk" },
                        new {Name = "Eggs" },
                        new {Name = "Artisan Bread" }
                    },
            };

            IMergeError[] errors;

            Assert.IsTrue(doc.TryMerge(data, out errors));

            doc.AssertMatch(@"
                <table>
                    <tr>
                        <th>
                            <span>Item</span>
                        </th>
                    </tr>
                    <tr>
                        <td>
                            <span>Milk</span>
                            <span>Eggs</span>
                            <span>Artisan Bread</span>
                        </td>
                    </tr>
                </table>
                ");
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:49,代码来源:HtmlMergeTests.cs

示例10: MergeHtml_IfWithMultipleOptions_SatsifyingBlockIsRendered

        public void MergeHtml_IfWithMultipleOptions_SatsifyingBlockIsRendered()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(@"
                <p>
                    <span>^</span>
                </p>
                <p>
                    <span>{{ Title }}</span>
                </p>
                <p>
                    <span>{{ if ShouldSendOffer }}</span>
                </p>
                <p>
                    <span>To: {{ Recipient }}</span>
                </p>
                <p>
                    <span>{{ else if IsUnderReview }}</span>
                </p>
                <p>
                    <span>Status: &lt;UNDER_REVIEW&gt;</span>
                </p>
                <p>
                    <span>{{ else }}</span>
                </p>
                <p>
                    <span>Status: &lt;UNKNOWN&gt;</span>
                </p>
                <p>
                    <span>{{ end if }}</span>
                </p>
                <p>
                    <span>$</span>
                </p>
                ");

            var data = new
            {
                Title = "Free Vacation Offer",
                IsUnderReview = true,
                ShouldSendOffer = false,
            };

            IMergeError[] errors;

            Assert.IsTrue(doc.TryMerge(data, out errors));

            doc.AssertMatch(@"
                <p>
                    <span>^</span>
                </p>
                <p>
                    <span>Free Vacation Offer</span>
                </p>
                <p>
                </p>
                <p>
                </p>
                <p>
                    <span>Status: &lt;UNDER_REVIEW&gt;</span>
                </p>
                <p>
                </p>
                <p>
                </p>
                <p>
                    <span>$</span>
                </p>
                ");
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:71,代码来源:HtmlMergeTests.cs

示例11: MergeHtml_IfWithinList_BlockIsRenderedWhenConditionPasses

        public void MergeHtml_IfWithinList_BlockIsRenderedWhenConditionPasses()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(@"
                <p>
                    <span>{{ each NcaaConferences }}{{ if Active }}{{ Name }}, {{ end if }}{{ end each }}</span>
                </p>
                ");

            var data = new
            {
                NcaaConferences = new[] {
                        new {Name = "PAC 12", Active = true },
                        new {Name = "SEC", Active = true },
                        new {Name = "Big East", Active = false }
                    },
            };

            IMergeError[] errors;

            Assert.IsTrue(doc.TryMerge(data, out errors));

            doc.AssertMatch(@"
                <p>
                    <span>PAC 12</span>
                    <span>, </span>
                    <span>SEC</span>
                    <span>, </span>
                </p>
                ");
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:32,代码来源:HtmlMergeTests.cs

示例12: MergeHtml_IfHasValue_BlockIsRendered

        public void MergeHtml_IfHasValue_BlockIsRendered()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(@"
                <p>
                    <span>{{ if Recipients }}To: {{ each Recipients }}{{ Name }}, {{ end each }} Subject: {{ Title }}{{ end if }}</span>
                </p>
                ");

            var data = new
            {
                Title = "Information About Your Policy",
                Recipients = new[] {
                        new {Name = "Jane Doe" },
                        new {Name = "Jon Doe" },
                    },
            };

            IMergeError[] errors;

            Assert.IsTrue(doc.TryMerge(data, out errors));

            doc.AssertMatch(@"
                <p>
                    <span>To: </span><span>Jane Doe</span><span>, </span><span>Jon Doe</span><span>, </span><span> Subject: </span><span>Information About Your Policy</span>
                </p>
                ");
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:29,代码来源:HtmlMergeTests.cs

示例13: MergeHtml_RootField_NodesReplacedWithValue

        public void MergeHtml_RootField_NodesReplacedWithValue()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(@"
                <p><span>{{ Business }}</span></p>
                ");

            var data = new
            {
                Business = "Dave's Automotive",
            };

            IMergeError[] errors;

            Assert.IsTrue(doc.TryMerge(data, out errors));

            doc.AssertMatch(@"
                <p><span>Dave's Automotive</span></p>
                ");
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:21,代码来源:HtmlMergeTests.cs

示例14: MergeHtml_ListWithEmptyParagraphs_EmptyParagraphsArePreserved

        //[TestMethod]
        public void MergeHtml_ListWithEmptyParagraphs_EmptyParagraphsArePreserved()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(@"
                <p>^</p>
                <p>
                    <span>{{ each CardinalDirections }}</span>
                </p>
                <p></p>
                <p>
                    <span>{{ Symbol }}</span>
                </p>
                <p></p>
                <p>
                    <span>{{ Name }}</span>
                </p>
                <p>
                    <span>{{ end each }}</span>
                </p>
                <p></p>
                <p>$</p>
                ");

            var data = new
            {
                CardinalDirections = new[] {
                        new {Name = "North", Symbol='↑' },
                        new {Name = "South", Symbol='↓' },
                        new {Name = "East", Symbol='→' },
                        new {Name = "West", Symbol='←' },
                    },
            };

            IMergeError[] errors;

            Assert.IsTrue(doc.TryMerge(data, out errors));

            doc.AssertMatch(@"
                <p>^</p>
                <p></p>
                <p>
                    <span>↑</span>
                </p>
                <p></p>
                <p>
                    <span>North</span>
                </p>
                <p></p>
                <p>
                    <span>↓</span>
                </p>
                <p></p>
                <p>
                    <span>South</span>
                </p>
                <p></p>
                <p>
                    <span>→</span>
                </p>
                <p></p>
                <p>
                    <span>East</span>
                </p>
                <p></p>
                <p>
                    <span>←</span>
                </p>
                <p></p>
                <p>
                    <span>West</span>
                </p>
                <p></p>
                <p>$</p>
                ");
        }
开发者ID:vc3,项目名称:ExoMerge,代码行数:77,代码来源:HtmlMergeTests.cs


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