寻找.NET嘲弄的框架,允许有不依赖注入测试方法 [英] Looking for .NET mocking framework that allows testing methods having non-injected dependencies

查看:165
本文介绍了寻找.NET嘲弄的框架,允许有不依赖注入测试方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道是否有任何嘲弄的框架,允许测试方法contaning方法调用没有注入到被测试的方法和它的类相关的类的实例:

I'm wondering if there's any mocking framework that allows testing methods contaning method calls to dependent class instances not injected to the tested method or its class:

void MethodToTest()
{
    ....
    DependentClass dc = new DependentClass();
    dc.Foo();
    ....
}

在code以上,我想嘲笑调用美孚()。我想这可以通过使用code注射液嘲弄的框架来实现? 预先感谢您的提示。

In the code above I would like to mock the call to Foo(). I guess it could be accomplished by a mocking framework using code injection? Thank you in advance for tips.

推荐答案

我从来没有使用过,但根据一些文章的应该是能够做到这一点。

I have never used it but based on some articles Moles should be able to do that.

MSDN 说:

鼹鼠类型使用了一个code强大的迂回框架   探查的API拦截来电   依赖类和重定向   调用一个假的对象

Mole types use a powerful detouring framework that uses code profiler APIs to intercept calls to dependency classes and redirects the calls to a fake object

这篇关于寻找.NET嘲弄的框架,允许有不依赖注入测试方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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