I see one of the ways people test solutions based on EntityFramework (code first) is to create interface for their custom context that contains properties of type IDbSet (instead of DbSet). Then in unit tests they use InMemoryDbSets.
I'm new to EntityFramework and that seemed like great way to do it. But it doesn't work at all does it? When we are using InMemory DbSets we can create and run queries that use any of the properties of our entity objects. Even if those are calculated properties. But during runtime the same queries will throw "The specified type member 'PropertyName' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.".
So either I don't understand something (probably) or it is not possible to unit test at all if you are using custom context with IDbSets.
Ok I did a lot of research and seems that the only reasonable way (if You want to expose IDbSet) is to do integration testing. Just forget about unit testing it.
Ladislav Mrnka summarized it here very nicely. Fake DbContext of Entity Framework 4.1 to Test
Also I saw on Ayende's blog (http://ayende.com/) that this is the way he is doing it.