开发者

NUnit.Framework.Assert.IsInstanceOfType() is obsolete

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(Cl开发者_Python百科assName), variableName);

would become:

Assert.IsInstanceOf(typeof(ClassName), variableName);


From the NUnit documentation the IsInstanceOf method is a generic method so you would use this:

Assert.IsInstanceOf<ClassName>(variableName);


For completeness: if you use the constraint model:

Assert.That(variableName, Is.InstanceOf<ClassName>());

or your test class inherits AssertionHelper:

Expect(variableName, InstanceOf<ClassName>());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜