Example #1
0
        public void TestRegisterIncome()
        {
            IncomeController ic = new IncomeController();

            IncomeType type = new IncomeType("AAA", "aaa");
            DateTime date = new DateTime(2012, 12, 21, 15, 30, 00);

            ic.RegisterIncome(type, date, 25, "AAA");

            List<Income> incs = ic.GetAllIncomes();
            Assert.AreEqual("Income:\nDescription: AAA\nType: AAA - aaa\nAmount: 25\nDate: 21/12/2012 15:30:00", incs[0].ToString());
        }
Example #2
0
        /// <summary>
        /// The specific method to the register income ui
        /// </summary>
        private void ShowRegisterIncome()
        {
            IncomeController ic = new IncomeController();

            IncomeType type = GetIncomeType();
            DateTime date = GetDate();
            Console.WriteLine("Insert a description");
            string description = Console.ReadLine();

            double amount;

            Console.WriteLine("Insert Amount:");
            while (!double.TryParse(Console.ReadLine(), out amount)) ;

            ic.RegisterIncome(type, date, amount, description);
        }
Example #3
0
        /// <summary>
        /// Method that will list all of incomes in repository
        /// </summary>
        private void List()
        {
            IncomeController ic = new IncomeController();

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

            List<Income> incomes = ic.GetAllIncomes().ToList();
            int i = 0;
            foreach (Income item in incomes)
            {
                Console.WriteLine(i);
                Console.WriteLine(item);
                Console.WriteLine("---\n");
                i++;
            }
        }
        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);
        }
Example #5
0
        /// <summary>
        /// The method that will choose a income type in the repository
        /// </summary>
        /// <returns>A income type</returns>
        private IncomeType GetIncomeType()
        {
            IncomeType type = null;
            IncomeController ic = new IncomeController();
            IncomeTypeUI itUI = new IncomeTypeUI();

            int numIncType = ic.GetIncomeTypeRepositorySize();
            if (numIncType == 0)
            {
                Console.WriteLine("Create a new Income Type");
                itUI.ShowRegisterIncomeType();
                type = ic.GetLastExpenseType();
            }
            else
            {
                int option = 999;
                Console.WriteLine("Choose an Income Type");
                itUI.List();

                do
                {
                    if (int.TryParse(Console.ReadLine(), out option))
                    {
                        type = ic.GetIncomeType(option);
                    }
                    else
                    {
                        option = -1;
                    }
                } while (option < 0 || option > numIncType);
            }

            return type;
        }