Skip to content

Commit

Permalink
Merge pull request #56 from svick/master
Browse files Browse the repository at this point in the history
Matcher should always work with the whole expression, including Convert
  • Loading branch information
kzu committed Sep 26, 2013
2 parents 453f479 + 8297c6a commit 7e0b14f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Source/MatcherFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,19 @@ public static IMatcher CreateMatcher(Expression expression, bool isParams)
if (attr != null)
{
var matcher = attr.CreateMatcher();
matcher.Initialize(expression);
matcher.Initialize(originalExpression);
return matcher;
}
else if (staticMatcherMethodAttr != null)
{
var matcher = new MatcherAttributeMatcher();
matcher.Initialize(expression);
matcher.Initialize(originalExpression);
return matcher;
}
else
{
var matcher = new LazyEvalMatcher();
matcher.Initialize(expression);
matcher.Initialize(originalExpression);
return matcher;
}
}
Expand Down
20 changes: 20 additions & 0 deletions UnitTests/Regressions/IssueReportsFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1889,5 +1889,25 @@ public interface IServiceContract
#endif

#endregion

#region Matcher should work with Convert

public class MatcherConvertFixture
{
public interface IFoo
{
string M(long l);
}

[Fact]
public void MatcherDoesNotIgnoreConvert()
{
var mock = new Mock<IFoo>(MockBehavior.Strict);
mock.Setup(x => x.M(int.Parse("2"))).Returns("OK");
Assert.Equal("OK", mock.Object.M(2L));
}
}

#endregion
}
}

0 comments on commit 7e0b14f

Please sign in to comment.