title: Mocking or faking DbEntityEntry or creating a new DbEntityEntry
body: <p>Following on the heels of my other <a href="https://stackoverflow.com/questions/5007100/mocking-dbcontext-sett">question about mocking DbContext.Set</a> I've got another question about mocking EF Code First.</p>
  
  <p>I now have a method for my update that looks like:</p>
  
  <pre><code>if (entity == null)
      throw new ArgumentNullException("entity");
  
  Context.GetIDbSet&lt;T&gt;().Attach(entity);
  Context.Entry(entity).State = EntityState.Modified;
  Context.CommitChanges();
  
  return entity;
  </code></pre>
  
  <p>Context is an interface of my own DbContext.</p>
  
  <p>The problem I'm running in to is, how do I handle the</p>
  
  <p><code>Context.Entry(entity).State</code>.</p>
  
  <p>I've stepped through this code and it works when I have a real live DbContext as the implementation of my Context interface.  But when I put my fake context there, I don't know how to handle it.</p>
  
  <p>There is no constructor for a DbEntityEntry class, so I can't just create a new one in my fake context.</p>
  
  <p>Has anyone had any success with either mocking or faking DbEntityEntry in your CodeFirst solutions?</p>
  
  <p>Or is there a better way to handle the state changes?</p>