public async Task <TransactionsResult> TransferAsync(TransferRequest transferRequest)
        {
            var transactionsResult = new TransactionsResult
            {
                AccountIban      = transferRequest.FromAccountIban,
                Amount           = transferRequest.Amount,
                Success          = false,
                ErrorMessage     = string.Empty,
                TransactionsType = "Transfer",
                TransactionsDate = DateTime.UtcNow
            };

            var accountFrom = await accountRepository.GetByAccountIbanAsync(transferRequest.FromAccountIban);

            var accountTo = await accountRepository.GetByAccountIbanAsync(transferRequest.ToAccountIban);

            if (accountFrom == null || accountTo == null)
            {
                transactionsResult.ErrorMessage = "Account does not exists";
                return(transactionsResult);
            }

            if (accountFrom.Balance - transferRequest.Amount < 0)
            {
                transactionsResult.ErrorMessage = "Account balance not enough";
                return(transactionsResult);
            }

            accountFrom.Balance -= transferRequest.Amount;
            accountTo.Balance   += transferRequest.Amount;

            await accountRepository.UpdateAccountAsync(accountFrom);

            await accountRepository.UpdateAccountAsync(accountTo);

            var transfer = new Transfer
            {
                TransferId    = Guid.NewGuid(),
                FromAccountId = accountFrom.AccountId,
                ToAccountId   = accountTo.AccountId,
                Amount        = transferRequest.Amount,
                Timestamp     = DateTime.UtcNow
            };

            await transferRepository.AddTransferAsync(transfer);

            transactionsResult.Balance = accountFrom.Balance;
            transactionsResult.Success = true;

            return(transactionsResult);
        }
        public async Task TransferAsync_WithCorrectAmount_ReturnTransactionsResult()
        {
            var transferRequest = new TransferRequest
            {
                FromAccountIban = "AAAA",
                ToAccountIban   = "BBBB",
                Amount          = 1000
            };

            var fromAccount = new Account
            {
                AccountId   = Guid.NewGuid(),
                AccountIban = "AAAA",
                Balance     = 2000,
            };

            var toAccount = new Account
            {
                AccountId   = Guid.NewGuid(),
                AccountIban = "BBBB",
                Balance     = 500,
            };

            accountRepository.GetByAccountIbanAsync(transferRequest.FromAccountIban).Returns(Task.FromResult(fromAccount));
            accountRepository.GetByAccountIbanAsync(transferRequest.ToAccountIban).Returns(Task.FromResult(toAccount));
            accountRepository.UpdateAccountAsync(fromAccount).Returns(Task.FromResult(new Account()));
            accountRepository.UpdateAccountAsync(toAccount).Returns(Task.FromResult(new Account()));
            transferRepository.AddTransferAsync(Arg.Any <Transfer>()).Returns(Task.FromResult(new Transfer()));

            // Act
            var transactionsResult = await transactionsService.TransferAsync(transferRequest);

            // Assert
            Assert.True(transactionsResult.Success);
            Assert.Equal(1000, transactionsResult.Balance);
        }