コード例 #1
0
        // Test for no http:// in URL.
        public void UrlNoHttpTest()
        {
            IWebCollector collector = new WebCollector();
            string        url       = "aftonbladet.se";

            collector.GetHTMLFromUrl(url);

            Assert.AreEqual(string.Empty, collector.HtmlCode);
        }
コード例 #2
0
        public async Task GetHTMLFromUrlTestValidURL()
        {
            var wc = new WebCollector();
            await wc.GetHTMLFromUrl("https://www.aftonbladet.se/");

            var result = wc.HtmlCode;

            Assert.IsNotEmpty(result);
        }
コード例 #3
0
        // Test for string.Empty URL.
        public void UrlStringEmptyTest()
        {
            IWebCollector collector = new WebCollector();
            string        url       = string.Empty;

            collector.GetHTMLFromUrl(url);

            Assert.AreEqual(string.Empty, collector.HtmlCode);
        }
コード例 #4
0
        public async Task GetHTMLFromUrlTestWithNoHTTP()
        {
            var wc = new WebCollector();
            await wc.GetHTMLFromUrl("www.aftonbladet.se");

            var result = wc.HtmlCode;

            Assert.IsEmpty(result);
        }
コード例 #5
0
        public async Task GetHTMLFromUrlTestWithEmptyString()
        {
            var wc = new WebCollector();
            await wc.GetHTMLFromUrl(string.Empty);

            var result = wc.HtmlCode;

            Assert.IsEmpty(result);;
        }
コード例 #6
0
        public async Task GetHTMLFromUrlTestWithNull()
        {
            var wc = new WebCollector();
            await wc.GetHTMLFromUrl(null);

            var result = wc.HtmlCode;

            Assert.IsEmpty(result);
        }
コード例 #7
0
        public async Task <int> UpdateGUI(string url, string searchCrit)
        {
            WebCollector webData = new WebCollector();

            webData.GetHTMLFromUrl(url);
            WebCalculator stuff  = new WebCalculator();
            int           result = stuff.Count(webData, searchCrit);

            System.Threading.Thread.Sleep(1000);
            return(result);
        }
コード例 #8
0
        // Test to see if inputting valid data works
        public void ValidDataTest()
        {
            IWebCollector collector = new WebCollector();
            string        url       = "http://aftonbladet.se";

            collector.GetHTMLFromUrl(url);

            if (collector.HtmlCode == string.Empty)
            {
                Assert.Fail("String is empty when it should contain HTML code");
            }
        }
コード例 #9
0
        public void CalculateNumberOfHitsTestKeywordEmpty()
        {
            var wb = new WebCollector();

            wb.GetHTMLFromUrl("https://www.aftonbladet.se/");

            WebCalculator wc     = new WebCalculator();
            int           result = wc.CalculateNumberOfHits(wb, string.Empty);

            if (result != -1)
            {
                Assert.Fail();
            }
        }
コード例 #10
0
        public void CalculateNumberOfHitsTestHTTPNull()
        {
            var wb = new WebCollector();

            wb.GetHTMLFromUrl("");

            WebCalculator wc = new WebCalculator();

            if (wb.HtmlCode == null)
            {
                int result = wc.CalculateNumberOfHits(wb, "polis");
                if (result != -1)
                {
                    Assert.Fail();
                }
            }
        }
コード例 #11
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            resultBox.Text = "Please Wait..";
            if (keyword != null && site != null)
            {
                WebCollector  wc = new WebCollector();
                WebCalculator wb = new WebCalculator();

                //Ascync!
                await wc.GetHTMLFromUrl(site);

                var tempSite = wc.HtmlCode;
                int result   = wb.CalculateNumberOfHits(wc, keyword);

                resultBox.Text = result.ToString();
            }

            else
            {
                MessageBox.Show("Choose Keyword And Site");
            }
        }