I\'m using ASP.NET MVC 4 with Entity Framework 5. I have model classes and Entity Maps to map existing tables to those model classes. All this is setup fine and works great.
Your ExampleService class is expecting IUnitOfWork, that means you just need another IUnitOfWork that is a Mock and its GetRepository() method will return an IRepository Mock.
For example (not really a Mock but In-Memory stub):
public InMemoryRepository : IRepository where T : class
{
........
}
public InMemoryUnitOfWork : IUnitOfWork
{
public IRepository GetRepository() where TEntity : class
{
return new InMemoryRepository();
}
}
Then:
public IEnumerable GetAll()
{
// Create Unit Of Work object
IUnitOfWork uow = new InMemoryUnitOfWork();
// Create Service with Unit Of Work
ExampleService service = new ExampleService(uow);
return service.getAll();
}