Esempio n. 1
0
        public void TestAccountsCannotBeDirectlyCyclical()
        {
            CompositeAccount ac1 = new CompositeAccount("AC1");
            CompositeAccount ac2 = new CompositeAccount("AC2");

            ac1.AddAccount(ac2);
            ac2.AddAccount(ac1);
        }
Esempio n. 2
0
        public void TestAccountsWithSameNameCannotShareParent()
        {
            CompositeAccount ac1 = new CompositeAccount("AC1");
            CompositeAccount ac2 = new CompositeAccount("ABC");
            CompositeAccount ac3 = new CompositeAccount("ABC");

            ac1.AddAccount(ac2);
            ac1.AddAccount(ac3);
        }
Esempio n. 3
0
        public void TestAccountOnlyAppearsOnceInHierarchy()
        {
            CompositeAccount ac1 = new CompositeAccount("A");
            CompositeAccount ac2 = new CompositeAccount("B");
            CompositeAccount ac3 = new CompositeAccount("C");

            ac1.AddAccount(ac3);
            ac2.AddAccount(ac3);
        }
Esempio n. 4
0
        public void TestRemoveAccount()
        {
            CompositeAccount ac1 = new CompositeAccount("A");
            CompositeAccount ac2 = new CompositeAccount("B");

            ac1.AddAccount(ac2);

            ac1.RemoveAccount(ac2);
            Assert.AreEqual(0, ac1.ChildAccounts.Count());
        }
Esempio n. 5
0
        public void TestAddAccount()
        {
            CompositeAccount ac1 = new CompositeAccount("A");
            CompositeAccount ac2 = new CompositeAccount("B");

            ac1.AddAccount(ac2);

            Assert.AreEqual(1, ac1.ChildAccounts.Count());
            Assert.AreEqual(ac2, ac1.ChildAccounts.FirstOrDefault());
        }
        public void TestAddAccount()
        {
            Person           person   = new Person();
            CompositeAccount account1 = new CompositeAccount("AC1");
            LeafAccount      account2 = new LeafAccount("AC2");

            person.AddAccount(account1);
            person.AddAccount(account2);

            Assert.AreEqual(2, person.Accounts.Count());
        }
Esempio n. 7
0
        public void TestAccountsWithSameNameCanExistInHierarchy()
        {
            CompositeAccount ac1 = new CompositeAccount("AC1");
            CompositeAccount ac2 = new CompositeAccount("ABC");
            CompositeAccount ac3 = new CompositeAccount("AC3");
            CompositeAccount ac4 = new CompositeAccount("ABC");

            ac1.AddAccount(ac2);
            ac2.AddAccount(ac3);
            ac3.AddAccount(ac4);
        }
        public void TestNetWorth()
        {
            Person           person   = new Person();
            CompositeAccount account1 = new CompositeAccount("AC1");
            LeafAccount      account2 = new LeafAccount("AC2", 200M);
            LeafAccount      account3 = new LeafAccount("AC3");
            LeafAccount      account4 = new LeafAccount("AC4");

            account1.AddAccount(account2);
            account1.AddAccount(account3);
            account1.AddAccount(account4);
            person.AddAccount(account1);


            account2.AddEntry(new Entry(EntryType.Deposit, 20.75M));
            account2.AddEntry(new Entry(EntryType.Withdrawal, 11.13M));

            account3.AddEntry(new Entry(EntryType.Deposit, 1220.67M));
            account3.AddEntry(new Entry(EntryType.Withdrawal, 654.44M));

            account4.AddEntry(new Entry(EntryType.Withdrawal, 110.98M));

            Assert.AreEqual(new Money(664.87M), person.NetWorth);
        }