我正在尝试使用以下私有方法测试私有
public class Test
{
private bool PVTMethod1(Guid[] Parameter1)
{
return true;
}
private bool PVTMethod2(RandomClass[] Parameter2)
{
return true;
}
}
public class RandomClass
{
public int Test { get; set; }
}
使用以下测试方法
[TestClass]
public TestClass1
{
[TestMethod]
public void SomUnitTest()
{
Test _helper = new Test();
PrivateObject obj = new PrivateObject(_helper);
bool response1 = (bool)obj.Invoke("PVTMethod1", new Guid[0]);
bool response2 = (bool)obj.Invoke("PVTMethod2", new RandomClass[0]);
}
}
第二次调用失败并出现 System.MissingMethodException。
使用复杂类型作为数组参数时似乎找不到方法