Exemple #1
0
        /// <summary>
        /// Test that the search results at arbitrary offsets
        /// in the collection are present
        /// </summary>
        public void Check_RequiredField_Present()
        {
            string testFile = "Search.CGov.En.BreastCancer.json";

            IOptions <SearchIndexOptions> config = GetMockSearchIndexConfig();
            SearchController ctrl = new SearchController(
                ElasticTools.GetInMemoryElasticClient(testFile),
                config,
                NullLogger <SearchController> .Instance
                );

            //Parameters don't matter in this case...
            SiteWideSearchResults results = ctrl.Get(
                "cgov",
                "en",
                "breast cancer"
                );

            Assert.All(results.Results, item => Assert.NotNull(item.URL));
        }
Exemple #2
0
        /// <summary>
        /// Test that search mapping returns correct number of results for an empty result set.
        /// (And also that it doesn't explode!)
        /// </summary>
        public void No_Results_Has_Correct_Total()
        {
            string testFile = "Search.CGov.En.NoResults.json";

            IOptions <SearchIndexOptions> config = GetMockSearchIndexConfig();
            SearchController ctrl = new SearchController(
                ElasticTools.GetInMemoryElasticClient(testFile),
                config,
                NullLogger <SearchController> .Instance
                );

            //Parameters don't matter in this case...
            SiteWideSearchResults results = ctrl.Get(
                "cgov",
                "en",
                "breast cancer"
                );

            Assert.Empty(results.Results);
        }
Exemple #3
0
        /// <summary>
        /// Test that the search result mapping returns null when an optional field is not present.
        /// Inputs for each call are obtained by iterating over the FieldData property.
        /// </summary>
        /// <param name="offset">Offset into testFile's set of search results.</param>
        /// <param name="nullTest">A test function of tupe Func&lt;SiteWideSearchResult, Boolean&gt; which checks
        /// wheter a specific field in the selected result is null.</param>
        /// <param name="fieldName">Name of the field being tested, used for display purposes.</param>
        public void Optional_Field_Is_Null(int offset, Object nullTest, string fieldName)
        {
            string testFile = "Search.CGov.En.AbsentFields.json";

            IOptions <SearchIndexOptions> config = GetMockSearchIndexConfig();
            SearchController ctrl = new SearchController(
                ElasticTools.GetInMemoryElasticClient(testFile),
                config,
                NullLogger <SearchController> .Instance
                );

            //Parameters don't matter in this case...
            SiteWideSearchResults results = ctrl.Get(
                "cgov",
                "en",
                "breast cancer"
                );

            SiteWideSearchResult item = results.Results[offset];

            Assert.True(((Func <SiteWideSearchResult, Boolean>)nullTest)(item), fieldName);
        }