Example #1
0
        public void ShouldExtraxctHtmlTags()
        {
            var linkRepo = Substitute.For <ILinksRepo>();
            var webRepo  = Substitute.For <IWebRepo>();
            LinkProcessingService linkProcessingService = new LinkProcessingService(linkRepo, webRepo);
            var          testUrl = "https://en.wikipedia.org/wiki/Mummia";
            HtmlDocument html    = new HtmlDocument
            {
                Text = File.ReadAllText("Resource\\Mummia.html")
            };

            webRepo.DowloandPage(testUrl).Returns(html);

            IEnumerable <string> pagesLinks = new List <string>
            {
                "/wiki/Mumu", "https://ru.wikipedia.org/wiki/Ruru",
                "https://en.wikipedia.org/wiki/Trololo", "/wiki/LoLo"
            };

            webRepo.GetAllTagsFromPage(html).Returns(pagesLinks);

            var testResult = linkProcessingService.ExtraxctHtmlTags(testUrl);

            webRepo.Received(1).DowloandPage(testUrl);
            webRepo.Received(1).GetAllTagsFromPage(html);
            Assert.AreEqual(testResult.Count, 3);
        }