public void CollectionInsertTest() { var customer = new Client {Name = "Customer-LazyLoad", Family = "CustomerA1"}; var ClientRepository = new ClientRepository(_unitOfWork); ClientRepository.Add(customer); var account1 = new Account {Client = customer, Balance = 10, OpendedDate = DateTime.Now}; var account2 = new Account {Client = customer, Balance = 100, OpendedDate = DateTime.Now}; customer.Accounts = new Collection<Account> {account1, account2}; _unitOfWork.Commit(); customer = ClientRepository.FindByID(customer.ClientID); Assert.AreEqual(2, customer.Accounts.Count); }
public void InsertDeleteAndUpdateTest() { var ClientRepository = new ClientRepository(_unitOfWork); Client customer = ClientRepository.FindByID(10); customer.Name = "Updated"; ClientRepository.Update(customer); var accountRepository = new AccountRepository(_unitOfWork); var accountList = accountRepository.GetCustomerAccounts(customer.ClientID); foreach (var account in accountList) { accountRepository.Remove(account); } _unitOfWork.Commit(); var deletedAccountList = accountRepository.GetCustomerAccounts(customer.ClientID); Assert.AreEqual(0, deletedAccountList.Count); }
public void LazyLoadTest() { var ClientRepository = new ClientRepository(_unitOfWork); Client customer = ClientRepository.FindByID(14); Assert.AreEqual(2, customer.Accounts.Count); }