Ejemplo n.º 1
0
        public void UrlStringIsNullOrEmpty()
        {
            WebCollector wc         = new WebCollector();
            var          stringnull = Assert.Throws <ArgumentNullException>(
                () => wc.GetHtmlFromUrl(url: null));

            Assert.IsTrue(stringnull.Message.Contains("Cant be null or empty values"));

            var stringempty = Assert.Throws <ArgumentNullException>(
                () => wc.GetHtmlFromUrl(url: String.Empty));

            Assert.IsTrue(stringempty.Message.Contains("Cant be null or empty values"));
        }
Ejemplo n.º 2
0
        public void ValidUrl()
        {
            WebCollector wc  = new WebCollector();
            string       url = "https://www.aftonbladet.se/";

            wc.GetHtmlFromUrl(url);
            Assert.IsTrue(url.Contains("https"));
        }
Ejemplo n.º 3
0
        public void UrlNotContainsHttp()
        {
            WebCollector wc  = new WebCollector();
            string       url = "www.aftonbladet.se";
            var          ex  = Assert.Throws <ArgumentException>(
                () => wc.GetHtmlFromUrl(url));

            Assert.IsTrue(ex.Message.Contains("missing https"));
        }
Ejemplo n.º 4
0
        public void TestKeyWordStringEmptyWebCalculator()
        {
            IWebCalCulator wc  = new WebCalCulator();
            IWebColector   wb  = new WebCollector();
            string         url = "https://www.aftonbladet.se/";

            wb.GetHtmlFromUrl(url);
            var results = wc.CalculateNumberOfHits(wb, keyword: String.Empty);

            Assert.AreEqual(-1, results);
        }