Ejemplo n.º 1
0
        public async Task GetById_Should_Return_Null_Account()
        {
            // Arrange
            using var factory         = new SQLiteDbContextFactory();
            await using var dbContext = factory.CreateContext();
            _service = new Service.Service.AccountsService(dbContext, _mapper);
            var accountsId = 9;

            // Act
            var actual = await _service.GetAccount(accountsId);

            // Assert
            Assert.IsNull(actual);
        }
            public async Task GetById_Should_Return_Correct_Account()
            {
                // Arrange
                using var factory         = new SQLiteDbContextFactory();
                await using var dbContext = factory.CreateContext();
                _accountService           = new BankApplication.Service.Service.AccountsService(dbContext, _mapper);
                var accountId = 1;

                // Act
                var actual = await _accountService.GetAccount(accountId);

                // Assert
                Assert.AreEqual(accountId, actual.Id);
            }
Ejemplo n.º 3
0
        public async Task GetAccount_ShouldReturnNull()
        {
            using var factory         = new SQLiteDbContextFactory();
            await using var dbContext = factory.CreateContext();
            accountsRepository        = new AccountsService(dbContext, mapper);

            //Arrange
            var accountId = 85;

            //Actual
            var actual = await accountsRepository.GetAccount(accountId);

            //Assert
            Assert.Null(actual);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Get([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _accountsRepository.GetAccount(id);

            if (result == null)
            {
                return(NotFound());
            }

            return(Ok(result));
        }
Ejemplo n.º 5
0
        public ActionResult <AccountDTO> GetAccount(string Username)
        {
            var account = _accountsRepository.GetAccount(Username);

            return(Ok(_mapper.Map <AccountDTO>(account)));
        }
 public async Task <IActionResult> GetAccount([FromRoute] int id)
 {
     return(Ok(await _service.GetAccount(id)));
 }
 public AccountDTO GetAccount(int accountId)
 {
     return(MapAccountToAccountDTO(accountsRepository
                                   .GetAccount(accountId)));
 }