public void ThrowsArgumentNullExceptionForNullExpression() { using (var dbContext = new TestDbContextContainer()) { using (var repository = new DbContextCustomerRepository(dbContext)) { ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => repository.GetAll().Include(null)); } } }
public void IncludesEntitiesUsingExpression() { using (var dbContext = new TestDbContextContainer()) { using (var repository = new DbContextCustomerRepository(dbContext)) { EFTestHelper.CreateCustomerIfNotAlreadyExists(42); var existingCustomer = repository.GetAll().Include(x => x.DbContextOrders).FirstOrDefault(); Assert.IsNotNull(existingCustomer); } } }
public void ReturnsCorrectEntities() { using (var dbContext = new TestDbContextContainer()) { using (var repository = new DbContextCustomerRepository(dbContext)) { EFTestHelper.CreateCustomerIfNotAlreadyExists(100); EFTestHelper.CreateCustomerIfNotAlreadyExists(101); EFTestHelper.CreateCustomerIfNotAlreadyExists(102); var customers = repository.GetAll().ToList(); Assert.IsTrue(customers.Count >= 3); } } }
public void ThrowsArgumentNullExceptionForNullExpression() { using (var dbContext = new TestDbContextContainer()) { using (var repository = new DbContextCustomerRepository(dbContext)) { ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => repository.GetAll().Include(null)); } } }