public void Given_When_Build_Should_Build_CustomerAccountViewModel()
        {
            //arrange
            var transaction = new Transaction
            {
                Id     = 1,
                Amount = 50
            };

            var accountTransactionResponse = new AccountTransactionResponse
            {
                Transactions = new List <Transaction>
                {
                    transaction
                }
            };

            var transactionRequest = new TransactionRequest(1);

            _transactionRequestBuilderMock.Setup(c => c.Build(1)).Returns(transactionRequest);

            _transactionProviderMock.Setup(c => c.Execute(transactionRequest)).Returns(accountTransactionResponse);

            //act
            var expectedAccountTransactionViewModel = _transactionViewModelBuilder.Build(1);

            //assert
            var expectedAccountTransaction = expectedAccountTransactionViewModel.Transactions.FirstOrDefault();

            Assert.NotNull(expectedAccountTransactionViewModel);
            Assert.AreEqual(expectedAccountTransactionViewModel.Transactions.Count(), 1);
            Assert.AreEqual(expectedAccountTransaction.Id, transaction.Id);
            Assert.AreEqual(expectedAccountTransaction.Amount, transaction.Amount);
        }
Beispiel #2
0
        private AccountTransactionResponse ConvertToResponse(Account account, string currency = null)
        {
            var response = new AccountTransactionResponse
            {
                AccountNumber = account.AccountNumber,
                Successful    = true,
                Message       = "Success",
            };

            if (currency == null)
            {
                response.AccountBalances = account.Balances.Select(b =>
                                                                   new AccountBalanceResponse
                {
                    Currency = b.Currency,
                    Balance  = b.Balance
                }).ToList();
            }
            else
            {
                response.Currency = currency;
                response.Balance  = account.Balances.FirstOrDefault(b => b.Currency == currency)?.Balance ?? 0;
            }

            return(response);
        }
        public AccountTransactionResponse ListAccountTransaction(int accountId)
        {
            var transactions = _accountService.Transactions(accountId);

            var accountTransactionResponse = new AccountTransactionResponse
            {
                Transactions = transactions.ToList()
            };

            return(accountTransactionResponse);
        }