Ejemplo n.º 1
0
        public async Task GetAllWalletsAsync_GetWallets_AllWalletsReturned()
        {
            SetupMocksGet <IEnumerable <Wallet>, IEnumerable <WalletDto> >(fixture.UserWithWallets,
                                                                           fixture.UserWalletsDtos);

            var wallets = await service.GetAllWalletsAsync(fixture.UserWithWallets.UserId, fixture.PaginationFilter);

            Assert.Equal(wallets, fixture.UserWalletsDtos);
            VerifyMockGetUser(fixture.UserWithWallets.UserId, Times.Once());
            MockMapper.Verify(x => x.Map <IEnumerable <WalletDto> >(fixture.UserWithWallets.Wallets), Times.Once);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> ShowAllWalletsAsync([FromQuery] PaginationQuery pagination)
        {
            var userId     = GetUserId();
            var filter     = Mapper.Map <PaginationFilter>(pagination);
            var walletsDto = await walletService.GetAllWalletsAsync(userId, filter);

            if (!walletsDto.Any())
            {
                return(NotFound());
            }

            var wallets = Mapper.Map <IEnumerable <Wallet> >(walletsDto);

            return(IsPagingSpecified(pagination) ? Ok(CreatePagedResponse(pagination, wallets)) : Ok(wallets));
        }