lundi 8 août 2016

Entity framework 6 with Autofac unit testing DataContext

I'm using Entity Framework 6 with Autofac for Dependency injection.

Here is my database context wrapper code:

public interface IOliveDataContext
{
    OlivesHealthEntities Context { get; }
}

Here is its implementation:

public class OliveDataContext : IOliveDataContext
{
    public OlivesHealthEntities Context => new OlivesHealthEntities();
}

I wonder if there is anyway to wrap the default context with in-memory database connection for unit testing or I have to connect to an other database to do the test.

Can anyone help me please ?

P/s : I've read some tuts about unit testing with EF6, they always write context interfaces for this, its different from my current app implementation.

Aucun commentaire:

Enregistrer un commentaire