Skip to content

Commit 37b24ad

Browse files
committed
Add failing test re: lazy evaluation of It.Is predicates
1 parent 6c7e7a1 commit 37b24ad

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/Moq.Tests/Regressions/IssueReportsFixture.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3688,6 +3688,35 @@ public virtual void SecondCall()
36883688

36893689
#endregion
36903690

3691+
#region 1217
3692+
3693+
public class Issue1217
3694+
{
3695+
[Fact]
3696+
public void It_Is_predicates_are_evaluated_lazily()
3697+
{
3698+
var patternKey = "";
3699+
var exeKey = "";
3700+
3701+
var mock = new Mock<ISettingsService>();
3702+
mock.Setup(x => x.GetSetting(It.Is<string>(y => y == patternKey))).Returns(() => patternKey);
3703+
mock.Setup(x => x.GetSetting(It.Is<string>(y => y == exeKey))).Returns(() => exeKey);
3704+
3705+
patternKey = "foo";
3706+
exeKey = "bar";
3707+
3708+
Assert.Equal("foo", mock.Object.GetSetting(patternKey));
3709+
Assert.Equal("bar", mock.Object.GetSetting(exeKey));
3710+
}
3711+
3712+
public interface ISettingsService
3713+
{
3714+
string GetSetting(string key);
3715+
}
3716+
}
3717+
3718+
#endregion
3719+
36913720
#region 1225
36923721

36933722
public class Issue1225

0 commit comments

Comments
 (0)