寻找一个允许模拟静态方法的C#模拟框架

6

我需要快速学习一种可以模拟静态方法并编写C#应用程序的测试用例的模拟框架。你会推荐哪个框架?

1个回答

13
你可以使用以下框架来完成:
  1. Typemock Isolator
  2. JustMock
  3. Moles(你只能对方法进行桩操作,而不能对其进行断言)。

使用Isolator伪造静态方法的示例:

Isolate.WhenCalled(() => MyClass.MethodReturningZero()).WillReturn(1);

声明 - 我在 Typemock 工作


4
只链接自己的产品会被扣分,可以在这里找到JustMock:http://www.telerik.com/products/mocking.aspx和Moles:http://research.microsoft.com/en-us/projects/moles/。 - Michiel van Oosterhout

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接