public void ShouldKnowToInstantiateContext() { var dbSet = new Mock<IDbSet<Book>>(); var dbContext = new Mock<PukuDbContext>(); dbContext.Setup(ctx => ctx.GetDbSet<Book>()).Returns(dbSet.Object); var efRepo = new TestRepository(); Assert.IsNull(efRepo.GetContextInstance()); efRepo.DoStuffThatUsesContextPropery(); Assert.IsNotNull(efRepo.GetContextInstance()); }