Faking DbContext
Posted by: K. Scott Allen,
on 01 Jun 2011 |
View original | Bookmarked: 0 time(s)
I like Kzu's take on building unit-testable domain models with EF code first. I've been playing around with some of the same ideas myself, which center around simple context abstractions. public interface IDomainContext
{
IQueryable<Restaurant> Restaurants { get; }
IQueryable<Recipe> Recipes { get; }
int SaveChanges();
void Save<T>(T entity);
void Delete<T>(T entity);
}
It's easy to mock an IDbContext, but I wanted a fake. My first brute force implementation...