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()); }
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); }
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); }
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); } }