コード例 #1
0
        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());
        }
コード例 #2
0
        public void TestAccountBalanceAllDeposits()
        {
            LeafAccount account = new LeafAccount("AC1");

            account.AddEntry(new Entry(EntryType.Deposit, 15.05M));
            account.AddEntry(new Entry(EntryType.Deposit, 67.32M));
            account.AddEntry(new Entry(EntryType.Deposit, 11.10M));
            account.AddEntry(new Entry(EntryType.Deposit, 112.35M));

            Assert.AreEqual(account.Entries.Count(), 4);
            Assert.AreEqual(account.Balance, 205.82M);
        }
コード例 #3
0
        public void CreateAccount()
        {
            IAccount account = null;

            if (string.IsNullOrWhiteSpace(OpeningBalance))
            {
                account = new LeafAccount(Name);
            }
            else
            {
                decimal openingBalance = decimal.Parse(OpeningBalance);
                account = new LeafAccount(Name, new Money(openingBalance));
            }
            _mainWindowViewModel.AddAccount(account);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public void TestDefaultAccountBalanceIsZero()
        {
            LeafAccount account = new LeafAccount("AC1");

            Assert.AreEqual(account.Balance, Money.Zero);
        }