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]); }
public void RemoveOwnerFromBankAccount_NULL_Owner_Expect_ArgumentNullException_Test() { //IRepository<IBankAccount, int> repository = new BankAccountRepository(); BankAccountController mgr = new BankAccountController(repository); ICustomer customer1 = new Customer(1, "Name", "Address", "Phone", "Email"); ICustomer customer2 = null; IBankAccount account1 = mgr.CreateNewBankAccount(customer1); try { mgr.RemoveOwnerFromBankAccount(account1, customer2); Assert.Fail("removed NULL owner from bank account."); } catch (ArgumentNullException) { Assert.AreEqual(1, account1.Owners.Count); Assert.AreSame(customer1, account1.Owners[0]); Assert.AreEqual(1, customer1.BankAccounts.Count); Assert.AreSame(account1, customer1.BankAccounts[0]); } }