-
Notifications
You must be signed in to change notification settings - Fork 7
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
[GH-135] - Detecting received like methods used in Received.InOrder #136
Conversation
Pull Request Test Coverage Report for Build 377
💛 - Coveralls |
@@ -0,0 +1,59 @@ | |||
# NS5001 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dtchepak as discussed nsubstitute/NSubstitute#604 (comment)
feel free to suggest better documentation and diagnostic id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor doc suggestions. Happy to merge as is. 👍
documentation/rules/NS5001.md
Outdated
// Correct: | ||
Received.InOrder(() => | ||
{ | ||
sub..Bar(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sub.Bar();
(one .
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
documentation/rules/NS5001.md
Outdated
|
||
## Rule description | ||
|
||
A violation of this rule occurs when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion:
A violation of this rule occurs when any of the following are used inside
Received.InOrder
callback:
Received()
ReceivedWithAnyArgs()
DidNotReceive()
DidNotReceiveWithAnyArgs()
Calls within
Received.InOrder
are already checked to ensure they were received in the expected order. Individual received-like assertions should be moved outside theReceived.InOrder
block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
For example: | ||
|
||
````c# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be 3 ticks instead of 4? "```"? Never mind, just saw this renders fine with 4. I've just always used 3 😂
sub..Bar(); | ||
}) | ||
```` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, move the received-like method outside of
Received.InOrder
block:// Incorrect: Received.InOrder(() => { sub.Baz(); sub.DidNotReceive().Bar(); }) // Correct: Received.InOrder(() => { sub.Baz(); }) sub.DidNotReceive().Bar();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I aggregated these here: #135 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, copy-pasted your version
3539311
to
675c135
Compare
Closes #135