public async Task Integration_GetAccountBalance_Expect70000()
        {
            Account newAccount = new Account {
                Name = "Test Account"
            };

            _context.Accounts.Add(newAccount);
            _context.SaveChanges();
            // 10 Deposits of 1000
            for (int i = 0; i < 10; i++)
            {
                _context.Transactions.Add(new Transaction
                {
                    AccountId         = newAccount.Id,
                    Amount            = 1000,
                    TransactionStatus = TransactionStatusEnum.Processed,
                    TransactionType   = TransactionTypeEnum.Deposit,
                    Date           = new DateTime(2020, 1, 1),
                    CreationDate   = new DateTime(2020, 1, 1),
                    LastUpdateDate = new DateTime(2020, 1, 1)
                });
            }
            // 2 Pending Payments
            for (int i = 0; i < 2; i++)
            {
                _context.Transactions.Add(new Transaction
                {
                    AccountId         = newAccount.Id,
                    Amount            = 1000,
                    TransactionStatus = TransactionStatusEnum.Pending,
                    TransactionType   = TransactionTypeEnum.Withdrawal,
                    Date           = new DateTime(2020, 1, 1),
                    CreationDate   = new DateTime(2020, 1, 1),
                    LastUpdateDate = new DateTime(2020, 1, 1)
                });
            }
            // 1 Procesed Payment
            _context.Transactions.Add(new Transaction
            {
                AccountId         = newAccount.Id,
                Amount            = 1000,
                TransactionStatus = TransactionStatusEnum.Processed,
                TransactionType   = TransactionTypeEnum.Withdrawal,
                Date           = new DateTime(2020, 1, 1),
                CreationDate   = new DateTime(2020, 1, 1),
                LastUpdateDate = new DateTime(2020, 1, 1)
            });
            // 2 Closed Payments
            for (int i = 0; i < 3; i++)
            {
                _context.Transactions.Add(new Transaction
                {
                    AccountId         = newAccount.Id,
                    Amount            = 100000,
                    TransactionStatus = TransactionStatusEnum.Closed,
                    TransactionType   = TransactionTypeEnum.Withdrawal,
                    Date           = new DateTime(2020, 1, 1),
                    CreationDate   = new DateTime(2020, 1, 1),
                    LastUpdateDate = new DateTime(2020, 1, 1),
                    ClosedReason   = Messages.Payment_NotEnoughFundsReason
                });
            }
            _context.SaveChanges();

            var response = await _client.GetAsync($"/api/account/balance/{newAccount.Id}");

            response.StatusCode.Should().Be(System.Net.HttpStatusCode.OK);
            var responseString = await response.Content.ReadAsStringAsync();

            AccountBalanceResultDto accountBalanceResult = JsonConvert.DeserializeObject <AccountBalanceResultDto>(responseString);

            accountBalanceResult.Should().NotBeNull();
            accountBalanceResult.OpeningBalance.Should().Be(10000);
            accountBalanceResult.ProcessedPaymentsBalance.Should().Be(1000);
            accountBalanceResult.PendingdPaymentsBalance.Should().Be(2000);
            accountBalanceResult.ClosingBalance.Should().Be(7000);
            accountBalanceResult.Deposits.Should().HaveCount(10);
            accountBalanceResult.Payments.Should().HaveCount(6);
            accountBalanceResult.Payments.Where(p => p.TransactionStatus == TransactionStatusEnum.Pending.ToString()).Should().HaveCount(2);
            accountBalanceResult.Payments.Where(p => p.TransactionStatus == TransactionStatusEnum.Closed.ToString()).Should().HaveCount(3);
            accountBalanceResult.Payments.Where(p => p.TransactionStatus == TransactionStatusEnum.Processed.ToString()).Should().HaveCount(1);
        }
        public async Task Unit_GetAccountBalance_Expect70000()
        {
            Account newAccount = new Account {
                Name = "Test Account"
            };

            _context.Accounts.Add(newAccount);
            _context.SaveChanges();
            // 10 Deposits of 1000
            for (int i = 0; i < 10; i++)
            {
                _context.Transactions.Add(new Transaction
                {
                    AccountId         = newAccount.Id,
                    Amount            = 1000,
                    TransactionStatus = TransactionStatusEnum.Processed,
                    TransactionType   = TransactionTypeEnum.Deposit,
                    Date           = new DateTime(2020, 1, 1),
                    CreationDate   = new DateTime(2020, 1, 1),
                    LastUpdateDate = new DateTime(2020, 1, 1)
                });
            }
            // 2 Pending Payments
            for (int i = 0; i < 2; i++)
            {
                _context.Transactions.Add(new Transaction
                {
                    AccountId         = newAccount.Id,
                    Amount            = 1000,
                    TransactionStatus = TransactionStatusEnum.Pending,
                    TransactionType   = TransactionTypeEnum.Withdrawal,
                    Date           = new DateTime(2020, 1, 1),
                    CreationDate   = new DateTime(2020, 1, 1),
                    LastUpdateDate = new DateTime(2020, 1, 1)
                });
            }
            // 1 Procesed Payment
            _context.Transactions.Add(new Transaction
            {
                AccountId         = newAccount.Id,
                Amount            = 1000,
                TransactionStatus = TransactionStatusEnum.Processed,
                TransactionType   = TransactionTypeEnum.Withdrawal,
                Date           = new DateTime(2020, 1, 1),
                CreationDate   = new DateTime(2020, 1, 1),
                LastUpdateDate = new DateTime(2020, 1, 1)
            });
            // 2 Closed Payments
            for (int i = 0; i < 3; i++)
            {
                _context.Transactions.Add(new Transaction
                {
                    AccountId         = newAccount.Id,
                    Amount            = 100000,
                    TransactionStatus = TransactionStatusEnum.Closed,
                    TransactionType   = TransactionTypeEnum.Withdrawal,
                    Date           = new DateTime(2020, 1, 1),
                    CreationDate   = new DateTime(2020, 1, 1),
                    LastUpdateDate = new DateTime(2020, 1, 1),
                    ClosedReason   = Messages.Payment_NotEnoughFundsReason
                });
            }
            _context.SaveChanges();

            AccountBalanceService balanceService = new AccountBalanceService(_mockLogger.Object, newAccount.Id, _mapper, _accountRepo, _transRepo);
            ServiceResult         result         = await balanceService.GetAccountBalance();

            result.Should().NotBeNull();
            AccountBalanceResultDto balance = JsonConvert.DeserializeObject <AccountBalanceResultDto>(result.ContentResult);

            balance.Should().NotBeNull();
            balance.AccountId.Should().Be(newAccount.Id);
            balance.OpeningBalance.Should().Be(10000);
            balance.ProcessedPaymentsBalance.Should().Be(1000);
            balance.PendingdPaymentsBalance.Should().Be(2000);
            balance.ClosingBalance.Should().Be(7000);
            balance.Deposits.Count().Should().Be(10);
            balance.Payments.Count().Should().Be(6);
        }