public async Task HandleAsync_GivenRepositoryReturnEmptyCollection_ShouldReturnEmptyResults() { // Given var query = new SearchAnimeQuery(); var mockRepository = new Mock <IAnimeRepository>(); mockRepository.Setup(x => x.GetOrderedPageByPopularityAsync(It.IsAny <Expression <Func <Anime, bool> > >(), 0, 10)) .ReturnsAsync(new PagedResult <Anime> { Results = new List <Anime>() }); var mockAnimeSearchCriteriaService = new Mock <IAnimeSearchCriteriaService>(); mockAnimeSearchCriteriaService.Setup(x => x.BuildExpression(query)).Returns(f => true); var handler = new SearchAnimeQueryHandler(mockRepository.Object, mockAnimeSearchCriteriaService.Object); // When var result = await handler.HandleAsync(query); // Then mockRepository.Verify(x => x.GetOrderedPageByPopularityAsync(It.IsAny <Expression <Func <Anime, bool> > >(), 0, 10), Times.Once); result.Results.Should().BeEmpty(); }
public Task <PagedResult <AnimeSearchEntryDto> > GetSearchEntries([FromQuery] SearchAnimeQuery query) => HandleAsync(async() => await _searchAnimeQueryHandler.HandleAsync(query));