예제 #1
0
 public void ThrowsArgumentNullExceptionForNullExpression()
 {
     using (var dbContext = new TestDbContextContainer())
     {
         using (var repository = new DbContextCustomerRepository(dbContext))
         {
             ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => repository.GetAll().Include(null));
         }
     }
 }
예제 #2
0
            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 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);
                    }
                }
            }
예제 #4
0
            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 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));
         }
     }
 }