"Type"类型的扩展方法为null

lio*_*art 0 .net c#

我为System.Type创建了一个扩展方法,我想对该方法进行单元测试.这可能吗?谢谢!

public static bool GetFoo(this Type self)
{
     if (self == null)
     {
          throw new ArgumentNullException("this")
     }
     ...
}
Run Code Online (Sandbox Code Playgroud)

小智 11

断言((Type)null).GetFoo()抛出.

  • @Maarten:我很长一段时间没有去过枪战.不确定我是否仍然拥有它,我所有的时间都在沙龙里... (4认同)