Skip to content

Commit

Permalink
Merge pull request #1075 from stakx/inner-mock-setups
Browse files Browse the repository at this point in the history
Don't require inner mock setups to be matched
  • Loading branch information
stakx committed Oct 13, 2020
2 parents 40b78a8 + 0bd4403 commit 5b8fbc4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1

* Setup not triggered due to VB.NET transparently inserting superfluous type conversions into a setup expression (@InteXX, #1067)
* Nested mocks created by `Mock.Of<T>()` no longer have their properties stubbed since version 4.14.0 (@vruss, @1071)
* `Verify` fails for recursive setups not explicitly marked as `Verifiable` (@killergege, #1073)


## 4.14.6 (2020-09-30)
Expand Down
6 changes: 6 additions & 0 deletions src/Moq/InnerMockSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,11 @@ protected override void ResetCore()
{
this.InnerMock.MutableSetups.Reset();
}

protected override bool TryVerifySelf(out MockException error)
{
error = null;
return true;
}
}
}
24 changes: 24 additions & 0 deletions tests/Moq.Tests/Regressions/IssueReportsFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3488,6 +3488,30 @@ public void Property_set_up_with_Mock_Of_is_automatically_stubbed__manual_inner_

#endregion

#region 1073

public class Issue1073
{
[Fact]
public void Test()
{
var mock = new Mock<IClassA>();
mock.Setup(x => x.Items.Count).Returns(1); // not verifiable, but won't be invoked
mock.Setup(x => x.Method()).Verifiable(); // verifiable, and will be invoked

mock.Object.Method();

mock.Verify();
}
public interface IClassA
{
public IList<string> Items { get; set; }
public void Method();
}
}

#endregion

// Old @ Google Code

#region #47
Expand Down

0 comments on commit 5b8fbc4

Please sign in to comment.