diff --git a/src/TestFramework/MSTest.Core/Assertions/Assert.cs b/src/TestFramework/MSTest.Core/Assertions/Assert.cs index 7ee7c491fd..25176aecf7 100644 --- a/src/TestFramework/MSTest.Core/Assertions/Assert.cs +++ b/src/TestFramework/MSTest.Core/Assertions/Assert.cs @@ -1754,11 +1754,17 @@ public static void IsNotInstanceOfType(object value, Type wrongType, string mess /// public static void IsNotInstanceOfType(object value, Type wrongType, string message, params object[] parameters) { - if (wrongType == null || value == null) + if (wrongType == null) { HandleFail("Assert.IsNotInstanceOfType", message, parameters); } + // Null is not an instance of any type. + if (value == null) + { + return; + } + var elementTypeInfo = value.GetType().GetTypeInfo(); var expectedTypeInfo = wrongType.GetTypeInfo(); if (expectedTypeInfo.IsAssignableFrom(elementTypeInfo)) diff --git a/test/UnitTests/MSTest.Core.Unit.Tests/Assertions/AssertTests.cs b/test/UnitTests/MSTest.Core.Unit.Tests/Assertions/AssertTests.cs index 4e84da6e23..dc64211915 100644 --- a/test/UnitTests/MSTest.Core.Unit.Tests/Assertions/AssertTests.cs +++ b/test/UnitTests/MSTest.Core.Unit.Tests/Assertions/AssertTests.cs @@ -278,7 +278,6 @@ public void InstanceOfTypeShouldPassOnHigherInstance() public void InstanceNotOfTypeShouldFailWhenValueIsNull() { Action action = () => TestFrameworkV2.Assert.IsNotInstanceOfType(null, typeof(AssertTests)); - ActionUtility.ActionShouldThrowExceptionOfType(action, typeof(TestFrameworkV2.AssertFailedException)); } [TestMethod]