コード例 #1
0
        public void ShouldGetFreeProducts(
            SearchRepository sut,
            ISearchIndex searchIndex,
            IIndexable indexable,
            [Frozen] SearchProvider provider,
            Switcher <SearchProvider> switcher)
        {
            // arrange
            searchIndex
            .CreateSearchContext()
            .GetQueryable <ProductSearchResultItem>()
            .Returns(new[]
            {
                new ProductSearchResultItem {
                    Free = true
                },
                new ProductSearchResultItem {
                    Free = false
                },
                new ProductSearchResultItem {
                    Free = true
                }
            }.AsQueryable());

            ContentSearchManager.SearchConfiguration.Indexes["indexName"] = searchIndex;
            provider.GetContextIndexName(indexable, Arg.Any <ICorePipeline>()).Returns("indexName");

            // act
            var products = sut.GetProducts(indexable);

            // assert
            Assert.Equal(2, products.Count());
        }
コード例 #2
0
 public void ShouldReturnCurrentName(
     [Frozen] SearchProvider current,
     Switcher <SearchProvider> switcher,
     IIndexable indexable,
     string expected,
     SwitchingSearchProvider sut)
 {
     current.GetContextIndexName(indexable).Returns(expected);
     sut.GetContextIndexName(indexable).Should().Be(expected);
 }
コード例 #3
0
        private static void InitIndexes(ISearchIndex index, SearchProvider searchProvider, IQueryable <SearchResultItem> results)
        {
            ContentSearchManager.SearchConfiguration.Indexes.Clear();
            searchProvider?.GetContextIndexName(Arg.Any <IIndexable>(), Arg.Any <ICorePipeline>()).Returns("CustomIndexName");

            var providerSearchContext = Substitute.For <IProviderSearchContext>();

            index.ReturnsForAll(providerSearchContext);
            providerSearchContext.GetQueryable <SearchResultItem>(Arg.Any <IExecutionContext[]>()).Returns(results);
            ContentSearchManager.SearchConfiguration.Indexes.Add("CustomIndexName", index);
        }
コード例 #4
0
 public void ShouldReturnCurrentNameByIIndexableAndIPipeline(
     [Frozen] SearchProvider current,
     IIndexable indexable,
     BaseCorePipelineManager pipeline,
     string expected,
     SwitchingSearchProvider sut)
 {
     using (new Switcher <SearchProvider>(current))
     {
         current.GetContextIndexName(indexable, pipeline).Returns(expected);
         sut.GetContextIndexName(indexable, pipeline).Should().Be(expected);
     }
 }