2013-06-04 29 views

回答

5

您可能在:

Assert.IsType<TypeNotRegisteredException>(exception); 

让我知道这是否接近你正在寻找。

2

我在想你在问什么是InstanceOfType断言的等价物,而不是相当于Assert.That。后者只是一个更好的语法,使您能够像英语一样阅读您的断言。

InstanceOfType断言中的xUnit相当于是IsType

Assert.IsType<TypeNotRegisteredException>(exception); 

注意,NUnit的当量,着实:

Assert.IsInstanceOf<TypeNotRegisteredException>(exception); 

(旧IsInstanceOfType断言已被弃用 - http://www.nunit.org/index.php?p=typeAsserts&r=2.5.1