Exemple #1
0
        public void AddOwnerToBankAccount_Existing_Owner_Expect_ArgumentException_Test()
        {
            //IRepository<IBankAccount, int> repository = new BankAccountRepository();
            BankAccountController mgr = new BankAccountController(repository);

            ICustomer customer1 = new Customer(1, "Name", "Address", "Phone", "Email");

            IBankAccount account1 = mgr.CreateNewBankAccount(customer1);

            Assert.AreEqual(1, account1.Owners.Count);
            Assert.AreSame(customer1, account1.Owners[0]);

            Assert.AreEqual(1, customer1.BankAccounts.Count);
            Assert.AreSame(account1, customer1.BankAccounts[0]);

            try
            {
                mgr.AddOwnerToBankAccount(account1, customer1);
            }
            catch (ArgumentException)
            {
                Assert.AreEqual(1, account1.Owners.Count);
                Assert.AreSame(customer1, account1.Owners[0]);

                Assert.AreEqual(1, customer1.BankAccounts.Count);
                Assert.AreSame(account1, customer1.BankAccounts[0]);
            }
        }
Exemple #2
0
        public void RemoveOwnerFromBankAccount_Existing_Owner_Test()
        {
            //IRepository<IBankAccount, int> repository = new BankAccountRepository();
            BankAccountController mgr = new BankAccountController(repository);

            ICustomer customer1 = new Customer(1, "Name", "Address", "Phone", "Email");
            ICustomer customer2 = new Customer(2, "Name", "Address", "Phone", "Email");

            IBankAccount account1 = mgr.CreateNewBankAccount(customer1);
            IBankAccount account2 = mgr.CreateNewBankAccount(customer2);

            mgr.AddOwnerToBankAccount(account1, customer2);

            mgr.RemoveOwnerFromBankAccount(account1, customer2);

            Assert.AreEqual(1, account1.Owners.Count);
            Assert.AreSame(customer1, account1.Owners[0]);
        }