-
-
Notifications
You must be signed in to change notification settings - Fork 798
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
SetupSequence() is not thread-safe #467
Comments
SetupSequence()
is not thread-safe
Hi @icalvo, and thanks for reporting this. Would you like to attempt a fix? If so, please feel free to send a PR (against the Otherwise, I'll take a look at this sometime during the next couple of days. |
Note to self:
In order to make |
@icalvo - A new implementation of I'm actually fine with this, because it brings People might have relied on the previous (current) funky behaviour of Moq to first setup a default action or return value for an invocation, then partially override that default with a second sequence setup. Once the sequence is exhausted, invocations would default / fall back to the first setup. That will no longer work if the above PR gets merged. What's probably missing with the new behaviour is methods on sequences such as |
While this issue isn't solved I've used approach Haacked blogged about.
|
@icalvo, @rusanov-vladimir - I just published a pre-release version |
Hi, we are using 4.8.1 and issue it still persists |
Can you provide a minimal code example that reproduces the issue you're referring to? Otherwise it's a little hard to tell what precisely we're talking about. |
Sorry it's my fault. I was using it wrong seems _client.SetupSequence() is not suitable for this _client.Setup(c=>c.Get(2)).Throws(); |
SetupSequence()
is not thread-safe. If two threads call the mock, it can return the same value more than once. The following failing test demonstrate it:The text was updated successfully, but these errors were encountered: