开发者

Using Rhino mocks with Unity application block

开发者 https://www.devze.com 2023-03-31 09:47 出处:网络
I am trying to mock UnityContainer for writing test harness in an asp.net mvc 2 application. are开发者_运维百科 there any examples available ?

I am trying to mock UnityContainer for writing test harness in an asp.net mvc 2 application.

are开发者_运维百科 there any examples available ?

Thanks


Simple Answer: Don't. The container should be invisible to your controllers or anything else you need to test. If it is leaking into your code then you're probably using it incorrectly and should think about redesigning your code.

That said, if you really, really need to then reference the UnityContainerBase abstract class in your code instead of the UnityContainer class itself. You'll still be able to pass in the normal UnityContainer object when your application is running, but you'll also be able to get RhinoMocks to generate a mock of UnityContainerBase to pass in when you are running unit tests.

0

精彩评论

暂无评论...
验证码 换一张
取 消