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

Setups with Nullable types on strict mocks no longer match null #184

Closed
pkpjpm opened this issue Jun 23, 2015 · 3 comments
Closed

Setups with Nullable types on strict mocks no longer match null #184

pkpjpm opened this issue Jun 23, 2015 · 3 comments

Comments

@pkpjpm
Copy link
Contributor

pkpjpm commented Jun 23, 2015

Here's an example of the problem:

        var mock = new Mock<ISimpleInterface>(MockBehavior.Strict);
        mock.Setup(x => x.SimpleMethod(It.IsAny<Guid?>()));
        mock.Object.SimpleMethod(null);

This used to work in Moq 4.2.1502.0911, but in 4.2.1506.2016 it fails. Workaround is to setup null explicitly instead of the Nullable Guid:

        mock.Setup(x => x.SimpleMethod(null));
@IharBury
Copy link
Contributor

The problem is in cc45976 because of Nullable<T> is value type

@kzu
Copy link
Contributor

kzu commented Jun 25, 2015

So this should also be fixed by the merged PR #185. if so, plz close after verifying :)

@stakx
Copy link
Contributor

stakx commented Jun 18, 2017

The test at the top of this thread works fine in recent versions of Moq, so I am closing this.

@stakx stakx closed this as completed Jun 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants