public void CanSerialize() { var budgetType = BudgetType.Income_Salary; var budgetTypeString = BudgetCategoryFactory.Serialize(budgetType); Assert.That(budgetTypeString, Is.EqualTo("Income:Salary")); }
public void CanDeSerialize() { var budgetTypeString = "Income:Salary"; var budgetType = BudgetCategoryFactory.DeSerialize(budgetTypeString); Assert.That(budgetType, Is.EqualTo(BudgetType.Income_Salary)); }
public void CanDeserializeMainCategoryOnly() { var budgetTypeString = "Income"; var budgetType = BudgetCategoryFactory.DeSerialize(budgetTypeString); Assert.That(budgetType, Is.EqualTo(BudgetType.Income)); }
public void CanSerializeMainCategoryOnly() { var budgetType = BudgetType.Income; var budgetTypeString = BudgetCategoryFactory.Serialize(budgetType); Assert.That(budgetTypeString, Is.EqualTo("Income")); }
public virtual string Serialize() { var categoryString = BudgetCategoryFactory.Serialize(Category.BudgetType); var amountString = Amount.ToString(); return($"{categoryString},{amountString},{Label}"); }
public BudgetEntry(double amount, string label, BudgetType budgetType) { Amount = amount; this.Label = label; BudgetType = budgetType; this.Category = BudgetCategoryFactory.GetBudgetCategory(budgetType); }
static void GetCommonParameters(ref string[] components, out double amount, out string label, out BudgetType budgetType) { budgetType = BudgetCategoryFactory.DeSerialize(components[0]); amount = double.Parse(components[1]); label = components[2]; components = components.Skip(3).ToArray(); }
private static void AddExpenses(Report report) { Console.WriteLine("When prompted, enter aggregated expenses..."); var expenseCategories = BudgetCategoryFactory.GetExpenseCategories(); foreach (var category in expenseCategories) { var amount = GetPromptedAmount(category); var budgetType = BudgetCategoryFactory.GetBudgetType(category, ""); report.AddExpenditure(budgetType, amount); } }
private static void AddIncome(Report report) { Console.WriteLine("When prompted, enter income..."); var incomeCategories = BudgetCategoryFactory.GetIncomeCategories(); foreach (var category in incomeCategories) { var prompt = string.IsNullOrWhiteSpace(category) ? "Unspecified Income" : category; var amount = GetPromptedAmount(prompt); var budgetType = BudgetCategoryFactory.GetBudgetType("Income", category); report.AddExpenditure(budgetType, amount); } }
public void IncomeCategoriesContainSubCategoriesFromSpecialIncomeMainCategory() { int numCategories = 0; foreach (BudgetType budgetType in Enum.GetValues(typeof(BudgetType))) { var components = budgetType.ToString().Split('_'); if (components[0] == "Income") { numCategories += 1; } } var mainCategories = BudgetCategoryFactory.GetIncomeCategories(); Assert.That(mainCategories.Count, Is.EqualTo(numCategories)); }
public void ExpenseCategoriesContainParentCategories() { int numParents = 0; foreach (BudgetType budgetType in Enum.GetValues(typeof(BudgetType))) { var components = budgetType.ToString().Split('_'); if (components.Length == 1 && components[0] != "Income") { numParents += 1; } } var mainCategories = BudgetCategoryFactory.GetExpenseCategories(); Assert.That(mainCategories.Count, Is.EqualTo(numParents)); }
public void GetBudgetTypeHandlesEmptySubCategories() { var budgetType = BudgetCategoryFactory.GetBudgetType("Income", ""); Assert.That(budgetType, Is.EqualTo(BudgetType.Income)); }
public void CanGetBudgetTypeForValidCategories() { var budgetType = BudgetCategoryFactory.GetBudgetType("Income", "Misc"); Assert.That(budgetType, Is.EqualTo(BudgetType.Income_Misc)); }