使用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