简体   繁体   中英

TDD with Entity, mocking the generated Entity classes?

My apologies, I read this post:

TDD and ADO.NET Entity Framework

But I don't think it covers what I'm looking for and other similar questions seem unanswered. So, forgive me if this has already been answered.

I have an application that I'm writing. I've created some Entity classes. I want to mock this during unit testing as I believe MS's implementation is good enough to warrant skipping the testing of it. =-}

So, my first guess:

Take the generated ObjectContext-deriving class and generate an interface off of it for the read properties that return ObjectQuery and the Add methods (at this point I'm not worrying about the updating of existing objects, just reading). However, I quickly ran into problems during the testing as I couldn't easily get the ObjectQuery properties working nicely.

I saw The Wayward Weblog's post about doing something similiar to this but with Linq to SQL and it just begs the question, hasn't anyone figured out a better way to mock the Entity framework than this?!

Thanks!

Wait for EF v2.0 (a year maybe more) or switch to NHibernate. I have choosen the second option (not easy but full TDD support and no database limits).

So I take it there is no answer to this. Unfortunately, after doing lots of googling, I don't think the EF really supports a TDD approach to development, which is an absolute shame. Time to adopt nHibernate, it sounds like.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM