Пример #1
0
        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();
        }
Пример #2
0
 public Task <PagedResult <AnimeSearchEntryDto> > GetSearchEntries([FromQuery] SearchAnimeQuery query)
 => HandleAsync(async() => await _searchAnimeQueryHandler.HandleAsync(query));