MSTest的TestMethod的依赖注入 [英] MSTest TestMethod Dependency Injection

查看:1048
本文介绍了MSTest的TestMethod的依赖注入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是DI容器,我想要做的MSTest的(VS 2010)单元测试与容器解决实例。

I'm using a DI container and I want to do MSTest (VS 2010) unit tests with instances resolved from the container.

我想获得这些实例注入到我的TestMethod的,或至少是我的TestClass。这可能吗?

I'd like to get these instances injected into my TestMethod or at least my TestClass. Is this possible?

现在我TestMethods直接调用 container.Resolve< T>(XXX),我想preFER避免让自己的注入测试是比较现实的。

Right now my TestMethods directly call container.Resolve<T>(xxx) which I'd prefer to avoid so that my injection testing is more realistic.

任何人有这方面的经验?

Anyone have experience with this?

在此先感谢。

推荐答案

测试类的实例深深发生在的MSTest的框架,以便注入依赖到这将是一项艰巨的任务的内部类。

The instantiation of the test class happens deeply in the internal classes of the MSTest framework so injecting dependencies into it would be a challenging task.

这篇关于MSTest的TestMethod的依赖注入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆