public void InsertBatchOfNewTransactions_AddingSingleTransactionIntoExistingLastDay_ReturnsExpectedDailyBalance() { IBankAccountDailyBalances dailyBalances = BuildDailyBalances(); // Act dailyBalances.InsertSingleNewTransaction(new FinancialTransactionDto(DateTime.Parse("04/01/2020 02:00:00"), "Ledger", 100.0, "Company")); // Assert var balances = dailyBalances.GetAllDailyBalances(); balances.Count.ShouldEqual(3); balances[0].Date.ShouldEqual(DateTime.Parse("01/10/2020 00:00:00")); balances[0].StartingBalance.ShouldEqual(0.0); balances[0].TotalTransactionSum.ShouldEqual(3.0); balances[0].EndingBalance.ShouldEqual(3.0); balances[1].Date.ShouldEqual(DateTime.Parse("02/15/2020 00:00:00")); balances[1].StartingBalance.ShouldEqual(3.0); balances[1].TotalTransactionSum.ShouldEqual(6); balances[1].EndingBalance.ShouldEqual(9.0); balances[2].Date.ShouldEqual(DateTime.Parse("04/01/2020 00:00:00")); balances[2].StartingBalance.ShouldEqual(9.0); balances[2].TotalTransactionSum.ShouldEqual(109); balances[2].EndingBalance.ShouldEqual(118.0); }
public void ForEach_MultipleDailyBalances_EachDailyBalanceIsSeen() { IBankAccountDailyBalances dailyBalances = BuildDailyBalances(); var expectedBalances = dailyBalances.GetAllDailyBalances(); List <DateTime> expectedDays = new List <DateTime>(); List <DateTime> visitedDays = new List <DateTime>(); dailyBalances.ForEach(dailyBalance => expectedDays.Add(dailyBalance.Date)); // Act dailyBalances.ForEach(dailyBalance => visitedDays.Add(dailyBalance.Date)); // Assert visitedDays.Count.ShouldEqual(expectedBalances.Count); expectedDays.ShouldEqual(visitedDays); }
public BankAccount(IBank bank, double startingBalance, IBankAccountDailyBalances dailyBalances) { this.Bank = bank; this.StartingBalance = startingBalance; this._dailyBalances = dailyBalances; }