寻找一个允许模拟静态方法的C#模拟框架 [英] looking for a C# mocking framework that allows mocking static methods
本文介绍了寻找一个允许模拟静态方法的C#模拟框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要快速学习一个模拟框架,该框架允许模拟静态方法并为用C#编写的应用程序编写测试用例.您会推荐哪种框架?
i am required to quickly learn a mocking framework that allows mocking static methods and write test cases for an application written in C#. which framework would you recommend?
推荐答案
您可以使用以下框架进行操作:
You can do it using the following frameworks:
- Typemock隔离器
- JustMock
- 摩尔(您只能对方法进行存根,不能对方法进行存根断言他们.)
- Typemock Isolator
- JustMock
- Moles (You can only stub the methods, you can't assert them).
使用隔离器伪造静态方法的示例:
Example of faking a static method using Isolator:
Isolate.WhenCalled(() => MyClass.MethodReturningZero()).WillReturn(1);
免责声明-我在Typemock工作
这篇关于寻找一个允许模拟静态方法的C#模拟框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文