NUnit.Framework.Assert.IsInstanceOfType() is obsolete

Malice picture Malice · Apr 17, 2010 · Viewed 21k times · Source

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);

Answer

Mark Byers picture Mark Byers · Apr 17, 2010

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

Assert.IsInstanceOf<ClassName>(variableName);