You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assert.IsInstanceOfType succeeds when value is null, while the MSDN specifies it should throw an error.
AssertFailedException : 'value is null or expectedType is not found in the inheritance hierarchy of value.' https://msdn.microsoft.com/en-us/library/ms243733.aspx
Steps to reproduce
Create a standard .net core test project from visual studio 2017, and create a dummy class. then use the following method: public void TestMethod1() { Assert.IsInstanceOfType(null, typeof(Dummy)); }
Expected behavior
The test should throw AssertFailedException and fail
Actual behavior
The test passes
Environment
Windows Server 2016,
MSTest.Framework version 1.1.11 and 1.1.17
MSTest.TestAdapter version 1.1.11 and 1.1.17
When i cloned testfx, i was able to reproduce this as well. [TestMethod] public void InstanceOfTypeShouldFailWhenValueIsNull() { // Assert.IsInstanceOfType(null, typeof(AssertTests)); FrameworkV2::Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsInstanceOfType(null, typeof(AssertTests)); }
the commented out line would fail if ran, and the frameworkv2 version will succeed.
Activity
LarsCelie commentedon May 9, 2017
When i cloned testfx, i was able to reproduce this as well.
[TestMethod] public void InstanceOfTypeShouldFailWhenValueIsNull() { // Assert.IsInstanceOfType(null, typeof(AssertTests)); FrameworkV2::Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsInstanceOfType(null, typeof(AssertTests)); }the commented out line would fail if ran, and the frameworkv2 version will succeed.
AbhitejJohn commentedon May 9, 2017
Thanks Lars Celie (@LarsCelie) for filing this. It looks like we are missing a check here. Marked this as an up-for-grabs issue - its a small change.
LarsCelie commentedon May 9, 2017
You can assign me as well, trying to fix it.
fix microsoft#178 InstanceOfType on null value
AbhitejJohn commentedon May 9, 2017
Great. Thanks Lars Celie (@LarsCelie) .
LarsCelie commentedon May 10, 2017
Abhitej John (@AbhitejJohn) Pull Request is up.
AbhitejJohn commentedon May 10, 2017
Thanks a bunch Lars Celie (@LarsCelie) . Had a few small comments. Will merge it soon after.
AbhitejJohn commentedon May 10, 2017
Merged. Thanks.
Fix for issue microsoft#175 (microsoft#178)