public void Create_SearchOccurrence()
        {
            var testUrl     = "http://google.com";
            var testResults = new int[] { 2 };

            var search = SearchOccurrence.Create(testUrl, testResults);

            Assert.IsNotNull(search);
            Assert.AreEqual(testUrl, search.URL);
            Assert.AreEqual(testResults.Length, search.Occurrences.Length);
        }
Ejemplo n.º 2
0
        public async Task <SearchOccurrence> Search(string keywords, Uri url, SearchEngine searchEngine)
        {
            _logger.LogInformation("Calling Search method");
            var scrapeResults = await _webScrapper.GetMatchingURLs(keywords, searchEngine, url);

            var result = new SearchOccurrence
            {
                //If there is no result available, add 0 into the array
                Occurrences  = scrapeResults.Any() ? scrapeResults.Select(s => s.Index).ToArray() : new int[] { 0 },
                SearchEngine = searchEngine,
                URL          = url.ToString()
            };

            return(result);
        }