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

Don't require inner mock setups to be matched #1075

Merged
merged 3 commits into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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