NUnit.Framework.Assert.IsInstanceOfType() 已过时
我目前正在阅读Professional Enterprise .NET 并且我在一些示例程序中注意到了这个警告:
'NUnit.Framework.Assert.IsInstanceOfType(System.Type, object)' is obsolete
现在我可能已经回答了我自己的问题,但是,要解决这个警告,是否只需将 Assert.IsInstanceOfType() 替换为 Assert.IsInstanceOf() 即可?例如:
Assert.IsInstanceOfType(typeof(ClassName), variableName);
将变为:
Assert.IsInstanceOf(typeof(ClassName), variableName);
I'm currently reading the book Professional Enterprise .NET and I've noticed this warning in some of the example programs:
'NUnit.Framework.Assert.IsInstanceOfType(System.Type, object)' is obsolete
Now I may have already answered my own question but, to fix this warning is it simply a case of replacing Assert.IsInstanceOfType() with Assert.IsInstanceOf()? For example this:
Assert.IsInstanceOfType(typeof(ClassName), variableName);
would become:
Assert.IsInstanceOf(typeof(ClassName), variableName);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自 NUnit 文档
IsInstanceOf 方法是一个通用方法,因此您可以使用以下方法:
From the NUnit documentation the
IsInstanceOf
method is a generic method so you would use this:为了完整性:如果您使用约束模型:
或您的测试类继承
AssertionHelper
:For completeness: if you use the constraint model:
or your test class inherits
AssertionHelper
: