public void GetOwnPensionSavings_DifferentScenarios_ShouldReturnCorrectValue(Dictionary <MonthAndYear, Dictionary <string, double> > dictionary, MonthAndYear monthAndYear, double expectedPension) { var sut = new MonthlyAccountCategorySums(dictionary); var ownPension = sut.GetOwnPensionSavings(monthAndYear); Assert.AreEqual(expectedPension, ownPension); }
public void GetFortuneAndInvestmentSummed_DifferentScenarios_ShouldReturnCorrectValue(Dictionary <MonthAndYear, Dictionary <string, double> > dictionary, MonthAndYear monthAndYear, double expectedSum) { var sut = new MonthlyAccountCategorySums(dictionary); var fortune = sut.GetFortunesWithoutPension(monthAndYear); Assert.AreEqual(expectedSum, fortune); }
public void Constructor_NoParameters_ShouldGiveEmptyDictionary() { var sut = new MonthlyAccountCategorySums(); var count = sut.Count; Assert.AreEqual(0, count); }
public MonthlyAccountCategorySums GetAccumulatedCategorySums(int userId) { var(_, monthlyAccountStatuses) = MonthlyAccountStatus(userId); var accountCategories = new MonthlyAccountCategorySums(); foreach (var status in monthlyAccountStatuses) { var dictionary = new Dictionary <string, double>(); accountCategories.Add(new MonthAndYear((int)status.Year, (int)status.Month), dictionary); foreach (var category in status.Categories.Values) { dictionary.Add(category.Name, category.Amount); } } return(accountCategories); }
private Dictionary <MonthAndYear, Ledger> CreateMonthlyLedgers(Dictionary <MonthAndYear, IncomeExpensesAndTax> monthlyIncomeExpensesAndTax, MonthlyAccountCategorySums monthlyAccountCategorySums) { var monthlyLedgers = new Dictionary <MonthAndYear, Ledger>(); foreach (var pair in monthlyIncomeExpensesAndTax) { var monthAndYear = pair.Key; var incomeExpensesAndTax = pair.Value; var income = pair.Value.Income; var expenses = pair.Value.Expenses; var tax = pair.Value.Tax; var ownPension = monthlyAccountCategorySums.GetOwnPensionSavings(monthAndYear); var summedFortunes = monthlyAccountCategorySums.GetFortunesWithoutPension(monthAndYear); var values = new Ledger { Income = income, IncomeWithoutTaxAndPension = income - tax - ownPension, Expenses = expenses, ExpensesWithoutTax = expenses - tax, Tax = tax, OwnPension = ownPension, Fortune = summedFortunes, FortuneIncrease = monthlyAccountCategorySums.GetFortune(monthAndYear), InvestmentIncrease = monthlyAccountCategorySums.GetInvestment(monthAndYear), }; monthlyLedgers.Add(monthAndYear, values); } return(monthlyLedgers); }