public void ShouldReturnGlobalSearch(ISearchResults searchResults, [Substitute] SearchService service, ISearchServiceRepository serviceRepository, ISearchSettingsRepository settingsRepository, QueryRepository queryRepository, IRenderingPropertiesRepository renderingPropertiesRepository, string query) { service.Search(Arg.Any<IQuery>()).Returns(searchResults); serviceRepository.Get().Returns(service); var controller = new SearchController(serviceRepository, settingsRepository, queryRepository, renderingPropertiesRepository); var result = controller.GlobalSearch() as ViewResult; result.Model.Should().As<ISearchResults>(); }
public void ShouldReturnPagedSearchResult([Substitute] SearchService service, ISearchServiceRepository serviceRepository, ISearchSettingsRepository settingsRepository, QueryRepository queryRepository, string query, ISearchResults searchResults, [Substitute] SearchController searchController, IRenderingPropertiesRepository renderingPropertiesRepository, [Substitute] PagingSettings pagingSettings) { renderingPropertiesRepository.Get<PagingSettings>().Returns(pagingSettings); service.Search(Arg.Any<IQuery>()).Returns(searchResults); serviceRepository.Get().Returns(service); var controller = new SearchController(serviceRepository, settingsRepository, queryRepository, renderingPropertiesRepository); var result = controller.PagedSearchResults(query, null) as ViewResult; result.Model.Should().BeOfType<PagedSearchResults>(); }
public void ShouldReturnGlobalSearch(ISearchResults searchResults, [Substitute] SearchService service, ISearchServiceRepository serviceRepository, ISearchSettingsRepository settingsRepository, QueryRepository queryRepository, IRenderingPropertiesRepository renderingPropertiesRepository, string query) { service.Search(Arg.Any <IQuery>()).Returns(searchResults); serviceRepository.Get().Returns(service); var controller = new SearchController(serviceRepository, settingsRepository, queryRepository, renderingPropertiesRepository); var result = controller.GlobalSearch() as ViewResult; result.Model.Should().As <ISearchResults>(); }
public IEnumerable <Item> Get(Item contextItem) { SearchService searchService = searchRepository.Get(new SearchSettingsBase { Templates = new[] { Templates._promo.ID } }); searchService.Settings.Root = contextItem; return(searchService.FindAll().Results.Select(x => x.Item)); }
public void ShouldReturnPagedSearchResult([Substitute] SearchService service, ISearchServiceRepository serviceRepository, ISearchSettingsRepository settingsRepository, QueryRepository queryRepository, string query, ISearchResults searchResults, [Substitute] SearchController searchController, IRenderingPropertiesRepository renderingPropertiesRepository, [Substitute] PagingSettings pagingSettings) { renderingPropertiesRepository.Get <PagingSettings>().Returns(pagingSettings); service.Search(Arg.Any <IQuery>()).Returns(searchResults); serviceRepository.Get().Returns(service); var controller = new SearchController(serviceRepository, settingsRepository, queryRepository, renderingPropertiesRepository); var result = controller.PagedSearchResults(query, null) as ViewResult; result.Model.Should().BeOfType <PagedSearchResults>(); }
public void SearchResults_ShouldReturnModel([Substitute]ControllerContext controllerContext, [Substitute]HttpContextBase context, ISearchResults searchResults, [Substitute]SearchService service, ISearchServiceRepository serviceRepository, ISearchContextRepository contextRepository, QueryRepository queryRepository, IRenderingPropertiesRepository renderingPropertiesRepository, string query) { service.Search(Arg.Any<IQuery>()).Returns(searchResults); serviceRepository.Get().Returns(service); var controller = new SearchController(serviceRepository, contextRepository, queryRepository, renderingPropertiesRepository) { ControllerContext = controllerContext }; controller.ControllerContext.HttpContext = context; var result = controller.SearchResults(query) as ViewResult; result.Model.Should().As<ISearchResults>(); }
public void SearchResults_ShouldReturnModel([Substitute] ControllerContext controllerContext, [Substitute] HttpContextBase context, ISearchResults searchResults, [Substitute] SearchService service, ISearchServiceRepository serviceRepository, ISearchContextRepository contextRepository, QueryRepository queryRepository, IRenderingPropertiesRepository renderingPropertiesRepository, string query) { service.Search(Arg.Any <IQuery>()).Returns(searchResults); serviceRepository.Get().Returns(service); var controller = new SearchController(serviceRepository, contextRepository, queryRepository, renderingPropertiesRepository) { ControllerContext = controllerContext }; controller.ControllerContext.HttpContext = context; var result = controller.SearchResults(query) as ViewResult; result.Model.Should().As <ISearchResults>(); }
public void Get_ReturnsListOfNews([Frozen] ISearchServiceRepository searchServiceRepository, [Frozen] ISearchSettingsRepository searchSettingsRepository, string itemName, [Substitute] SearchService searchService) { var id = ID.NewID; searchServiceRepository.Get().Returns(searchService); var db = new Db { new DbItem(itemName, id, Templates.NewsFolder.ID) }; var contextItem = db.GetItem(id); var repository = new NewsRepository(contextItem, searchServiceRepository); var news = repository.Get(); news.Should().As <IEnumerable <Item> >(); }
public void GetLatestNews_IntegerAs1Parameter_ReturnsNumberOfNewsEquelToParameterValue([Frozen] ISearchServiceRepository searchServiceRepository, [Frozen] ISearchSettingsRepository searchSettingsRepository, string itemName, [Substitute] SearchService searchService, ISearchResults searchResults, List <Item> collection) { var id = ID.NewID; searchResults.Results.Returns(collection.Select(x => new Foundation.Indexing.Models.SearchResult(x))); searchService.FindAll().Returns(searchResults); searchServiceRepository.Get().Returns(searchService); var db = new Db { new DbItem(itemName, id, Templates.NewsFolder.ID) }; var contextItem = db.GetItem(id); var repository = new NewsRepository(contextItem, searchServiceRepository); var news = repository.GetLatestNews(1); news.Count().ShouldBeEquivalentTo(1); }