Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert.IsInstanceOf passes on value null #178

Closed
LarsCelie opened this issue May 9, 2017 · 7 comments
Closed

Assert.IsInstanceOf passes on value null #178

LarsCelie opened this issue May 9, 2017 · 7 comments
Assignees
Labels
Help-Wanted The issue is up-for-grabs, and can be claimed by commenting Type: Bug

Comments

@LarsCelie
Copy link
Contributor

Description

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

@LarsCelie
Copy link
Contributor Author

LarsCelie commented 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 AbhitejJohn added Type: Bug Help-Wanted The issue is up-for-grabs, and can be claimed by commenting labels May 9, 2017
@AbhitejJohn
Copy link
Contributor

Thanks @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
Copy link
Contributor Author

You can assign me as well, trying to fix it.

LarsCelie added a commit to LarsCelie/testfx that referenced this issue May 9, 2017
@AbhitejJohn
Copy link
Contributor

Great. Thanks @LarsCelie .

@LarsCelie
Copy link
Contributor Author

@AbhitejJohn Pull Request is up.

@AbhitejJohn
Copy link
Contributor

Thanks a bunch @LarsCelie . Had a few small comments. Will merge it soon after.

@AbhitejJohn
Copy link
Contributor

Merged. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help-Wanted The issue is up-for-grabs, and can be claimed by commenting Type: Bug
Projects
None yet
Development

No branches or pull requests

2 participants