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