Пример #1
0
        public async Task FindPageAsync_When_There_Is_Next_Page_Should_Create_Model_With_Next_Page()
        {
            int page      = 1;
            int pageCount = 5;
            IList <Advertisement> list = new List <Advertisement>()
            {
                new Advertisement(),
                new Advertisement(),
                new Advertisement(),
                new Advertisement(),
                new Advertisement(),
                new Advertisement(),
            };

            var listToConvert = list.Take(5).ToList();

            _repositoryMock
            .Setup(x =>
                   x.FindManyAsync(y => true, page, pageCount))
            .Returns(Task.FromResult(list));

            _converterMock.Setup(x => x.Convert(listToConvert)).Returns(new List <AdvertisementDTO>());

            var result = await _sut.FindPageAsync(page, pageCount);

            result.ShouldNotBeNull();
            result.Items.ShouldNotBeNull();
            result.NextPageAvailable.ShouldBeTrue();

            _converterMock.Verify(x => x.Convert(listToConvert), Times.Once);
            _repositoryMock.Verify(x => x.FindManyAsync(y => true, page, pageCount), Times.Once);
        }
Пример #2
0
 public async Task <IActionResult> Get([FromQuery] int page = 1, [FromQuery] int pageCount = 20)
 {
     return(Ok(await _service.FindPageAsync(page, pageCount)));
 }