我知道如何写这个使用NUnit,相当于Nunit的断言是什么?在Xunit中呢?
Assert.That(exception, Is.InstanceOfType(typeof(TypeNotRegisteredException)));
我怎么能写使用的xUnit同样的事情,为的xUnit没有Assert.That
。
我知道如何写这个使用NUnit,相当于Nunit的断言是什么?在Xunit中呢?
Assert.That(exception, Is.InstanceOfType(typeof(TypeNotRegisteredException)));
我怎么能写使用的xUnit同样的事情,为的xUnit没有Assert.That
。
您可能在:
Assert.IsType<TypeNotRegisteredException>(exception);
让我知道这是否接近你正在寻找。
我在想你在问什么是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)