Ejemplo n.º 1
0
        public void TestAddTransaction()
        {
            da = new CDataAccess(fileName);
            Assert.IsNotNull(da);
            da.ReadAllTransations();
            Assert.That(da.Transactions.Count == 2);
            AddTransaction();

            da.ReadAllTransations();

            Assert.That(da.Transactions.Count == 3);
            Assert.That(da.Transactions[2].Description == "Unit Test");
            Assert.That(da.Transactions[2].ID == 2);
            Assert.That(da.Transactions[2].AccountName == "Savings");
            Assert.That(da.Transactions[2].Balanced == true);
            Assert.That(da.Transactions[2].TransactionDate == DateTime.Parse("3/1/2008"));
            Assert.That(da.Transactions[2].Transactions.Count == 2);
            Assert.That(da.Transactions[2].Transactions[0].Amount == 1234);
            Assert.That(da.Transactions[2].Transactions[0].TransactionBudget == "Other");
            Assert.That(da.Transactions[2].Transactions[0].Categories.Count == 1);
            Assert.That(da.Transactions[2].Transactions[0].Categories[0] == "Cat1");
            Assert.That(da.Transactions[2].Transactions[1].Amount == 4321);
            Assert.That(da.Transactions[2].Transactions[1].TransactionBudget == "Other1");
            Assert.That(da.Transactions[2].Transactions[1].Categories.Count == 2);
            Assert.That(da.Transactions[2].Transactions[1].Categories[0] == "Cat2");
            Assert.That(da.Transactions[2].Transactions[1].Categories[1] == "Cat3");

            DeleteTransaction();
        }
Ejemplo n.º 2
0
        public void TestUpdateAccount()
        {
            da = new CDataAccess(fileName);
            Assert.IsNotNull(da);
            da.ReadAllAccounts();

            AddAccount();
            Assert.That(da.Accounts.Count == 3);
            Assert.That(da.Accounts[0].AccountName == "CreditCard");
            Assert.That(da.Accounts[1].AccountName == "Current");
            Assert.That(da.Accounts[2].AccountName == "Savings");

            Account ac = new Account();

            ac.AccountName = "ISA";

            da.UpdateAccount(da.Accounts[2], ac);

            da.ReadAllAccounts();
            Assert.That(da.Accounts.Count == 3);
            Assert.That(da.Accounts[0].AccountName == "CreditCard");
            Assert.That(da.Accounts[1].AccountName == "Current");
            Assert.That(da.Accounts[2].AccountName == "ISA");

            da.DeleteAccount(ac);
        }
Ejemplo n.º 3
0
        public void TestReadTransactions()
        {
            da = new CDataAccess(fileName);
            Assert.IsNotNull(da);
            da.ReadAllTransations();
            Assert.That(da.Transactions.Count == 2);

            Assert.That(da.Transactions[0].Description == "Spent at Sainsburys");
            Assert.That(da.Transactions[0].AccountName == "CreditCard");
            Assert.That(da.Transactions[0].Balanced == true);
            Assert.That(da.Transactions[0].ID == 0);
            Assert.That(da.Transactions[0].TransactionDate == DateTime.Parse("1/1/2007"));
            Assert.That(da.Transactions[0].Transactions.Count == 2);
            Assert.That(da.Transactions[0].Transactions[0].Amount == 1250);
            Assert.That(da.Transactions[0].Transactions[0].TransactionBudget == "food");
            Assert.That(da.Transactions[0].Transactions[0].Categories.Count == 2);
            Assert.That(da.Transactions[0].Transactions[0].Categories[0] == "food");
            Assert.That(da.Transactions[0].Transactions[0].Categories[1] == "crisps");
            Assert.That(da.Transactions[0].Transactions[1].Amount == 1325);
            Assert.That(da.Transactions[0].Transactions[1].TransactionBudget == "excess");
            Assert.That(da.Transactions[0].Transactions[1].Categories.Count == 1);
            Assert.That(da.Transactions[0].Transactions[1].Categories[0] == "music");

            Assert.That(da.Transactions[1].Description == "Spent at Tesco");
            Assert.That(da.Transactions[1].ID == 1);
            Assert.That(da.Transactions[1].AccountName == "Current");
            Assert.That(da.Transactions[1].Balanced == false);
            Assert.That(da.Transactions[1].TransactionDate == DateTime.Parse("2/1/2007"));
            Assert.That(da.Transactions[1].Transactions.Count == 1);
            Assert.That(da.Transactions[1].Transactions[0].Amount == 1023);
            Assert.That(da.Transactions[1].Transactions[0].TransactionBudget == "food");
            Assert.That(da.Transactions[1].Transactions[0].Categories.Count == 1);
            Assert.That(da.Transactions[1].Transactions[0].Categories[0] == "junk");
        }
Ejemplo n.º 4
0
        public void TestReadAccounts()
        {
            da = new CDataAccess(fileName);
            Assert.IsNotNull(da);
            da.ReadAllAccounts();

            Assert.That(da.Accounts.Count == 2);
            Assert.That(da.Accounts[0].AccountName == "CreditCard");
            Assert.That(da.Accounts[1].AccountName == "Current");
        }
Ejemplo n.º 5
0
        public void TestAddAccount()
        {
            da = new CDataAccess(fileName);
            Assert.IsNotNull(da);
            da.ReadAllAccounts();

            AddAccount();
            Assert.That(da.Accounts.Count == 3);
            Assert.That(da.Accounts[0].AccountName == "CreditCard");
            Assert.That(da.Accounts[1].AccountName == "Current");
            Assert.That(da.Accounts[2].AccountName == "Savings");
            DeleteAccount();
        }
Ejemplo n.º 6
0
        public void TestUpdateTransaction()
        {
            da = new CDataAccess(fileName);
            Assert.IsNotNull(da);
            da.ReadAllTransations();
            AddTransaction();
            Assert.That(da.Transactions.Count == 3);

            AccountTransactions trans = new AccountTransactions();

            trans.Description     = "Unit Test";
            trans.ID              = 2;
            trans.AccountName     = "Savings";
            trans.Balanced        = true;
            trans.TransactionDate = DateTime.Parse("4/1/2008");
            Transaction t1 = new Transaction();

            t1.Amount            = 1235;
            t1.TransactionBudget = "Other";
            t1.Categories.Add("Cat1");
            Transaction t2 = new Transaction();

            t2.Amount            = 5321;
            t2.TransactionBudget = "Other1";
            t2.Categories.Add("Cat2");
            t2.Categories.Add("Cat4");
            trans.Transactions.Add(t1);
            trans.Transactions.Add(t2);

            da.UpdateTransaction(trans);
            da.ReadAllTransations();

            Assert.That(da.Transactions.Count == 3);
            Assert.That(da.Transactions[2].Description == "Unit Test");
            Assert.That(da.Transactions[2].ID == 2);
            Assert.That(da.Transactions[2].Balanced == true);
            Assert.That(da.Transactions[2].AccountName == "Savings");
            Assert.That(da.Transactions[2].TransactionDate == DateTime.Parse("4/1/2008"));
            Assert.That(da.Transactions[2].Transactions.Count == 2);
            Assert.That(da.Transactions[2].Transactions[0].Amount == 1235);
            Assert.That(da.Transactions[2].Transactions[0].TransactionBudget == "Other");
            Assert.That(da.Transactions[2].Transactions[0].Categories.Count == 1);
            Assert.That(da.Transactions[2].Transactions[0].Categories[0] == "Cat1");
            Assert.That(da.Transactions[2].Transactions[1].Amount == 5321);
            Assert.That(da.Transactions[2].Transactions[1].TransactionBudget == "Other1");
            Assert.That(da.Transactions[2].Transactions[1].Categories.Count == 2);
            Assert.That(da.Transactions[2].Transactions[1].Categories[0] == "Cat2");
            Assert.That(da.Transactions[2].Transactions[1].Categories[1] == "Cat4");
            DeleteTransaction();
        }
Ejemplo n.º 7
0
        public void TestDeleteBudget()
        {
            da = new CDataAccess(fileName);
            Assert.IsNotNull(da);
            da.ReadAllBudgets();

            AddBudget();
            DeleteBudget();

            da.ReadAllBudgets();

            Assert.That(da.Budgets.Count == 3);
            Assert.That(da.Budgets[0].BudgetName != "Other");
            Assert.That(da.Budgets[1].BudgetName != "Other");
            Assert.That(da.Budgets[2].BudgetName != "Other");
        }
Ejemplo n.º 8
0
        public void TestAddBudget()
        {
            da = new CDataAccess(fileName);
            Assert.IsNotNull(da);
            da.ReadAllBudgets();

            AddBudget();

            da.ReadAllBudgets();

            Assert.That(da.Budgets.Count == 4);
            Assert.That(da.Budgets[3].Amount == 7500);
            Assert.That(da.Budgets[3].BudgetName == "Other");
            Assert.That(da.Budgets[3].BudgetPeriod == Period.annual);

            DeleteBudget();
        }
Ejemplo n.º 9
0
        public void TestDeleteTransaction()
        {
            da = new CDataAccess(fileName);
            Assert.IsNotNull(da);
            da.ReadAllTransations();
            AddTransaction();
            Assert.That(da.Transactions.Count == 3);

            da.ReadAllTransations();
            DeleteTransaction();

            da.ReadAllTransations();

            Assert.That(da.Transactions.Count == 2);
            Assert.That(da.Transactions[0].ID != 2);
            Assert.That(da.Transactions[1].ID != 2);
        }
Ejemplo n.º 10
0
        public void TestReadBudgets()
        {
            da = new CDataAccess(fileName);
            Assert.IsNotNull(da);
            da.ReadAllBudgets();
            Assert.That(da.Budgets.Count == 3);
            Assert.That(da.Budgets[0].Amount == 0);
            Assert.That(da.Budgets[0].BudgetName == "excess");
            Assert.That(da.Budgets[0].BudgetPeriod == Period.none);

            Assert.That(da.Budgets[1].Amount == 25);
            Assert.That(da.Budgets[1].BudgetName == "food");
            Assert.That(da.Budgets[1].BudgetPeriod == Period.weekly);

            Assert.That(da.Budgets[2].Amount == 705);
            Assert.That(da.Budgets[2].BudgetName == "mortgage");
            Assert.That(da.Budgets[2].BudgetPeriod == Period.monthly);
        }
Ejemplo n.º 11
0
        public void TestUpdateBudget()
        {
            da = new CDataAccess(fileName);
            Assert.IsNotNull(da);
            da.ReadAllBudgets();
            AddBudget();

            Budget budg = new Budget();

            budg.Amount       = 7600;
            budg.BudgetName   = "Other";
            budg.BudgetPeriod = Period.none;

            da.UpdateBudget(budg);
            da.ReadAllBudgets();

            Assert.That(da.Budgets.Count == 4);
            Assert.That(da.Budgets[3].Amount == 7600);
            Assert.That(da.Budgets[3].BudgetName == "Other");
            Assert.That(da.Budgets[3].BudgetPeriod == Period.none);

            DeleteBudget();
        }
Ejemplo n.º 12
0
 public void TestOpenFile()
 {
     da = new CDataAccess(fileName);
     Assert.IsNotNull(da);
 }