Beispiel #1
0
        public async Task <IHttpActionResult> GetPagedLotteries(string filter = "", int page = 1, int pageSize = WebApiConstants.DefaultPageSize)
        {
            var args = new GetPagedLotteriesArgs {
                Filter = filter, PageNumber = page, PageSize = pageSize, UserOrg = GetUserAndOrganization()
            };
            var pagedLotteriesDto = await _lotteryService.GetPagedLotteriesAsync(args);

            var pagedLotteriesViewModel = new PagedViewModel <LotteryDetailsDto>
            {
                PagedList = pagedLotteriesDto,
                PageCount = pagedLotteriesDto.PageCount,
                ItemCount = pagedLotteriesDto.TotalItemCount,
                PageSize  = pageSize
            };

            return(Ok(pagedLotteriesViewModel));
        }
Beispiel #2
0
        public async Task GetPagedLotteries_Should_Return_Ok()
        {
            // Arrange
            var args = new GetPagedLotteriesArgs
            {
                Filter     = "",
                PageNumber = 1,
                PageSize   = 10,
                UserOrg    = _userAndOrganization
            };

            var pagedListAsync = await LotteryDetailsDto.ToPagedListAsync(args.PageNumber, args.PageSize);

            _lotteryService.GetPagedLotteriesAsync(args).Returns(pagedListAsync);

            // Act
            var response = await _lotteryController.GetPagedLotteries("", 1, 10);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsInstanceOf <OkNegotiatedContentResult <PagedViewModel <LotteryDetailsDto> > >(response);
            await _lotteryService.Received(1).GetPagedLotteriesAsync(Arg.Any <GetPagedLotteriesArgs>());
        }