示例#1
0
        public void IWebCalculatorTests_Check_If_WebColl_Is_Null()
        {
            IWebCalculator wcalc  = new WebHandler();
            IWebCollector  wcoll  = new WebHandler();
            string         t      = "test";
            var            result = wcalc.CalculateNumberOfHits(wcoll, t);

            Assert.AreEqual(-1, result);
        }
示例#2
0
        public void MoqTest()
        {
            Mock <IWebCollector> moq   = new Mock <IWebCollector>();
            IWebCalculator       wcalc = new WebHandler();

            moq.Setup(x => x.HtmlCode).Returns("koreakoreakorea");
            string k      = "korea";
            var    result = wcalc.CalculateNumberOfHits(moq.Object, k);

            Assert.That(result == 3);
        }
示例#3
0
        public void IWebCalculatorTests_Is_Keyword_string_null()
        {
            IWebCalculator wcalc  = new WebHandler();
            IWebCollector  wecoll = new WebHandler();
            string         url    = "https://www.aftonbladet.se";

            wecoll.GetHTMLFromUrl(url);
            var results = wcalc.CalculateNumberOfHits(wecoll, keyword: null);

            Assert.AreEqual(-1, results);
        }
示例#4
0
        public void IWebCalculatorTests_Check_If_Html_String_Is_Empty()
        {
            IWebCalculator wcalc  = new WebHandler();
            IWebCollector  wecoll = new WebHandler();

            wecoll.HtmlCode = string.Empty;
            string t       = "test";
            var    results = wcalc.CalculateNumberOfHits(wecoll, t);

            Assert.AreEqual(-1, results);
        }
示例#5
0
        public void IWebCalculator_TestNullObjectHtml()
        {
            IWebCalculator wcalc  = new WebHandler();
            IWebCollector  wecoll = new WebHandler();

            wecoll.HtmlCode = null;
            string t       = "test";
            var    results = wcalc.CalculateNumberOfHits(wecoll, t);

            Assert.AreEqual(-1, results);
        }