예제 #1
0
        public ActionResult FilterStopWord(FormCollection form)
        {
            string     source    = "";
            string     url       = "";
            StopWords  sw        = new StopWords();
            ISeoFilter seoFilter = null;
            IUrlFilter urlFilter = new StopWordUrlFilterService();
            IEnumerable <StopWords> resultLink = new List <StopWords>();

            if (form["url"] == null)
            {
                source    = form["anytext"].ToString();
                seoFilter = new StopWordTextFilterService();
            }
            else
            {
                source    = form["url"].ToString();
                url       = source;
                seoFilter = new StopWordUrlFilterService();
            }

            string response   = seoFilter.GetDataFromSource(source);
            var    res        = seoFilter.GetResponseBody(response);
            var    result     = seoFilter.CalculateStopCount(res);
            var    resultBody = sw.PopulateStopWords(result);

            if (seoFilter is StopWordUrlFilterService)
            {
                var link    = urlFilter.GetResponseLink(response);
                var str     = string.Join(",", link);
                var result1 = seoFilter.CalculateStopCount(str);
                resultLink = sw.PopulateStopWords(result1);
            }
            ViewBag.Url = url;

            sw.Body = resultBody;
            sw.Link = resultLink;

            return(View(sw));
        }
예제 #2
0
        public void FilterStopWord_URL(string value)
        {
            StopWords  model     = new StopWords();
            ISeoFilter seoFilter = new StopWordUrlFilterService();
            IEnumerable <StopWords> resultLink = new List <StopWords>();

            string response   = seoFilter.GetDataFromSource(value);
            var    res        = seoFilter.GetResponseBody(response);
            var    result     = seoFilter.CalculateStopCount(res);
            var    resultBody = model.PopulateStopWords(result);

            Assert.IsNotNull(resultBody, "Stop Words is available");
        }
예제 #3
0
        public void FilterStopWord_Text(string value)
        {
            StopWords  model     = new StopWords();
            ISeoFilter seoFilter = new StopWordTextFilterService();
            IEnumerable <StopWords> resultLink = new List <StopWords>();

            string response   = seoFilter.GetDataFromSource(value);
            var    res        = seoFilter.GetResponseBody(response);
            var    result     = seoFilter.CalculateStopCount(res);
            var    resultBody = model.PopulateStopWords(result);

            var body = resultBody.FirstOrDefault().Body;

            Assert.IsTrue(resultBody.Any(c => c.Word == "and" && c.Count == 2), "Word 'and' is 2 count");
        }