-
-
Notifications
You must be signed in to change notification settings - Fork 802
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
Method setup broken when specifying the same parameters in a different order in setup #252
Comments
This isn't dependent on having a generic interface, this simplified test case also shows the same issue: using Moq;
using Xunit;
public class MoqTest
{
[Fact]
public void MoqWorks()
{
var a = new MyClass();
var b = new MyClass();
var mock = new Mock<IDoStuff>();
mock.Setup(m => m.DoStuff(a, b)).Returns(1);
mock.Setup(m => m.DoStuff(b, a)).Returns(1);
Assert.Equal(1, mock.Object.DoStuff(a, b));
Assert.Equal(1, mock.Object.DoStuff(b, a));
}
public interface IDoStuff
{
int DoStuff(MyClass a, MyClass b);
}
public class MyClass { }
} It does seem related to the type of the arguments though, using
Strings also work, so it's not a reference type vs value type issue, but could be related to those types implementing IEquatable? |
This has to do with how hash code is calculated for |
…fferent order in setup (issue devlooped#252)
Fixed setup issues when specifying the same parameters in a different order (issue #252)
Great, thanks for fixing this @LeonidLevin! |
Code to reproduce:
Both asserts should pass but one fails as
DoStuff
returns the default value of 0.This was tested with Moq version 4.2.1510.2205.
The text was updated successfully, but these errors were encountered: