Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Entity Framework more mockable than Linq2Sql?

I've found that Linq2Sql doesn't (Rhino) mock well, as the interfaces I need aren't there. Does EF generate code that's more mockable?

NOTE: I'm not mocking, yet, without interfaces, the next reader of this question may not have my bias.

EDIT: VS2008 / 3.5 for now.

like image 817
lance Avatar asked Nov 24 '25 00:11

lance


2 Answers

Entity Framework 1.0 is mockable: http://blogs.msdn.com/diego/archive/2008/03/03/unit-testing-your-entity-framework-domain-classes.aspx

It's not pretty, but it's possible. EF 4 is much improved over EF 1.0 in this regard.

like image 176
Dave Swersky Avatar answered Nov 25 '25 16:11

Dave Swersky


I would think that if, for example, you have Data Access Objects (DAOs) over your Linq2SQL objects they can implement intefaces and therefore work well with RhinoMocks.

like image 25
Joe Ratzer Avatar answered Nov 25 '25 15:11

Joe Ratzer