コード例 #1
0
            public async void HomeCrawler_GatherArticles()
            {
                // Arrange
                List <KeyValuePair <string, List <string> > > Sites = new List <KeyValuePair <string, List <string> > >()
                {
                };

                Sites.Add(new KeyValuePair <string, List <string> >("http://hugogarcia.me/site/testing.html", new List <string> {
                    "div", "class", "test", "a", "href", "http://hugogarcia.me/site/", "meta", "name", "keywords", "content", "meta", "property", "og:title", "content", "meta", "name", "description", "content", "Testing"
                }));
                List <string[]> actualLinks = new List <string[]> {
                    new string[] { "http://hugogarcia.me/site/testSite1.html", "http://hugogarcia.me/site/testing.html" },
                    new string[] { "http://www.hugogarcia.me/site/testSite2.html", "http://hugogarcia.me/site/testing.html" },
                    new string[] { "http://hugogarcia.me/site/testSite3.html", "http://hugogarcia.me/site/testing.html" },
                    new string[] { "http://hugogarcia.me/site/testSite4.html", "http://hugogarcia.me/site/testing.html" },
                    new string[] { "http://hugogarcia.me/site/testSite5.html", "http://hugogarcia.me/site/testing.html" }
                };
                HashSet <string> Tags = new HashSet <string> {
                    "hm", "test", "tester"
                };

                BaseCrawler test = new BaseCrawler(Sites, Tags);

                // Act
                var result = await test.GatherArticles(Sites);

                // Assert
                Assert.Equal(actualLinks, result);
            }
コード例 #2
0
            public async void ArticleCrawler_AcceptArticles()
            {
                var tag = new InterestTag
                {
                    TagName         = "Testing",
                    AccountUsername = null,
                    ArticleTags     = null
                };

                var mockInterestRepo = new Mock <IInterestTagRepository>();

                mockInterestRepo.Setup(x => x.Insert(tag));
                List <KeyValuePair <string, List <string> > > Sites = new List <KeyValuePair <string, List <string> > >()
                {
                };

                Sites.Add(new KeyValuePair <string, List <string> >("http://hugogarcia.me/site/testing.html", new List <string> {
                    "div", "class", "test", "a", "href", "http://hugogarcia.me/site/", "meta", "name", "keywords", "content", "meta", "property", "og:title", "content", "meta", "name", "description", "content", "Testing"
                }));
                // KeyValuePair<string, List<string>> siteAttributes = new KeyValuePair<string, List<string>>("http://hugogarcia.me/site/testing.html", new List<string> { "div", "class", "test", "a", "href", "http://hugogarcia.me/site/", "meta", "name", "keywords", "content", "meta", "property", "og:title", "content", "meta", "name", "description", "content", "Testing" });
                HashSet <string> Tags = new HashSet <string> {
                    "hm", "test", "tester"
                };

                BaseCrawler test = new BaseCrawler(Sites, Tags);

                // Act
                var result = await test.GatherArticles(Sites);

                var list = await test.ArticleCrawler(result);

                // Assert
                Assert.Equal(4, list.Count);
            }