Пример #1
0
        /// <summary>
        /// Method that will list all of expenses in repository
        /// </summary>
        private void List()
        {
            ExpenseController ec = new ExpenseController();

            Console.WriteLine(" === Expense List ===");

            List<Expense> expenses = ec.GetAllExpenses();
            int i = 0;
            foreach (Expense item in expenses)
            {
                Console.WriteLine(i);
                Console.WriteLine(item);
                Console.WriteLine("---\n");
                i++;
            }
        }
Пример #2
0
        public void TestSumExpenses()
        {
            ExpenseController ec = new ExpenseController();
            ExpenseType type = new ExpenseType("AAA", "aaa");
            Money money1 = new Money("EUR");
            Payment pay1 = new Payment(money1, 15);
            DateTime date = DateTime.Now;
            date.Subtract(new TimeSpan(5, 0, 0, 0));
            ec.RegisterExpense(type, pay1, date, "AAA");

            Payment pay2 = new Payment(money1, 20);
            DateTime date2 = DateTime.Now.Subtract(new TimeSpan(10, 0, 0, 0));
            ec.RegisterExpense(type, pay2, date2, "BBB");

            List<Expense> allExpenses = ec.GetAllExpenses();
            double sum = ec.SumExpenses(allExpenses);

            Assert.AreEqual(35, sum);
        }