vendredi 25 novembre 2016

Mocking DbContext Entry

I am testing a function that contains this code:

void FunctionToTest() {
  if (context.Entry(entity).State == EntityState.Detached)
        {
            // [...]
        }

  // [...]
}

For this reason I created my own test context that works well but I am not able to mock DbEntityEntry<TEntity> Entry<TEntity>(TEntity entity) as the DbEntityEntry class has a constructor that requires an internal class.

Any solution for this?

Aucun commentaire:

Enregistrer un commentaire