コード例 #1
0
        public void NormalGenerateTestTemplate(string html, int expectedCount, List<string> links)
        {
            Assert.IsTrue(links == null || expectedCount == links.Count);

            Uri baseUri = GetBaseUri();
            HttpRequestResult result = new HttpRequestResult()
            {
                Content = html,
                RequestUrl = baseUri,
                ResultUrl = baseUri
            };


            List<HyperLink> hyperlinks = new HtmlParser(result).GenerateHyperLinks();

            Assert.AreEqual(hyperlinks.Count, expectedCount);

            if (links != null)
            {
                for (int i = 0; i < links.Count; i++)
                {
                    Assert.AreEqual(links[i], hyperlinks[i].AbsoluteUri.ToString());
                }
            }
        }
コード例 #2
0
        public void PerformTest()
        {
            var parser = new HtmlParser(new HttpRequestResult() { ResultUrl = ROOT, Content = this.ContentToParse });
            List<Link> links = parser.Parse();

            AssertEqual(this.ExpectedLinks, links);
        }