If you have a system that has multiple types of object contexts. For Eg: BillingObjectContext, HumanResourceObjectContext etc. All derive from ObjectContext but ObjectContext Class does not implement any specific interface like IObjectContext. How would you apply DI/IoC in case of multiple types of ObjectContext say using Ninject?
views:
183answers:
1
+1
A:
If you must depend on it in a test, you have to mock it. Here's a sample; it's not much harder than implementing an interface. See also TDD improvements in EF 4.
Craig Stuntz
2010-01-14 17:13:39
+1 for the stuff about mocking it out but what about Injecting appropriate ObjectContexts where needed ?
Perpetualcoder
2010-01-14 17:31:05
That's what DI/IoC is for. Make your repository take the context as a constructor argument.
Craig Stuntz
2010-01-14 19:40:06