示例#1
0
 /// <summary>
 /// The main constructor of the income type
 /// </summary>
 /// <param name="description">income description</param>
 /// <param name="date">income date</param>
 /// <param name="amount">income amount</param>
 /// <param name="incomeType">income type</param>
 public Income(string description, DateTime date, double amount, IncomeType incomeType)
 {
     this.description = description;
     this.date = date;
     this.amount = amount;
     this.incomeType = incomeType;
 }
        public void TestToString()
        {
            IncomeType expType1 = new IncomeType("AAA", "aaa");
            IncomeType expType2 = new IncomeType("A1B1", "testes");

            Assert.AreEqual("AAA - aaa", expType1.ToString());
            Assert.AreEqual("A1B1 - testes", expType2.ToString());
        }
示例#3
0
        public void TestToString()
        {
            IncomeType type = new IncomeType("AAA", "aaa");
            DateTime date = new DateTime(2012, 12, 21, 15, 30, 00);
            Income inc = new Income("AAA", date, 25, type);

            Assert.AreEqual("Income:\nDescription: AAA\nType: AAA - aaa\nAmount: 25\nDate: 21/12/2012 15:30:00", inc.ToString());
        }
示例#4
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());
        }
示例#5
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);
        }
        /// <summary>
        /// The method that will share data between ui, model and persistance
        /// </summary>
        /// <param name="key">the key of income type</param>
        /// <param name="description">the description of income type</param>
        public void RegisterIncomeType(string key, string description)
        {
            IncomeType incT = new IncomeType(key, description);

            PersistenceFactory.GetFactory().GetRepository().GetIncomeTypeRepository().Save(incT);
        }
        /// <summary>
        /// The method that will save an income
        /// </summary>
        /// <param name="type">income type</param>
        /// <param name="date">income date</param>
        /// <param name="amount">income amount</param>
        /// <param name="description">income description</param>
        public void RegisterIncome(IncomeType type, DateTime date, double amount, string description)
        {
            Income inc = new Income(description, date, amount, type);

            PersistenceFactory.GetFactory().GetRepository().GetIncomeRepository().Save(inc);
        }
 /// <summary>
 /// Saves an income type object in repository
 /// </summary>
 /// <param name="incT">the object of income type</param>
 public void Save(IncomeType incT)
 {
     incomeTypes.Add(incT);
 }