Exemple #1
0
        public void CupOfCoffee_ShouldSaveFifteenThousandDollars()
        {
            //$4 cup of coffee equals $20 a week
            var expensesService          = new ExpensesService(20);
            var amountSavedByNotSpending = expensesService.CalculateWeeklyExpenses();

            Assert.AreEqual(15040, amountSavedByNotSpending);
        }
        private static void CalculateExpensesOver10Years()
        {
            Console.WriteLine("*** Calculating Expesnses ***");
            Console.WriteLine("*** The following calculation assumes a 7% growth over 10 years. ***");

            Console.WriteLine("Is the following expense a monthly (M), or weekly (W) expense?");
            var expenseType = Console.ReadLine().ToUpper();

            if (expenseType != "W" && expenseType != "M")
            {
                return;
            }

            Console.WriteLine("Please enter the recurring expense amount");
            var expenseAmount = decimal.Parse(Console.ReadLine());

            var expensesService = new ExpensesService(expenseAmount);
            var amountSaved     = expenseType == "M" ?
                                  expensesService.CalculateMonthlyExpenses() :
                                  expensesService.CalculateWeeklyExpenses();

            Console.WriteLine($"If you invested your ${expenseAmount} instead, you would save ${amountSaved} after 10 years!");
        }