public void UpdatesEntity() { using (var dbContext = new TestDbContextContainer()) { using (var repository = new DbContextCustomerRepository(dbContext)) { EFTestHelper.CreateCustomerIfNotAlreadyExists(301); var customer1 = repository.GetByKey(301); customer1.Name = "John Doe"; repository.Update(customer1); dbContext.SaveChanges(); var customer2 = repository.GetByKey(301); Assert.IsNotNull(customer2); Assert.AreEqual("John Doe", customer2.Name); } } }
public void UpdatesEntity() { using (var dbContext = new TestDbContextContainer()) { using (var repository = new DbContextCustomerRepository(dbContext)) { EFTestHelper.CreateCustomerIfNotAlreadyExists(301); var customer1 = repository.GetByKey(301); customer1.Name = "John Doe"; repository.Update(customer1); dbContext.SaveChanges(); var customer2 = repository.GetByKey(301); Assert.IsNotNull(customer2); Assert.AreEqual("John Doe", customer2.Name); } } }
public void ThrowsArgumentNullExceptionForNullEntity() { using (var dbContext = new TestDbContextContainer()) { using (var repository = new DbContextCustomerRepository(dbContext)) { ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => repository.Update(null)); } } }
public void ThrowsArgumentNullExceptionForNullEntity() { using (var dbContext = new TestDbContextContainer()) { using (var repository = new DbContextCustomerRepository(dbContext)) { ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => repository.Update(null)); } } }