public async Task GetAccountTestAsync(int accountId, bool existingAccount, double expectedBalance, int expectedCountOfPayments)
        {
            var result = await _accountBusiness.GetAccountByIdIncludingPayments(accountId);

            if (existingAccount)
            {
                //check account value
                Assert.NotNull(result);
                Assert.Equal(expectedBalance, result.Balance);
                Assert.Equal(expectedCountOfPayments, result.Payments.Count);
            }
            else
            {
                //null check
                Assert.Null(result);
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Get(int accountId)
        {
            try
            {
                _logger.LogInformation($"Retriving account by id: {accountId}...");
                var result = await _accountBusiness.GetAccountByIdIncludingPayments(accountId);

                if (result == null)
                {
                    return(NotFound($"Account with id: {accountId} doesn't exist in DB."));
                }
                _logger.LogInformation($"Retrived account by id: {accountId}.");
                return(Ok(result));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Error while retriving account by id: {accountId}. {ex.Message}. {ex.StackTrace}");
                var result = StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
                return(result);
            }
        }