/// <summary>
        /// Performs search using the fake search service and populating default values to make sure that search works correctly when modifying just some parameters.
        /// </summary>
        private static TestSearchResults Search(
            string indexes                 = "index1;index2",
            string culture                 = "en-us",
            string defaultCulture          = "en-us",
            string siteName                = "site",
            bool combineWithDefaultCulture = true,
            string query          = "query",
            int page              = 0,
            int pageSize          = 5,
            string resultsXmlPath = null
            )
        {
            var testResults = new TestSearchResults();
            int numberOfResults;

            // Mock the method CultureHelper.GetDefaultCultureCode()
            CultureHelper.HelperObject = new FakeCultureHelper(defaultCulture);

            var searchService = new FakeSearchService(indexes.Split(';'), culture, siteName, combineWithDefaultCulture, resultsXmlPath);

            testResults.Results         = searchService.Search(query, page, pageSize, out numberOfResults);
            testResults.NumberOfResults = numberOfResults;
            testResults.RawResults      = searchService.RawResults;
            testResults.Parameters      = searchService.Parameters;

            CultureHelper.HelperObject = null;

            return(testResults);
        }
Beispiel #2
0
        public void Search_NoOptions_ThrowsException()
        {
            var searchService = new FakeSearchService(null, new FakePagesActivityLogger());

            Assert.That(() => searchService.Search(null),
                        Throws.Exception.TypeOf <ArgumentNullException>());
        }
Beispiel #3
0
        private static TestSearchResults GeneralSearch(FakeSearchService service, IEnumerable <string> searchIndexNames, string query, string culture, bool combineWithDefaultCulture, int pageNumber, int pageSize)
        {
            var testResults = new TestSearchResults();

            var options = new SearchOptions(query, searchIndexNames)
            {
                CultureName = culture,
                CombineWithDefaultCulture = combineWithDefaultCulture,
                PageNumber = pageNumber,
                PageSize   = pageSize
            };

            var searchResult = service.Search(options);

            testResults.Result     = searchResult;
            testResults.RawResults = service.RawResults;
            testResults.Parameters = service.Parameters;

            return(testResults);
        }