MSTEST0017: Assertion arguments should be passed in the correct order
Property | Value |
---|---|
Rule ID | MSTEST0017 |
Title | Assertion arguments should be passed in the correct order |
Category | Usage |
Fix is breaking or non-breaking | Non-breaking |
Enabled by default | Yes |
Default severity | Info |
Introduced in version | 3.4.0 |
There is a code fix | Yes |
Cause
This rule raises an issue when calls to Assert.AreEqual
, Assert.AreNotEqual
, Assert.AreSame
or Assert.AreNotSame
are following one or multiple of the patterns below:
actual
argument is a constant or literal valueactual
argument variable starts withexpected
,_expected
orExpected
expected
ornotExpected
argument variable starts withactual
actual
is not a local variable
Rule description
MSTest Assert.AreEqual
, Assert.AreNotEqual
, Assert.AreSame
and Assert.AreNotSame
expect the first argument to be the expected/unexpected value and the second argument to be the actual value.
Having the expected value and the actual value in the wrong order will not alter the outcome of the test (succeeds/fails when it should), but the assertion failure will contain misleading information.
How to fix violations
Ensure that that actual
and expected
/notExpected
arguments are passed in the correct order.
When to suppress warnings
Do not suppress a warning from this rule as it would result to misleading output.