public void Parse_Sample1_TitleOfLastPost()
        {
            var parser = new HtmlTextParser();
            IEnumerable <Post> posts = parser.Parse(_sampleHtml1);

            Assert.AreEqual("The FAQ of comp.lang.prolog is maintained as a Prolog source file", posts.Last().Title);
        }
        public void Parse_Sample1_CommentsOfFirstPost()
        {
            var parser = new HtmlTextParser();
            IEnumerable <Post> posts = parser.Parse(_sampleHtml1);

            Assert.AreEqual(46u, posts.First().Comments);
        }
        public void Parse_Sample1_RankOfFirstPost()
        {
            var parser = new HtmlTextParser();
            IEnumerable <Post> posts = parser.Parse(_sampleHtml1);

            Assert.AreEqual(1u, posts.First().Rank);
        }
        public void Parse_Sample1_UriOfFirstPost()
        {
            var parser = new HtmlTextParser();
            IEnumerable <Post> posts = parser.Parse(_sampleHtml1);

            Assert.AreEqual("https://chartio.com/blog/why-we-made-sql-visual-and-how-we-finally-did-it/", posts.First().Uri);
        }
        public void Parse_Sample1_AuthorOfFirstPost()
        {
            var parser = new HtmlTextParser();
            IEnumerable <Post> posts = parser.Parse(_sampleHtml1);

            Assert.AreEqual("thingsilearned", posts.First().Author);
        }
        public void Parse_Sample1_IsNotNull()
        {
            var parser = new HtmlTextParser();
            IEnumerable <Post> posts = parser.Parse(_sampleHtml1);

            Assert.IsNotNull(posts);
        }
        public void Parse_Sample1_TitleOfFirstPost()
        {
            var parser = new HtmlTextParser();
            IEnumerable <Post> posts = parser.Parse(_sampleHtml1);

            Assert.AreEqual("Show HN: Visual SQL", posts.First().Title);
        }
        public void Parse_Sample1_PointsOfLastPost()
        {
            var parser = new HtmlTextParser();
            IEnumerable <Post> posts = parser.Parse(_sampleHtml1);

            Assert.AreEqual(105u, posts.Last().Points);
        }
        public void Parse_Sample1_AuthorOfLastPost()
        {
            var parser = new HtmlTextParser();
            IEnumerable <Post> posts = parser.Parse(_sampleHtml1);

            Assert.AreEqual("martinlaz", posts.Last().Author);
        }
        public void Parse_Sample1_UriOfLastPost()
        {
            var parser = new HtmlTextParser();
            IEnumerable <Post> posts = parser.Parse(_sampleHtml1);

            Assert.AreEqual("https://www.metalevel.at/prolog/faq/", posts.Last().Uri);
        }
Пример #11
0
        public IHtmlNode FindBodyOrFirstElement()
        {
            MariGold.HtmlParser.HtmlParser parser = new HtmlTextParser(html)
            {
                UriSchema = uriSchema,
                BaseURL   = baseUrl
            };

            parser.Parse();
            parser.ParseStyles();

            IHtmlNode node = parser.Current;
            IHtmlNode body = null;

            while (node != null)
            {
                body = FindBody(node);

                if (body != null || node.Next == null)
                {
                    break;
                }

                node = node.Next;
            }

            return(body ?? parser.Current);
        }
        public void Parse_Sample1_ContainsThirtyPosts()
        {
            var parser = new HtmlTextParser();
            IEnumerable <Post> posts = parser.Parse(_sampleHtml1);
            var x = posts.ToArray();

            Assert.AreEqual(30, posts.Count());
        }