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

Matcher should always work with the whole expression, including Convert #56

Merged
merged 1 commit into from
Sep 26, 2013

Conversation

svick
Copy link
Contributor

@svick svick commented Sep 18, 2013

Without this change, the following code doesn't work correctly,
because the passed in long is compared against int.

interface IFoo
{
    string M(long l);
}

var mock = new Mock<IFoo>(MockBehavior.Strict);
mock.Setup(x => x.M(int.Parse("2"))).Returns("OK");
var result = mock.Object.M(2L);

This commit is based on a SO question that asked about this.

@svick
Copy link
Contributor Author

svick commented Sep 18, 2013

Also, I'm not sure about the way it is decided whether the expression is evaluated lazily or not. Why should int.Parse("2") be lazy, but 0 + int.Parse("2") shouldn't?

@kzu
Copy link
Member

kzu commented Sep 18, 2013

I assume all tests pass with this change?

@kzu
Copy link
Member

kzu commented Sep 18, 2013

Also, we won't take a pull request for a fix that doesn't have a corresponding test repro that failed previously and now passes.

There is an IssueReportsFixture.cs file to keep those tests isolated.

Thanks!

Without this change, the following code doesn't work correctly,
because the passed in long is compared against int.

interface IFoo
{
    string M(long l);
}

var mock = new Mock<IFoo>(MockBehavior.Strict);
mock.Setup(x => x.M(int.Parse("2"))).Returns("OK");
var result = mock.Object.M(2L);
@svick
Copy link
Contributor Author

svick commented Sep 26, 2013

Yes, all unit tests pass for me.

And I have added unit test for this.

kzu added a commit that referenced this pull request Sep 26, 2013
Matcher should always work with the whole expression, including Convert
@kzu kzu merged commit 7e0b14f into devlooped:master Sep 26, 2013
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

Successfully merging this pull request may close these issues.

None yet

2 participants