如何在PrivateObject中模拟辅助函数

时间:2014-08-20 07:01:47

标签: c# unit-testing visual-studio-2013

使用visual studio的内置测试工具测试类的私有方法时,可以创建一个PrivateObject实例,如下所示:

PrivateObject classUnderTest = new PrivateObject(typeof(ClassUnderTest);

是否有可能在该PrivateObject中有一个方法返回设置值用于测试目的,如下所示:

classUserTest.getNumberFromFile = 5; // Pseudo-code to have getNumberFromFile() to return 5 when it is called by a another method in the same class 

0 个答案:

没有答案