示例#1
0
        public void Test_GetPageLinks()
        {
            string  url         = "https://wiprodigital.com";
            int     maxDepth    = 3;
            Crawler crawler     = new Crawler(url, maxDepth);
            var     html        = crawler.GetPageHtml(url);
            var     actualLinks = CrawlerParser.GetPageLinks(url, html);

            var actualHrefs = actualLinks.Where(x => x.IsWipro && !x.IsJavaScript).Select(x => Utilities.RemoveTrailingSlash(x.Href)).Distinct().ToList();

            actualHrefs.Sort();
            var expectedHrefs = Utilities.GetPageLinksViaAgility(url).Where(x => CrawlerParser.IsWipro(x) && !CrawlerParser.IsJavaScriptOrHashLink(null, x)).Select(x => Utilities.RemoveTrailingSlash(x)).Distinct().ToList();

            expectedHrefs.Sort();


            for (int i = 0; i < expectedHrefs.Count; i++)
            {
                Debug.WriteLine("{0} |exp: {1}\n{0} |act: {2}", i, expectedHrefs[i], actualHrefs[i]);
                if (expectedHrefs[i] != actualHrefs[i])
                {
                }
            }
            Assert.AreEqual(actualHrefs, expectedHrefs);
        }
示例#2
0
        public void Test_ParseTextFromQuote()
        {
            var    inputHtml = @"<a href=""https://wiprodigital.com/cases/delivering-an-exceptional-mortgage-customer-experience-for-allied-irish-bank/"" target=""_self"">";
            string url       = CrawlerParser.ParseTextFromQuote(inputHtml);

            Assert.AreEqual(url, "https://wiprodigital.com/cases/delivering-an-exceptional-mortgage-customer-experience-for-allied-irish-bank/");
        }
示例#3
0
        public void Test_IsRelativeUrl()
        {
            bool trueCase  = CrawlerParser.IsRelativeUrl("/cases/delivering-an-exceptional-mortgage-customer-experience-for-allied-irish-bank/");
            bool falseCase = CrawlerParser.IsRelativeUrl("http://test.wiprodigital.com/cases/delivering-an-exceptional-mortgage-customer-experience-for-allied-irish-bank/");

            Assert.AreEqual(trueCase, true);
            Assert.AreNotEqual(falseCase, true);
        }
示例#4
0
        public void Test_IsJavaScriptOrHashLink()
        {
            bool strHasHash = CrawlerParser.IsJavaScriptOrHashLink("href=\"#AllcontntAggr\"", "#AllcontntAggr");
            bool strHasJS   = CrawlerParser.IsJavaScriptOrHashLink("<a href=\"javascript: void(0)\" id=\"loginlink\">login</a>", "javascript:void(0)");

            Assert.AreEqual(strHasHash, true);
            Assert.AreEqual(strHasJS, true);
        }
示例#5
0
        public void Test_GetAbsoluteUri()
        {
            string case1 = CrawlerParser.GetAbsoluteUri(this.rootUri, "cases/delivering-an-exceptional-mortgage-customer-experience-for-allied-irish-bank/");

            /// bool case2 = CrawlerParser.GetAbsoluteUri("https://wiprodigital.com/cases/delivering-an-exceptional-mortgage-customer-experience-for-allied-irish-bank/");

            Assert.AreEqual(case1, "https://wiprodigital.com/cases/delivering-an-exceptional-mortgage-customer-experience-for-allied-irish-bank/");
            ///   Assert.AreNotEqual(case2, true);
        }
示例#6
0
        public void Test_IsStatic()
        {
            //True cases
            bool trueCase = CrawlerParser.IsStatic("https://s17776.pcdn.co/wp-content/themes/wiprodigital/images/logo.png");

            //False cases
            bool falseCase = CrawlerParser.IsStatic("https://wiprodigital.com/cases/delivering-an-exceptional-mortgage-customer-experience-for-allied-irish-bank/");


            Assert.AreEqual(trueCase, true);
            Assert.AreNotEqual(falseCase, true);
        }