Esempio n. 1
0
            public void ReturnsEntityWhenTableContainsEntity()
            {
                using (var dbContext = new TestDbContextContainer())
                {
                    using (var repository = new DbContextCustomerRepository(dbContext))
                    {
                        EFTestHelper.CreateCustomerIfNotAlreadyExists(1);

                        var customer = repository.First();

                        Assert.IsNotNull(customer);
                        Assert.AreEqual(1, customer.Id);
                    }
                }
            }
            public void ReturnsEntityWhenTableContainsEntity()
            {
                using (var dbContext = new TestDbContextContainer())
                {
                    using (var repository = new DbContextCustomerRepository(dbContext))
                    {
                        EFTestHelper.CreateCustomerIfNotAlreadyExists(1);

                        var customer = repository.First();

                        Assert.IsNotNull(customer);
                        Assert.AreEqual(1, customer.Id);
                    }
                }
            }
Esempio n. 3
0
 public void ThrowsExceptionWhenTableDoesNotContainEntity()
 {
     using (var dbContext = new TestDbContextContainer())
     {
         using (var repository = new DbContextCustomerRepository(dbContext))
         {
             ExceptionTester.CallMethodAndExpectException <InvalidOperationException>(() => repository.First(x => x.Id == 999));
         }
     }
 }
 public void ThrowsExceptionWhenTableDoesNotContainEntity()
 {
     using (var dbContext = new TestDbContextContainer())
     {
         using (var repository = new DbContextCustomerRepository(dbContext))
         {
             ExceptionTester.CallMethodAndExpectException<InvalidOperationException>(() => repository.First(x => x.Id == 999));
         }
     }
 }