I have read a lot about unit testing the Entity Framework.
I am posting this question because I simply saw there are too many solutions to this problem !
Here are the solutions I found:
- Use an expensive commercial tool called TypeMock (mentioned here).
- Use an alpha open-source tool called Effort (mentioned here).
- Use Repository Pattern and Rhino Mock. test the isolated LINQ queries against a real database (mentioned here).
Some problems with some of the methods stated here:
- You cannot get around the fact that you need to supply an ObjectContext with a connection string
- If you fake the ObjectContext - some things that might work in unit testing won't work in production (like running functions inside the queries)
Some of the articles I read were from 3-4 years ago.
Does any one here have any experience with this issue and can help me go for the best solution ?
Just to make things clear: my business logic functions aren't just simple functions like 'GetUserById'.
Some of the functions include accessing objects, that have relationships to other objects. (for example - I can add a user + departmant + office in the same function).