title: Unit Testing Entity Framework Repository
body: <p>I am working with TDD and all is going well.  When I get to my actual Repository though I don't know how to test this.</p>
  
  <p>Consider the code below - this is what I know I want to write but how do I tackle this in a test first way without doing integration testing.</p>
  
  <pre><code>public class UserDb : IUserDb
  {
      public void Add(User user)
      {
          using (var context = new EfContext())
          {
              context.Users.Add(user);
  
              context.SaveChanges();
          }
      }
  }
  </code></pre>
  
  <p>The link below by forsvarir is what I want to put as an answer.  How I can do that?</p>
  
  <p><a href="http://romiller.com/2012/02/14/testing-with-a-fake-dbcontext/" rel="nofollow">http://romiller.com/2012/02/14/testing-with-a-fake-dbcontext/</a></p>