Exemplo n.º 1
0
        private void TestXmlVariants(string html, string expected, string expectedNoIndent = null)
        {
            expectedNoIndent = expectedNoIndent ?? expected;

            using (var reader = new HtmlReader(html))
            {
                var elem = XDocument.Load(reader);
                Assert.Equal(expected, elem.ToString());
            }

            using (var reader = new HtmlReader(html))
            {
                var list = reader.ToList();
                using (var xml = list.AsXmlReader())
                {
                    var elem = XDocument.Load(xml);
                    Assert.Equal(expected, elem.ToString());
                }
            }

            using (var reader = new HtmlReader(html))
            {
                var doc = new XmlDocument();
                doc.Load(reader);
                Assert.Equal(expectedNoIndent, doc.OuterXml);
            }

            using (var reader = new HtmlReader(html))
            {
                var list = reader.ToList();
                using (var xml = list.AsXmlReader())
                {
                    var doc = new XmlDocument();
                    doc.Load(xml);
                    Assert.Equal(expectedNoIndent, doc.OuterXml);
                }
            }
        }