33 lines
977 B
Plaintext
33 lines
977 B
Plaintext
== How to fix it in MSTest
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,csharp,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
bool someResult;
|
|
|
|
Assert.AreEqual(false, someResult); // Noncompliant: use Assert.IsFalse
|
|
Assert.AreEqual(true, someResult); // Noncompliant: use Assert.IsTrue
|
|
Assert.AreNotEqual(false, someResult); // Noncompliant: use Assert.IsTrue
|
|
Assert.AreNotEqual(true, someResult); // Noncompliant: use Assert.IsFalse
|
|
Assert.IsFalse(true, "Should not reach this line!"); // Noncompliant: use Assert.Fail
|
|
Assert.IsTrue(false, "Should not reach this line!"); // Noncompliant: use Assert.Fail
|
|
Assert.IsFalse(false); // Noncompliant: remove it
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,csharp,diff-id=1,diff-type=compliant]
|
|
----
|
|
bool someResult;
|
|
|
|
Assert.IsFalse(someResult);
|
|
Assert.IsTrue(someResult);
|
|
Assert.IsTrue(someResult);
|
|
Assert.IsFalse(someResult);
|
|
Assert.Fail("Should not reach this line!");
|
|
Assert.Fail("Should not reach this line!");
|
|
// Removed
|
|
---- |