You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using nested properties, it seems that Verify() is behaving as if Verifiable() was applied on the auto-generated properties.
The issue appeared in 4.14.
public class Tests
{
[Test]
public void Test1()
{
var mock = new Mock<IClassA>();
mock.Setup(x => x.Items.Count).Returns(1);
mock.Setup(x => x.Method()).Verifiable();
mock.Object.Method();
//Expected to pass
//Passes in 4.13, but fails in 4.14 with "IClassA x => x.Items: This setup was not matched."
mock.Verify();
}
}
public interface IClassA
{
public IList<string> Items { get; set; }
public void Method();
}
The text was updated successfully, but these errors were encountered:
killergege
changed the title
MockRepository.Verify() fails on items not explicitely marked a Verifiable()
Verify() fails on items not explicitely marked a Verifiable()
Oct 13, 2020
Thanks for reporting, @killergege. Yes, it's definitely related to #1018, or more precisely, to the automatic recursion algorithm that Moq uses for verification, which leads to quite a few unintuitive situations like this one.
I'm still investigating ways to give up recursive verification as safely as possible. It's quite a puzzle, so I'm afraid this is going to take some time.
I think the issue is similar to #1018
When using nested properties, it seems that Verify() is behaving as if Verifiable() was applied on the auto-generated properties.
The issue appeared in 4.14.
To reproduce:
Solution : https://github.com/killergege/moq_issue1073
The text was updated successfully, but these errors were encountered: