MSTEST0023: Do not negate boolean assertions
Property | Value |
---|---|
Rule ID | MSTEST0023 |
Title | Do not negate boolean assertions |
Category | Usage |
Fix is breaking or non-breaking | Non-breaking |
Enabled by default | Yes |
Default severity | Info |
Introduced in version | 3.4.0 |
Cause
This rule raises a diagnostic when a call to Assert.IsTrue
or Assert.IsFalse
contains a negated argument.
Rule description
MSTest assertion library contains opposite APIs that makes it easier to test true
and false
cases. It is recommend to use the right API for the right case as it is improving readability and also provides better information in case of failure.
How to fix violations
When negating argument in a Assert.IsTrue
call, you should use Assert.IsFalse
.
When negating argument in a Assert.IsFalse
call, you should use Assert.IsTrue
.
When to suppress warnings
Do not suppress warnings from this rule.
Feedback
https://aka.ms/ContentUserFeedback.
Kommer snart: I hele 2024 udfaser vi GitHub-problemer som feedbackmekanisme for indhold og erstatter det med et nyt feedbacksystem. Du kan få flere oplysninger under:Indsend og få vist feedback om