public void DeleteTest() { using (var unitOfWork = new SqLiteUnitOfWork(_sqliteDtabase.Connect())) { var customerRepository = _repositoryFactory.CreateRepository<Customer>(); var shippingAddressRepository = _repositoryFactory.CreateRepository<ShippingAddress>(); var customer = new CustomerProxy(shippingAddressRepository) { Id = 1, Name = "Test User" }; unitOfWork.BeginTransaction(); customerRepository.Save(customer); unitOfWork.Commit(); int expectedCount = 1; int actualCount = customerRepository.Find().GetCount(); Assert.AreEqual(expectedCount, actualCount); unitOfWork.BeginTransaction(); customerRepository.Delete(customer); unitOfWork.Commit(); expectedCount = 0; actualCount = customerRepository.Find().GetCount(); Assert.AreEqual(expectedCount, actualCount); } }
public void SaveTest() { using (var unitOfWork = new SqLiteUnitOfWork(_sqliteDtabase.Connect())) { var customerRepository = _repositoryFactory.CreateRepository<Customer>(); var shippingAddressRepository = _repositoryFactory.CreateRepository<ShippingAddress>(); var customer = new CustomerProxy(shippingAddressRepository) { Id = 1, Name = "Test User" }; unitOfWork.BeginTransaction(); customerRepository.Save(customer); unitOfWork.Commit(); const int expectedCount = 1; int actualCount = customerRepository.Find().GetCount(); Assert.AreEqual(expectedCount, actualCount); const string expectedCustomerName = "ModyfiedName"; customer.Name = expectedCustomerName; unitOfWork.BeginTransaction(); customerRepository.Save(customer); unitOfWork.Commit(); string actualName = customerRepository.GetById(customer.Id).Name; Assert.AreEqual(expectedCustomerName, actualName); } }