标签: c# xunit.net
是否可以将Assert.DoesNotThrow与特定的异常类型一起使用?
Assert.DoesNotThrow
例如,我如何验证方法调用没有专门抛出NullReferenceExceptions,但它可能抛出我不关心的NotSupportedException。 ?
NullReferenceExceptions
NotSupportedException
答案 0 :(得分:5)
xUnit中有一个模式空值检查。
var ex = Record.Exception(...); Assert.Null(ex);
有点晚了;但是,希望它可以帮助你:)。