Modifying base collection throws System.InvalidOperationException
Consider:
var emails = new List<EmailQueueEntry>();
emails.Add(new EmailQueueEntry());
var mockSet = emails.AsQueryable().BuildMockDbSet();
emails.Add(new EmailQueueEntry());
var list= await mockSet.Object.ToListAsync();
This used to work fine in v5.0.1, but since upgrading our projects to .net6 and MockQueryable to 6.0.1 now throws System.InvalidOperationException : Collection was modified; enumeration operation may not execute on the ToListAsync call.
Seems to be a regression of this
Checked also with v7.0 does the same thing. I think it may be the method CreateAsyncMock method in MoqExtensions.cs added for v6.0.1 causing the issue.
Any updates on this one? I am having the same issue. However, changing ToListAsync to ToList solves the problem, so I also think there could be an issue with CreateAsyncMock.
Hello. Thanks for you contribution. Sorry for the late answer. Unfortunately I'm very busy at the moment. If you provide a pull request with fix of the issue I would be happy to include it to the next release. Please don't forget to cover the case by additional tests to minimize possibility of regressions for the future. Thanks for the understanding.
fixed in #74 Thanks @fischero19 Included to the release v7.0.1