-
-
Notifications
You must be signed in to change notification settings - Fork 794
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
VerifySet fails on non-trivial property setter #430
Comments
@TimothyHayes, thanks for reporting this bug. I've added this issue to a fairly long list (see #414) of problems caused by To understand what this component does, take a look at the signature of the A quick hacky fix would be possible in your case. Instead of checking the last invocation, Moq could be changed to check the last property setter invocation. I cannot say whether such a fix would break less tests than it fixes, which is why I am reluctant to apply that fix. A better, but still somewhat hacky fix might be to change the recorder to only record calls made directly from the verify lambda. This might be worth following up. To really solve your issue, |
Thank you for pursuing. I have another potential work-around. The |
Sorry, did not understand close and comment. |
I'm not sure is it the same issue or not (or event is it Moq issue), but decided to post here.
|
Well, I don't know whats wrong with my code. I cleared out my test project and remained with 8 tests. Got the same error. Run with "dotnet test ... --no-build" fails almost always, but sometimes all tests passed. I tried run dll with "xunit.console.exe ..." and all tests passed always. I tried 20 times - nothing. It brings me to thought that may be bug in this link dotnet -> xunit. |
@Alezis: It would've been easier if you had posted that as a separate issue so there wouldn't be the risk of hijacking the OP's issue. I've just quickly glanced over your code, you have a very low timeout (1 millisecond) in there. Given that your tests sometimes pass and sometimes fail, I would suspect that the timeout might have something to do with it. If this timeout is honored at all, perhaps try increasing it to a higher value (such as 1 second). |
@stakx. I should apologize. I found that cache affects my tests. You are right, if I set this to 1 second or even more I could find bug more easily. From other view I would not rewrite my caching logic and improve code )). Anyway, I fixed everything. Tests pass. Should I delete my previous comments ? |
No, leave your posts as they are, that's OK. :) I would only ask that if you do need more assistance with the use of Moq in your code, then open a new issue. Glad you could fix the immediate problem! |
Closing this, this problem will be tracked in #414 (together with a couple other related issues). |
The test cases at the beginning of this issue reveal a regresion in current |
When I attempt to use a VerifySet on a property that refers to another property within the setter, Moq throws
Expression is not a property setter invocation.
Here is the sample class. Notice the use of the IsMale property within the Antlers setter:
Here are the unit tests. Each one throws the same Exception noted above:
I posted this problem on StackOverflow and received an explanation from user Jason Boyd. Check here for that link.
Can the VerifySet function be improved to allow for non-trivial property setters?
The text was updated successfully, but these errors were encountered: