public void GetBalance_MustReturn_TheBalanceBetweenIncomeAndExpense() { Account account = new Account(); Expense ex = new Expense(100, DateTime.Today); Expense ex2 = new Expense(50, DateTime.Today); Income income = new Income(200, DateTime.Today); account.AddExpense(ex); account.AddExpense(ex2); account.AddIncome(income); double balance = account.GetBalance(); Assert.AreEqual(50, balance); }
public void GetBalances_ForEachMonth_StartingFrom_MustReturns_Balances() { Account account = new Account(); account.AddIncome(new Income(100, The.Year(2012).On.January.The1st)); account.AddExpense(new Expense(80, The.Year(2012).On.January.The1st)); account.AddIncome(new Income(1000, The.Year(2012).On.April.The1st)); account.AddExpense(new Expense(600, The.Year(2012).On.August.The1st)); List <PartialBalance> balances = account.GetBalances(ForEach.Month.StartingFrom(The.Year(2012).On.January.The1st)); Assert.AreEqual(12, balances.Count()); Assert.AreEqual(20, balances.ElementAt(0).Balance); Assert.AreEqual(1000, balances.ElementAt(3).Balance); Assert.AreEqual(-600, balances.ElementAt(7).Balance); }
public void Add_ExpenseOnAccount_MustBeAdded() { Account account = new Account(); Expense ex = new Expense(5, DateTime.Today); account.AddExpense(ex); CollectionAssert.Contains(account.Movements, ex); }
public void GetBalances_ForEachDay_StartingFrom_MustReturns_Balances() { Account account = new Account(); account.AddIncome(new Income(100, The.Year(2012).On.January.The1st)); account.AddExpense(new Expense(80, The.Year(2012).On.January.The1st)); List <PartialBalance> balances = account.GetBalances(ForEach.Day.StartingFrom(The.Year(2012).On.January.The1st)); Assert.AreEqual(20, balances.ElementAt(0).Balance); }
public void GetMovementsByTag_MustReturns_TheTaggedMovements() { Account account = new Account(); Expense ex = new Expense(100, DateTime.Today, "mangiare"); Expense ex2 = new Expense(10, DateTime.Today, "cellulare"); Income income = new Income(1000, DateTime.Today, "stipendio"); Income income2 = new Income(25, DateTime.Today, "Cellulare"); account.AddExpense(ex); account.AddExpense(ex2); account.AddIncome(income); account.AddIncome(income2); IEnumerable <IMovement> movements = account.GetMovementByTag("Cellulare"); CollectionAssert.DoesNotContain(movements, ex); CollectionAssert.DoesNotContain(movements, income); CollectionAssert.Contains(movements, ex2); CollectionAssert.Contains(movements, income2); }
public void GetBalanceInPeriod_MustReturn_BalanceOfperiod() { Account account = new Account(); // movements in range account.AddIncome(new Income(1200, The.Year(2012).On.January.The10th)); account.AddExpense(new Expense(5, The.Year(2012).On.January.The15th)); account.AddExpense(new Expense(400, The.Year(2012).On.January.The30th)); account.AddExpense(new Expense(120, The.Year(2012).On.February.The4th)); account.AddIncome(new Income(100, The.Year(2012).On.February.The6th)); // some movement extra range. Must be skipped account.AddExpense(new Expense(120, The.Year(2012).On.April.The4th)); account.AddIncome(new Income(100, The.Year(2012).On.April.The6th)); var from = The.Year(2012).On.January.The10th; var to = The.Year(2012).On.February.The9th; double balance = account.GetBalanceInPeriod(from, to); Assert.AreEqual(1200 - 5 - 400 - 120 + 100, balance); }