Skip to content

RafaelSalguero/DbContextMock

Repository files navigation

DbContextMock

##In memory mock EntityFramework 6 DbContext!

Populate your fake database:

static Guid id = Guid.NewGuid();
...
using (var C = DbContextMock.Persistent<Db>(id))
{
    C.Customer.Add(new Customer
    {
        Name = "Rafa",
        Id = 5,
        Email = "rafaelsalgueroiturrios@gmail.comn"
    });
    
    C.SaveChanges();
}

Query your fake database, full support for async queries too!

using (var C = DbContextMock.Persistent<Db>(id))
{
    return await C.Where(x => x.Id == 5).Select(x => x.Name).ToListAsync();
}

About

In memory mock EntityFramework 6 DbContext

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages