2013-06-04 27 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