如何测试私有静态泛型方法?内部结构对我的测试项目可见。如何测试这些方法?
internal class Foo {
// Non-static. This works!
private T TestThisMethod1<T>(T value) {
Console.WriteLine("Called TestThisMethod1");
return value;
}
// Static. Can't get this to work!
private static T TestThisMethod2<T>(T value) {
Console.WriteLine("Called TestThisMethod2");
return value;
}
// Static. Can't get this to work!
private static void TestThisMethod3<T>(T value) {
Console.WriteLine("Called TestThisMethod3");
}
// Static. Can't get this to work!
private static void TestThisMethod4<T, T2>(T value, T2 value2) {
Console.WriteLine("Called TestThisMethod4");
}
}
Run Code Online (Sandbox Code Playgroud)
第一个例子有效。它不是静态的。这是来自https://msdn.microsoft.com/en-us/library/bb546207.aspx的示例。
[TestMethod]
public void PrivateStaticGenericMethodTest() …Run Code Online (Sandbox Code Playgroud)