Пример #1
0
        public void TestToString()
        {
            Money money1 = new Money("EUR");
            Money money2 = new Money("DLR");

            Assert.AreEqual("Money\nCurrency: EUR", money1.ToString());
            Assert.AreEqual("Money\nCurrency: DLR", money2.ToString());
        }
Пример #2
0
        public void TestToString()
        {
            ExpenseType type = new ExpenseType("AAA", "aaa");
            Money money1 = new Money("EUR");
            Payment pay1 = new Payment(money1, 15);
            DateTime date = new DateTime(2012, 12, 21, 15, 30, 00);
            Expense exp = new Expense(type, pay1, date, "AAA");


            Assert.AreEqual("Expense:\nDescription: AAA\nType: AAA - aaa\nPayment: Payment: Money\nCurrency: EUR\nAmount: 15\nDate: 21/12/2012 15:30:00", exp.ToString());
        }
Пример #3
0
        public void TestRegisterExpense()
        {
            ExpenseController ec = new ExpenseController();
            ExpenseType type = new ExpenseType("AAA", "aaa");
            Money money1 = new Money("EUR");
            Payment pay1 = new Payment(money1, 15);
            DateTime date = new DateTime(2012, 12, 21, 15, 30, 00);
            ec.RegisterExpense(type, pay1, date, "AAA");
        
            List<Expense> list = PersistenceFactory.GetFactory().GetRepository().GetExpenseRepository().All();

            Assert.AreEqual("Expense:\nDescription: AAA\nType: AAA - aaa\nPayment: Payment: Money\nCurrency: EUR\nAmount: 15\nDate: 21/12/2012 15:30:00", list[0].ToString());
        }
Пример #4
0
        public void TestToString()
        {
            Money money1 = new Money("EUR");
            Payment pay1 = new Payment(money1, 15);
            Assert.AreEqual("Payment: Money\nCurrency: EUR\nAmount: 15", pay1.ToString());

            DebitCard dc1 = new DebitCard("AAA", "123A", "Me", new DateTime(2013, 07, 1), 157568);
            Payment pay2 = new Payment(dc1, 53.5);
            Assert.AreEqual("Payment: Debit Card\nCard Name: AAA\nCard Number: 157568\nOwner: Me\nBank: 123A\nValidity: 2013/7\nAmount: 53,5", pay2.ToString());

            CreditCard cc1 = new CreditCard("AA", "hi", "Me", new DateTime(2012, 12, 1), 1165131, 15);
            Payment pay3 = new Payment(cc1, 125);
            Assert.AreEqual("Payment: Credit Card\nCard Name: AA\nCard Number: 1165131\nOwner: Me\nBank: hi\nValidity: 2012/12\nLimit: 15\nAmount: 125", pay3.ToString());
        }
Пример #5
0
        public void TestGetExpensesLastMonth()
        {
            ExpenseController ec = new ExpenseController();
            ExpenseType type = new ExpenseType("AAA", "aaa");
            Money money1 = new Money("EUR");
            Payment pay1 = new Payment(money1, 15);
            DateTime date = new DateTime(2012, 12, 21, 15, 30, 00);
            ec.RegisterExpense(type, pay1, date, "AAA");

            DateTime date1 = DateTime.Now;
            ec.RegisterExpense(type, pay1, date1, "BBB");

            List<Expense> list = ec.GetExpensesFromLastMonth();
            Assert.AreEqual(String.Format("Expense:\nDescription: BBB\nType: AAA - aaa\nPayment: Payment: Money\nCurrency: EUR\nAmount: 15\nDate: {0}", date1), list[0].ToString());
        }
Пример #6
0
        public void TestViewBalance()
        {
            IncomeController ic = new IncomeController();
            IncomeType typeI = new IncomeType("AAA", "aaa");
            DateTime dateI = new DateTime(2012, 12, 21, 15, 30, 00);
            ic.RegisterIncome(typeI, dateI, 25, "AAA");

            ExpenseController ec = new ExpenseController();
            ExpenseType typeE = new ExpenseType("AAA", "aaa");
            Money moneyE = new Money("EUR");
            Payment payE = new Payment(moneyE, 15);
            DateTime dateE = new DateTime(2012, 12, 21, 15, 30, 00);
            ec.RegisterExpense(typeE, payE, dateE, "AAA");

            BalanceController bc = new BalanceController();
            double actual = bc.CalculateBalance();
            Assert.AreEqual(10, actual);
        }
Пример #7
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);
        }
Пример #8
0
        public void TestGetWeekStats()
        {
            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");

            double amount1 = ec.GetWeekStats();
            Assert.AreEqual(-15, amount1);

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

            double amount2 = ec.GetWeekStats();
            Assert.AreEqual(5, amount2);
        }
        /// <summary>
        /// The controller method to create the money
        /// </summary>
        /// <param name="currency">the currency of the money</param>
        public void CreateMoney(string currency)
        {
            Money mc = new Money(currency);

            PersistenceFactory.GetFactory().GetRepository().GetPaymentMethodRepository().Save(mc);
        }