diff --git a/articles/nunit-analyzers/NUnit-Analyzers.html b/articles/nunit-analyzers/NUnit-Analyzers.html
index a844f0d21..073ce94a5 100644
--- a/articles/nunit-analyzers/NUnit-Analyzers.html
+++ b/articles/nunit-analyzers/NUnit-Analyzers.html
@@ -212,7 +212,7 @@
Structure Rules (NUnit1001 - )
NUnit1015 |
-The source type does not implement IEnumerable |
+The source type does not implement I(Async)Enumerable |
✅ |
❗ |
❌ |
@@ -240,7 +240,7 @@ Structure Rules (NUnit1001 - )
NUnit1019 |
-The source specified by the TestCaseSource does not return an IEnumerable or a type that implements IEnumerable |
+The source specified by the TestCaseSource does not return an I(Async)Enumerable or a type that implements I(Async)Enumerable |
✅ |
❗ |
❌ |
@@ -275,7 +275,7 @@ Structure Rules (NUnit1001 - )
NUnit1024 |
-The source specified by the ValueSource does not return an IEnumerable or a type that implements IEnumerable |
+The source specified by the ValueSource does not return an I(Async)Enumerable or a type that implements I(Async)Enumerable |
✅ |
❗ |
❌ |
@@ -353,42 +353,42 @@ Assertion Rules (NUnit2001 - )
NUnit2001 |
-Consider using Assert.That(expr, Is.False) instead of Assert.False(expr) |
+Consider using Assert.That(expr, Is.False) instead of ClassicAssert.False(expr) |
✅ |
ℹ️ |
✅ |
NUnit2002 |
-Consider using Assert.That(expr, Is.False) instead of Assert.IsFalse(expr) |
+Consider using Assert.That(expr, Is.False) instead of ClassicAssert.IsFalse(expr) |
✅ |
ℹ️ |
✅ |
NUnit2003 |
-Consider using Assert.That(expr, Is.True) instead of Assert.IsTrue(expr) |
+Consider using Assert.That(expr, Is.True) instead of ClassicAssert.IsTrue(expr) |
✅ |
ℹ️ |
✅ |
NUnit2004 |
-Consider using Assert.That(expr, Is.True) instead of Assert.True(expr) |
+Consider using Assert.That(expr, Is.True) instead of ClassicAssert.True(expr) |
✅ |
ℹ️ |
✅ |
NUnit2005 |
-Consider using Assert.That(actual, Is.EqualTo(expected)) instead of Assert.AreEqual(expected, actual) |
+Consider using Assert.That(actual, Is.EqualTo(expected)) instead of ClassicAssert.AreEqual(expected, actual) |
✅ |
⚠️ |
✅ |
NUnit2006 |
-Consider using Assert.That(actual, Is.Not.EqualTo(expected)) instead of Assert.AreNotEqual(expected, actual) |
+Consider using Assert.That(actual, Is.Not.EqualTo(expected)) instead of ClassicAssert.AreNotEqual(expected, actual) |
✅ |
⚠️ |
✅ |
@@ -451,35 +451,35 @@ Assertion Rules (NUnit2001 - )
NUnit2015 |
-Consider using Assert.That(actual, Is.SameAs(expected)) instead of Assert.AreSame(expected, actual) |
+Consider using Assert.That(actual, Is.SameAs(expected)) instead of ClassicAssert.AreSame(expected, actual) |
✅ |
⚠️ |
✅ |
NUnit2016 |
-Consider using Assert.That(expr, Is.Null) instead of Assert.Null(expr) |
+Consider using Assert.That(expr, Is.Null) instead of ClassicAssert.Null(expr) |
✅ |
ℹ️ |
✅ |
NUnit2017 |
-Consider using Assert.That(expr, Is.Null) instead of Assert.IsNull(expr) |
+Consider using Assert.That(expr, Is.Null) instead of ClassicAssert.IsNull(expr) |
✅ |
ℹ️ |
✅ |
NUnit2018 |
-Consider using Assert.That(expr, Is.Not.Null) instead of Assert.NotNull(expr) |
+Consider using Assert.That(expr, Is.Not.Null) instead of ClassicAssert.NotNull(expr) |
✅ |
ℹ️ |
✅ |
NUnit2019 |
-Consider using Assert.That(expr, Is.Not.Null) instead of Assert.IsNotNull(expr) |
+Consider using Assert.That(expr, Is.Not.Null) instead of ClassicAssert.IsNotNull(expr) |
✅ |
ℹ️ |
✅ |
@@ -522,8 +522,8 @@ Assertion Rules (NUnit2001 - )
NUnit2025 |
Wrong actual type used with ContainsConstraint |
-✅ |
-❗ |
+❌ |
+💭 |
❌ |
@@ -535,91 +535,91 @@ Assertion Rules (NUnit2001 - )
NUnit2027 |
-Consider using Assert.That(actual, Is.GreaterThan(expected)) instead of Assert.Greater(actual, expected) |
+Consider using Assert.That(actual, Is.GreaterThan(expected)) instead of ClassicAssert.Greater(actual, expected) |
✅ |
ℹ️ |
✅ |
NUnit2028 |
-Consider using Assert.That(actual, Is.GreaterThanOrEqualTo(expected)) instead of Assert.GreaterOrEqual(actual, expected) |
+Consider using Assert.That(actual, Is.GreaterThanOrEqualTo(expected)) instead of ClassicAssert.GreaterOrEqual(actual, expected) |
✅ |
ℹ️ |
✅ |
NUnit2029 |
-Consider using Assert.That(actual, Is.LessThan(expected)) instead of Assert.Less(actual, expected) |
+Consider using Assert.That(actual, Is.LessThan(expected)) instead of ClassicAssert.Less(actual, expected) |
✅ |
ℹ️ |
✅ |
NUnit2030 |
-Consider using Assert.That(actual, Is.LessThanOrEqualTo(expected)) instead of Assert.LessOrEqual(actual, expected) |
+Consider using Assert.That(actual, Is.LessThanOrEqualTo(expected)) instead of ClassicAssert.LessOrEqual(actual, expected) |
✅ |
ℹ️ |
✅ |
NUnit2031 |
-Consider using Assert.That(actual, Is.Not.SameAs(expected)) instead of Assert.AreNotSame(expected, actual) |
+Consider using Assert.That(actual, Is.Not.SameAs(expected)) instead of ClassicAssert.AreNotSame(expected, actual) |
✅ |
⚠️ |
✅ |
NUnit2032 |
-Consider using Assert.That(expr, Is.Zero) instead of Assert.Zero(expr) |
+Consider using Assert.That(expr, Is.Zero) instead of ClassicAssert.Zero(expr) |
✅ |
ℹ️ |
✅ |
NUnit2033 |
-Consider using Assert.That(expr, Is.Not.Zero) instead of Assert.NotZero(expr) |
+Consider using Assert.That(expr, Is.Not.Zero) instead of ClassicAssert.NotZero(expr) |
✅ |
ℹ️ |
✅ |
NUnit2034 |
-Consider using Assert.That(expr, Is.NaN) instead of Assert.IsNaN(expr) |
+Consider using Assert.That(expr, Is.NaN) instead of ClassicAssert.IsNaN(expr) |
✅ |
ℹ️ |
✅ |
NUnit2035 |
-Consider using Assert.That(collection, Is.Empty) instead of Assert.IsEmpty(collection) |
+Consider using Assert.That(collection, Is.Empty) instead of ClassicAssert.IsEmpty(collection) |
✅ |
ℹ️ |
✅ |
NUnit2036 |
-Consider using Assert.That(collection, Is.Not.Empty) instead of Assert.IsNotEmpty(collection) |
+Consider using Assert.That(collection, Is.Not.Empty) instead of ClassicAssert.IsNotEmpty(collection) |
✅ |
ℹ️ |
✅ |
NUnit2037 |
-Consider using Assert.That(collection, Does.Contain(instance)) instead of Assert.Contains(instance, collection) |
+Consider using Assert.That(collection, Does.Contain(instance)) instead of ClassicAssert.Contains(instance, collection) |
✅ |
ℹ️ |
✅ |
NUnit2038 |
-Consider using Assert.That(actual, Is.InstanceOf(expected)) instead of Assert.IsInstanceOf(expected, actual) |
+Consider using Assert.That(actual, Is.InstanceOf(expected)) instead of ClassicAssert.IsInstanceOf(expected, actual) |
✅ |
ℹ️ |
✅ |
NUnit2039 |
-Consider using Assert.That(actual, Is.Not.InstanceOf(expected)) instead of Assert.IsNotInstanceOf(expected, actual) |
+Consider using Assert.That(actual, Is.Not.InstanceOf(expected)) instead of ClassicAssert.IsNotInstanceOf(expected, actual) |
✅ |
ℹ️ |
✅ |
@@ -680,11 +680,32 @@ Assertion Rules (NUnit2001 - )
⚠️ |
✅ |
+
+NUnit2048 |
+Consider using Assert.That(...) instead of StringAssert(...) |
+✅ |
+⚠️ |
+✅ |
+
+
+NUnit2049 |
+Consider using Assert.That(...) instead of CollectionAssert(...) |
+✅ |
+⚠️ |
+✅ |
+
+
+NUnit2050 |
+NUnit 4 no longer supports string.Format specification |
+✅ |
+❗ |
+✅ |
+
Suppressor Rules (NUnit3001 - )
Rules which suppress compiler errors based on context. Note that these rules are only available in the .NET Standard 2.0
-builds (version 3.0.0 and above) which require Visual Studio 2019.
+builds (version 3.0.0 and above) which require Visual Studio 2019 (version 16.3) or newer.
@@ -698,7 +719,7 @@ Suppressor Rules (NUnit3001 - )
NUnit3001 |
-Expression was checked in an Assert.NotNull, Assert.IsNotNull or Assert.That call |
+Expression was checked in an ClassicAssert.NotNull, ClassicAssert.IsNotNull or Assert.That call |
✅ |
ℹ️ |
❌ |
diff --git a/articles/nunit-analyzers/NUnit1001.html b/articles/nunit-analyzers/NUnit1001.html
index b4993231b..69dc5221e 100644
--- a/articles/nunit-analyzers/NUnit1001.html
+++ b/articles/nunit-analyzers/NUnit1001.html
@@ -113,7 +113,7 @@
diff --git a/articles/nunit-analyzers/NUnit1002.html b/articles/nunit-analyzers/NUnit1002.html
index 7ed6a397d..3c3d7bff0 100644
--- a/articles/nunit-analyzers/NUnit1002.html
+++ b/articles/nunit-analyzers/NUnit1002.html
@@ -113,7 +113,7 @@ The Tes
Code |
-TestCaseSourceUsesStringAnalyzer |
+TestCaseSourceUsesStringAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1003.html b/articles/nunit-analyzers/NUnit1003.html
index 7c853a4fe..fac01f845 100644
--- a/articles/nunit-analyzers/NUnit1003.html
+++ b/articles/nunit-analyzers/NUnit1003.html
@@ -113,7 +113,7 @@ The TestCaseAttribute
Code |
-TestCaseUsageAnalyzer |
+TestCaseUsageAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1004.html b/articles/nunit-analyzers/NUnit1004.html
index 8222b52cc..184d18d35 100644
--- a/articles/nunit-analyzers/NUnit1004.html
+++ b/articles/nunit-analyzers/NUnit1004.html
@@ -113,7 +113,7 @@ The TestCaseAttribute
Code |
-TestCaseUsageAnalyzer |
+TestCaseUsageAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1005.html b/articles/nunit-analyzers/NUnit1005.html
index 76551d550..083c41cfb 100644
--- a/articles/nunit-analyzers/NUnit1005.html
+++ b/articles/nunit-analyzers/NUnit1005.html
@@ -113,7 +113,7 @@ Code
-TestMethodUsageAnalyzer |
+TestMethodUsageAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1006.html b/articles/nunit-analyzers/NUnit1006.html
index e08198913..719bf07fe 100644
--- a/articles/nunit-analyzers/NUnit1006.html
+++ b/articles/nunit-analyzers/NUnit1006.html
@@ -113,7 +113,7 @@ Expec
Code |
-TestMethodUsageAnalyzer |
+TestMethodUsageAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1007.html b/articles/nunit-analyzers/NUnit1007.html
index aaeb900e9..5bc24e40f 100644
--- a/articles/nunit-analyzers/NUnit1007.html
+++ b/articles/nunit-analyzers/NUnit1007.html
@@ -113,7 +113,7 @@ Code
-TestMethodUsageAnalyzer |
+TestMethodUsageAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1008.html b/articles/nunit-analyzers/NUnit1008.html
index 3d562d476..58edfa7e0 100644
--- a/articles/nunit-analyzers/NUnit1008.html
+++ b/articles/nunit-analyzers/NUnit1008.html
@@ -113,7 +113,7 @@ Specifying
Code |
-ParallelizableUsageAnalyzer |
+ParallelizableUsageAnalyzer |
@@ -128,7 +128,8 @@ Example Violation
[assembly: Parallelizable(ParallelScope.Self)]
Explanation
-
ParallelScope.Self
only applies to classes and methods, not to assemblies.
+ParallelScope.Self
only applies to classes and methods,
+not to assemblies.
Fix
Either remove it or change to a valid option, such as:
[assembly: Parallelizable(ParallelScope.Children)]
diff --git a/articles/nunit-analyzers/NUnit1009.html b/articles/nunit-analyzers/NUnit1009.html
index e1526fc9f..b68b2833a 100644
--- a/articles/nunit-analyzers/NUnit1009.html
+++ b/articles/nunit-analyzers/NUnit1009.html
@@ -113,7 +113,7 @@ Code
-ParallelizableUsageAnalyzer |
+ParallelizableUsageAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1010.html b/articles/nunit-analyzers/NUnit1010.html
index 210826904..45ba71d5d 100644
--- a/articles/nunit-analyzers/NUnit1010.html
+++ b/articles/nunit-analyzers/NUnit1010.html
@@ -113,7 +113,7 @@ One may not
Code |
-ParallelizableUsageAnalyzer |
+ParallelizableUsageAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1011.html b/articles/nunit-analyzers/NUnit1011.html
index bc9965a1b..39749095e 100644
--- a/articles/nunit-analyzers/NUnit1011.html
+++ b/articles/nunit-analyzers/NUnit1011.html
@@ -113,7 +113,7 @@ The Tes
Code |
-TestCaseSourceUsesStringAnalyzer |
+TestCaseSourceUsesStringAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1012.html b/articles/nunit-analyzers/NUnit1012.html
index 3c525b077..62de61abe 100644
--- a/articles/nunit-analyzers/NUnit1012.html
+++ b/articles/nunit-analyzers/NUnit1012.html
@@ -113,7 +113,7 @@ The async test m
Code |
-TestMethodUsageAnalyzer |
+TestMethodUsageAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1013.html b/articles/nunit-analyzers/NUnit1013.html
index 5e95356c6..3b08c51bb 100644
--- a/articles/nunit-analyzers/NUnit1013.html
+++ b/articles/nunit-analyzers/NUnit1013.html
@@ -113,7 +113,7 @@
Explanation
-The NUnit ExpectedResult
syntax is not used, so it's an error for this method to return something that isn't being checked.
+The NUnit ExpectedResult
syntax is not used, so it's an error for this method to return something that isn't being
+checked.
Fix
Utilize the ExpectedResult
syntax:
[TestCase(1, ExpectedResult = "1")]
@@ -166,7 +167,8 @@ Fix
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
# NUnit1013: The async test method must have a non-generic Task return type when no result is expected
dotnet_diagnostic.NUnit1013.severity = chosenSeverity
diff --git a/articles/nunit-analyzers/NUnit1014.html b/articles/nunit-analyzers/NUnit1014.html
index a0ec22d3b..a3b320355 100644
--- a/articles/nunit-analyzers/NUnit1014.html
+++ b/articles/nunit-analyzers/NUnit1014.html
@@ -113,7 +113,7 @@ Code
-TestMethodUsageAnalyzer |
+TestMethodUsageAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1015.html b/articles/nunit-analyzers/NUnit1015.html
index 8305e69e3..bbb1beb8d 100644
--- a/articles/nunit-analyzers/NUnit1015.html
+++ b/articles/nunit-analyzers/NUnit1015.html
@@ -86,7 +86,7 @@
NUnit1015
-The source type does not implement IEnumerable
+The source type does not implement I(Async)Enumerable
Description
-The source type must implement IEnumerable in order to provide test cases.
+The source type must implement I(Async)Enumerable in order to provide test cases.
Motivation
To prevent tests that will fail at runtime due to improper construction.
How to fix violations
@@ -128,7 +128,7 @@ Example Violation
[TestCaseSource(typeof(DivideCases))]
public void DivideTest(int n, int d, int q)
{
- Assert.AreEqual(q, n / d);
+ ClassicAssert.AreEqual(q, n / d);
}
}
@@ -143,16 +143,17 @@ Example Violation
}
Explanation
-In the sample above, the class DivideCases
does not implement IEnumerable
.
-However, source types specified by TestCaseSource
must implement IEnumerable
.
+In the sample above, the class DivideCases
does not implement IEnumerable
nor IAsyncEnumerable
+However, source types specified by TestCaseSource
+must implement IEnumerable
or IAsyncEnumerable
.
Fix
-Make the source type implement IEnumerable
:
+Make the source type implement IEnumerable
or IAsyncEnumerable
public class MyTestClass
{
[TestCaseSource(typeof(DivideCases))]
public void DivideTest(int n, int d, int q)
{
- Assert.AreEqual(q, n / d);
+ ClassicAssert.AreEqual(q, n / d);
}
}
@@ -169,23 +170,24 @@ Fix
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
-# NUnit1015: The source type does not implement IEnumerable
+# NUnit1015: The source type does not implement I(Async)Enumerable
dotnet_diagnostic.NUnit1015.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit1015 // The source type does not implement IEnumerable
+#pragma warning disable NUnit1015 // The source type does not implement I(Async)Enumerable
Code violating the rule here
-#pragma warning restore NUnit1015 // The source type does not implement IEnumerable
+#pragma warning restore NUnit1015 // The source type does not implement I(Async)Enumerable
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit1015 // The source type does not implement IEnumerable
+#pragma warning disable NUnit1015 // The source type does not implement I(Async)Enumerable
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Structure",
- "NUnit1015:The source type does not implement IEnumerable",
+ "NUnit1015:The source type does not implement I(Async)Enumerable",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit1016.html b/articles/nunit-analyzers/NUnit1016.html
index 5d40951ef..ed3f567f7 100644
--- a/articles/nunit-analyzers/NUnit1016.html
+++ b/articles/nunit-analyzers/NUnit1016.html
@@ -113,7 +113,7 @@ The source type doe
Code |
-TestCaseSourceUsesStringAnalyzer |
+TestCaseSourceUsesStringAnalyzer |
@@ -128,7 +128,7 @@ Example Violation
[TestCaseSource(typeof(DivideCases))]
public void DivideTest(int n, int d, int q)
{
- Assert.AreEqual(q, n / d);
+ ClassicAssert.AreEqual(q, n / d);
}
}
@@ -146,7 +146,8 @@ Example Violation
Explanation
In the sample above, the class DivideCases
does not have a default constructor - i.e. a constructor with no parameters.
-However, source types specified by TestCaseSource
must have a default constructor.
+However, source types specified by TestCaseSource
+must have a default constructor.
Fix
Add a default constructor to the source type (or remove the parameters from an existing constructor):
public class MyTestClass
@@ -154,7 +155,7 @@ Fix
[TestCaseSource(typeof(DivideCases))]
public void DivideTest(int n, int d, int q)
{
- Assert.AreEqual(q, n / d);
+ ClassicAssert.AreEqual(q, n / d);
}
}
@@ -175,7 +176,8 @@ Fix
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
# NUnit1016: The source type does not have a default constructor
dotnet_diagnostic.NUnit1016.severity = chosenSeverity
diff --git a/articles/nunit-analyzers/NUnit1017.html b/articles/nunit-analyzers/NUnit1017.html
index bebe34096..c0abd6309 100644
--- a/articles/nunit-analyzers/NUnit1017.html
+++ b/articles/nunit-analyzers/NUnit1017.html
@@ -113,7 +113,7 @@ The specified source is not static
Code |
-TestCaseSourceUsesStringAnalyzer |
+TestCaseSourceUsesStringAnalyzer |
@@ -128,7 +128,7 @@ Example Violation
[TestCaseSource(nameof(DivideCases))]
public void DivideTest(int n, int d, int q)
{
- Assert.AreEqual(q, n / d);
+ ClassicAssert.AreEqual(q, n / d);
}
object[] DivideCases =
@@ -141,7 +141,8 @@ Example Violation
Explanation
In the sample above, DivideCases
is not a static
field.
-However, sources specified by TestCaseSource
must be static
.
+However, sources specified by TestCaseSource
+must be static
.
Fix
Make the source static
:
public class MyTestClass
@@ -149,7 +150,7 @@ Fix
[TestCaseSource(nameof(DivideCases))]
public void DivideTest(int n, int d, int q)
{
- Assert.AreEqual(q, n / d);
+ ClassicAssert.AreEqual(q, n / d);
}
static object[] DivideCases =
@@ -163,7 +164,8 @@ Fix
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
# NUnit1017: The specified source is not static
dotnet_diagnostic.NUnit1017.severity = chosenSeverity
diff --git a/articles/nunit-analyzers/NUnit1018.html b/articles/nunit-analyzers/NUnit1018.html
index 0ca8a2334..689cdceb0 100644
--- a/articles/nunit-analyzers/NUnit1018.html
+++ b/articles/nunit-analyzers/NUnit1018.html
@@ -113,7 +113,7 @@ Code
-TestCaseSourceUsesStringAnalyzer |
+TestCaseSourceUsesStringAnalyzer |
@@ -160,7 +160,8 @@ Fix
Configure severity
Via ruleset file
-
Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
# NUnit1018: The number of parameters provided by the TestCaseSource does not match the number of parameters in the target method
dotnet_diagnostic.NUnit1018.severity = chosenSeverity
diff --git a/articles/nunit-analyzers/NUnit1019.html b/articles/nunit-analyzers/NUnit1019.html
index 337143d20..f32d90fc5 100644
--- a/articles/nunit-analyzers/NUnit1019.html
+++ b/articles/nunit-analyzers/NUnit1019.html
@@ -86,7 +86,7 @@
NUnit1019
-The source specified by the TestCaseSource does not return an IEnumerable or a type that implements IEnumerable
+The source specified by the TestCaseSource does not return an I(Async)Enumerable or a type that implements I(Async)Enumerable
Description
-The source specified by the TestCaseSource must return an IEnumerable or a type that implements IEnumerable.
+The source specified by the TestCaseSource must return an I(Async)Enumerable or a type that implements I(Async)Enumerable.
Motivation
To prevent tests that will fail at runtime due to improper construction.
How to fix violations
@@ -134,12 +134,12 @@ Example Violation
}
Explanation
-In the sample above, the source specified by TestCaseSource
- the field testCases
- does not return an IEnumerable
-or a type that implements IEnumerable
, instead it returns an int
.
-However, sources specified by TestCaseSource
must return an IEnumerable
or a type that implements
-IEnumerable
..
+In the sample above, the source specified by TestCaseSource
- the field testCases
- does not return an
+I(Async)Enumerable
or a type that implements I(Async)Enumerable
, instead it returns an int
.
+However, sources specified by TestCaseSource
+must return an I(Async)Enumerable
or a type that implements I(Async)Enumerable
..
Fix
-Change testCases
to return an IEnumerable
or a type that implements IEnumerable
:
+Change testCases
to return an I(Async)Enumerable
or a type that implements I(Async)Enumerable
:
public class AnalyzeWhenSourceDoesProvideIEnumerable
{
private static readonly int[] testCases = new int[] { 1, 2, 42 };
@@ -156,21 +156,21 @@ Via ruleset file
Configure the severity per project, for more info see
MSDN.
Via .editorconfig file
-# NUnit1019: The source specified by the TestCaseSource does not return an IEnumerable or a type that implements IEnumerable
+# NUnit1019: The source specified by the TestCaseSource does not return an I(Async)Enumerable or a type that implements I(Async)Enumerable
dotnet_diagnostic.NUnit1019.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit1019 // The source specified by the TestCaseSource does not return an IEnumerable or a type that implements IEnumerable
+#pragma warning disable NUnit1019 // The source specified by the TestCaseSource does not return an I(Async)Enumerable or a type that implements I(Async)Enumerable
Code violating the rule here
-#pragma warning restore NUnit1019 // The source specified by the TestCaseSource does not return an IEnumerable or a type that implements IEnumerable
+#pragma warning restore NUnit1019 // The source specified by the TestCaseSource does not return an I(Async)Enumerable or a type that implements I(Async)Enumerable
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit1019 // The source specified by the TestCaseSource does not return an IEnumerable or a type that implements IEnumerable
+#pragma warning disable NUnit1019 // The source specified by the TestCaseSource does not return an I(Async)Enumerable or a type that implements I(Async)Enumerable
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Structure",
- "NUnit1019:The source specified by the TestCaseSource does not return an IEnumerable or a type that implements IEnumerable",
+ "NUnit1019:The source specified by the TestCaseSource does not return an I(Async)Enumerable or a type that implements I(Async)Enumerable",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit1020.html b/articles/nunit-analyzers/NUnit1020.html
index ac929cd53..10e07374f 100644
--- a/articles/nunit-analyzers/NUnit1020.html
+++ b/articles/nunit-analyzers/NUnit1020.html
@@ -113,7 +113,7 @@ Code
-TestCaseSourceUsesStringAnalyzer |
+TestCaseSourceUsesStringAnalyzer |
@@ -128,7 +128,7 @@ Example Violation
[TestCaseSource(nameof(DivideCases), new object[] { "Testing" })]
public void DivideTest(int n, int d, int q)
{
- Assert.AreEqual(q, n / d);
+ ClassicAssert.AreEqual(q, n / d);
}
static object[] DivideCases =
@@ -149,7 +149,7 @@ Fix
[TestCaseSource(nameof(DivideCases), new object[] { "Testing" })]
public void DivideTest(int n, int d, int q)
{
- Assert.AreEqual(q, n / d);
+ ClassicAssert.AreEqual(q, n / d);
}
static object[] DivideCases(string input)
diff --git a/articles/nunit-analyzers/NUnit1021.html b/articles/nunit-analyzers/NUnit1021.html
index cf4343b6e..eae6a3451 100644
--- a/articles/nunit-analyzers/NUnit1021.html
+++ b/articles/nunit-analyzers/NUnit1021.html
@@ -113,7 +113,7 @@ The ValueS
Code |
-ValueSourceUsageAnalyzer |
+ValueSourceUsageAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1022.html b/articles/nunit-analyzers/NUnit1022.html
index a22c6c55e..1c0b03a14 100644
--- a/articles/nunit-analyzers/NUnit1022.html
+++ b/articles/nunit-analyzers/NUnit1022.html
@@ -113,7 +113,7 @@ The specified source is not static
Code |
-ValueSourceUsageAnalyzer |
+ValueSourceUsageAnalyzer |
@@ -128,7 +128,7 @@ Example Violation
[Test]
public void DivideTest([ValueSource(nameof(Numbers))] int n)
{
- Assert.AreEqual(n, Is.GreaterThanOrEqualTo(0));
+ ClassicAssert.AreEqual(n, Is.GreaterThanOrEqualTo(0));
}
object[] Numbers => new int[] { 1, 2, 3 };
@@ -144,7 +144,7 @@ Fix
[Test]
public void DivideTest([ValueSource(nameof(Numbers))] int n)
{
- Assert.AreEqual(n, Is.GreaterThanOrEqualTo(0));
+ ClassicAssert.AreEqual(n, Is.GreaterThanOrEqualTo(0));
}
static object[] Numbers => new int[] { 1, 2, 3 };
@@ -153,7 +153,8 @@ Fix
Configure severity
Via ruleset file
-
Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
# NUnit1022: The specified source is not static
dotnet_diagnostic.NUnit1022.severity = chosenSeverity
diff --git a/articles/nunit-analyzers/NUnit1023.html b/articles/nunit-analyzers/NUnit1023.html
index d9d0e8e7f..5bed360a0 100644
--- a/articles/nunit-analyzers/NUnit1023.html
+++ b/articles/nunit-analyzers/NUnit1023.html
@@ -113,7 +113,7 @@ Code
-ValueSourceUsageAnalyzer |
+ValueSourceUsageAnalyzer |
@@ -160,7 +160,8 @@ Fix
Configure severity
Via ruleset file
-
Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
# NUnit1023: The target method expects parameters which cannot be supplied by the ValueSource
dotnet_diagnostic.NUnit1023.severity = chosenSeverity
diff --git a/articles/nunit-analyzers/NUnit1024.html b/articles/nunit-analyzers/NUnit1024.html
index b257ea8e7..b9f1e6601 100644
--- a/articles/nunit-analyzers/NUnit1024.html
+++ b/articles/nunit-analyzers/NUnit1024.html
@@ -86,7 +86,7 @@
NUnit1024
-The source specified by the ValueSource does not return an IEnumerable or a type that implements IEnumerable
+The source specified by the ValueSource does not return an I(Async)Enumerable or a type that implements I(Async)Enumerable
Description
-The source specified by the ValueSource must return an IEnumerable or a type that implements IEnumerable.
+The source specified by the ValueSource must return an I(Async)Enumerable or a type that implements I(Async)Enumerable.
Motivation
To prevent tests that will fail at runtime due to improper construction.
How to fix violations
@@ -134,12 +134,12 @@ Example Violation
}
Explanation
-In the sample above, the source specified by ValueSource
- the field testCases
- does not return an IEnumerable
or
-a type that implements IEnumerable
, instead it returns an int
.
-However, sources specified by ValueSource
must return an IEnumerable
or a type that implements
-IEnumerable
..
+In the sample above, the source specified by ValueSource
- the field testCases
- does not return an
+I(Async)Enumerable
or a type that implements I(Async)Enumerable
, instead it returns an int
.
+However, sources specified by ValueSource
+must return an I(Async)Enumerable
or a type that implements I(Async)Enumerable
..
Fix
-Change testCases
to return an IEnumerable
or a type that implements IEnumerable
:
+Change testCases
to return an I(Async)Enumerable
or a type that implements I(Async)Enumerable
:
public class AnalyzeWhenSourceDoesProvideIEnumerable
{
private static readonly int[] testCases = new int[] { 1, 2, 42 };
@@ -156,21 +156,21 @@ Via ruleset file
Configure the severity per project, for more info see
MSDN.
Via .editorconfig file
-# NUnit1024: The source specified by the ValueSource does not return an IEnumerable or a type that implements IEnumerable
+# NUnit1024: The source specified by the ValueSource does not return an I(Async)Enumerable or a type that implements I(Async)Enumerable
dotnet_diagnostic.NUnit1024.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit1024 // The source specified by the ValueSource does not return an IEnumerable or a type that implements IEnumerable
+#pragma warning disable NUnit1024 // The source specified by the ValueSource does not return an I(Async)Enumerable or a type that implements I(Async)Enumerable
Code violating the rule here
-#pragma warning restore NUnit1024 // The source specified by the ValueSource does not return an IEnumerable or a type that implements IEnumerable
+#pragma warning restore NUnit1024 // The source specified by the ValueSource does not return an I(Async)Enumerable or a type that implements I(Async)Enumerable
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit1024 // The source specified by the ValueSource does not return an IEnumerable or a type that implements IEnumerable
+#pragma warning disable NUnit1024 // The source specified by the ValueSource does not return an I(Async)Enumerable or a type that implements I(Async)Enumerable
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Structure",
- "NUnit1024:The source specified by the ValueSource does not return an IEnumerable or a type that implements IEnumerable",
+ "NUnit1024:The source specified by the ValueSource does not return an I(Async)Enumerable or a type that implements I(Async)Enumerable",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit1025.html b/articles/nunit-analyzers/NUnit1025.html
index bb0adecc5..e50e16058 100644
--- a/articles/nunit-analyzers/NUnit1025.html
+++ b/articles/nunit-analyzers/NUnit1025.html
@@ -113,7 +113,7 @@ The ValueS
Code |
-ValueSourceUsageAnalyzer |
+ValueSourceUsageAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1026.html b/articles/nunit-analyzers/NUnit1026.html
index 866286787..c1402838c 100644
--- a/articles/nunit-analyzers/NUnit1026.html
+++ b/articles/nunit-analyzers/NUnit1026.html
@@ -113,7 +113,7 @@ The test or setup/teardo
Code |
-TestMethodAccessibilityLevelAnalyzer |
+TestMethodAccessibilityLevelAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1027.html b/articles/nunit-analyzers/NUnit1027.html
index 44e02717b..e92800c72 100644
--- a/articles/nunit-analyzers/NUnit1027.html
+++ b/articles/nunit-analyzers/NUnit1027.html
@@ -113,7 +113,7 @@ Code
-TestMethodUsageAnalyzer |
+TestMethodUsageAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1028.html b/articles/nunit-analyzers/NUnit1028.html
index a3d483cb7..4f60b6450 100644
--- a/articles/nunit-analyzers/NUnit1028.html
+++ b/articles/nunit-analyzers/NUnit1028.html
@@ -113,13 +113,13 @@ The non-test method is public
Code |
-NonTestMethodAccessibilityLevelAnalyzer |
+NonTestMethodAccessibilityLevelAnalyzer |
Description
-
A fixture should not contain any public non-test methods.
-There are two exceptions: A public constructor and an IDisposable.Dispose
method implementation.
+A fixture should not contain any public non-test methods.
+There are two exceptions: A public constructor and an IDisposable.Dispose
method implementation.
Motivation
A fixture should be self-contained and not have methods callable by other classes.
How to fix violations
@@ -128,7 +128,8 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
# NUnit1028: The non-test method is public
dotnet_diagnostic.NUnit1028.severity = chosenSeverity
diff --git a/articles/nunit-analyzers/NUnit1029.html b/articles/nunit-analyzers/NUnit1029.html
index 88c09790a..c5c73f859 100644
--- a/articles/nunit-analyzers/NUnit1029.html
+++ b/articles/nunit-analyzers/NUnit1029.html
@@ -113,7 +113,7 @@ Code
-TestCaseSourceUsesStringAnalyzer |
+TestCaseSourceUsesStringAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1030.html b/articles/nunit-analyzers/NUnit1030.html
index 0482ed285..63d8d6060 100644
--- a/articles/nunit-analyzers/NUnit1030.html
+++ b/articles/nunit-analyzers/NUnit1030.html
@@ -113,7 +113,7 @@ Code
-TestCaseSourceUsesStringAnalyzer |
+TestCaseSourceUsesStringAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1031.html b/articles/nunit-analyzers/NUnit1031.html
index 0e3569379..c427888cf 100644
--- a/articles/nunit-analyzers/NUnit1031.html
+++ b/articles/nunit-analyzers/NUnit1031.html
@@ -113,7 +113,7 @@ Code
-ValuesUsageAnalyzer |
+ValuesUsageAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit1032.html b/articles/nunit-analyzers/NUnit1032.html
index 5d99c6a25..5398e8dac 100644
--- a/articles/nunit-analyzers/NUnit1032.html
+++ b/articles/nunit-analyzers/NUnit1032.html
@@ -113,7 +113,7 @@ An
Code |
-DisposeFieldsAndPropertiesInTearDownAnalyzer |
+DisposeFieldsAndPropertiesInTearDownAnalyzer |
@@ -128,7 +128,8 @@ How to fix violations
Configure severity
Via ruleset file
-
Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
# NUnit1032: An IDisposable field/property should be Disposed in a TearDown method
dotnet_diagnostic.NUnit1032.severity = chosenSeverity
diff --git a/articles/nunit-analyzers/NUnit2001.html b/articles/nunit-analyzers/NUnit2001.html
index 4ab5a87e2..12e48b0d3 100644
--- a/articles/nunit-analyzers/NUnit2001.html
+++ b/articles/nunit-analyzers/NUnit2001.html
@@ -86,7 +86,7 @@
NUnit2001
-Consider using Assert.That(expr, Is.False) instead of Assert.False(expr)
+Consider using Assert.That(expr, Is.False) instead of ClassicAssert.False(expr)
Description
-Consider using the constraint model, Assert.That(expr, Is.False)
, instead of the classic model, Assert.False(expr)
.
+Consider using the constraint model, Assert.That(expr, Is.False)
, instead of the classic model,
+ClassicAssert.False(expr)
.
Motivation
The classic Assert model contains less flexibility than the constraint model,
-so this analyzer marks usages of Assert.False
from the classic Assert model.
+so this analyzer marks usages of ClassicAssert.False
from the classic Assert model.
[Test]
public void Test()
{
- Assert.False(expression);
+ ClassicAssert.False(expression);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.False(expression)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.False(expression)
with
Assert.That(expression, Is.False)
. So the code block above will be changed into.
[Test]
public void Test()
@@ -140,23 +141,24 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
-# NUnit2001: Consider using Assert.That(expr, Is.False) instead of Assert.False(expr)
+# NUnit2001: Consider using Assert.That(expr, Is.False) instead of ClassicAssert.False(expr)
dotnet_diagnostic.NUnit2001.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2001 // Consider using Assert.That(expr, Is.False) instead of Assert.False(expr)
+#pragma warning disable NUnit2001 // Consider using Assert.That(expr, Is.False) instead of ClassicAssert.False(expr)
Code violating the rule here
-#pragma warning restore NUnit2001 // Consider using Assert.That(expr, Is.False) instead of Assert.False(expr)
+#pragma warning restore NUnit2001 // Consider using Assert.That(expr, Is.False) instead of ClassicAssert.False(expr)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2001 // Consider using Assert.That(expr, Is.False) instead of Assert.False(expr)
+#pragma warning disable NUnit2001 // Consider using Assert.That(expr, Is.False) instead of ClassicAssert.False(expr)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2001:Consider using Assert.That(expr, Is.False) instead of Assert.False(expr)",
+ "NUnit2001:Consider using Assert.That(expr, Is.False) instead of ClassicAssert.False(expr)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2002.html b/articles/nunit-analyzers/NUnit2002.html
index 97b3ed8b5..0478f08e6 100644
--- a/articles/nunit-analyzers/NUnit2002.html
+++ b/articles/nunit-analyzers/NUnit2002.html
@@ -86,7 +86,7 @@
NUnit2002
-Consider using Assert.That(expr, Is.False) instead of Assert.IsFalse(expr)
+Consider using Assert.That(expr, Is.False) instead of ClassicAssert.IsFalse(expr)
Description
-Consider using the constraint model, Assert.That(expr, Is.False)
, instead of the classic model, Assert.IsFalse(expr)
.
+Consider using the constraint model, Assert.That(expr, Is.False)
, instead of the classic model,
+ClassicAssert.IsFalse(expr)
.
Motivation
The classic Assert model contains less flexibility than the constraint model,
-so this analyzer marks usages of Assert.IsFalse
from the classic Assert model.
+so this analyzer marks usages of ClassicAssert.IsFalse
from the classic Assert model.
[Test]
public void Test()
{
- Assert.IsFalse(expression);
+ ClassicAssert.IsFalse(expression);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.IsFalse(expression)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.IsFalse(expression)
with
Assert.That(expression, Is.False)
. So the code block above will be changed into.
[Test]
public void Test()
@@ -140,23 +141,24 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
-# NUnit2002: Consider using Assert.That(expr, Is.False) instead of Assert.IsFalse(expr)
+# NUnit2002: Consider using Assert.That(expr, Is.False) instead of ClassicAssert.IsFalse(expr)
dotnet_diagnostic.NUnit2002.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2002 // Consider using Assert.That(expr, Is.False) instead of Assert.IsFalse(expr)
+#pragma warning disable NUnit2002 // Consider using Assert.That(expr, Is.False) instead of ClassicAssert.IsFalse(expr)
Code violating the rule here
-#pragma warning restore NUnit2002 // Consider using Assert.That(expr, Is.False) instead of Assert.IsFalse(expr)
+#pragma warning restore NUnit2002 // Consider using Assert.That(expr, Is.False) instead of ClassicAssert.IsFalse(expr)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2002 // Consider using Assert.That(expr, Is.False) instead of Assert.IsFalse(expr)
+#pragma warning disable NUnit2002 // Consider using Assert.That(expr, Is.False) instead of ClassicAssert.IsFalse(expr)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2002:Consider using Assert.That(expr, Is.False) instead of Assert.IsFalse(expr)",
+ "NUnit2002:Consider using Assert.That(expr, Is.False) instead of ClassicAssert.IsFalse(expr)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2003.html b/articles/nunit-analyzers/NUnit2003.html
index 07391fc5b..2a1002ae8 100644
--- a/articles/nunit-analyzers/NUnit2003.html
+++ b/articles/nunit-analyzers/NUnit2003.html
@@ -86,7 +86,7 @@
NUnit2003
-Consider using Assert.That(expr, Is.True) instead of Assert.IsTrue(expr)
+Consider using Assert.That(expr, Is.True) instead of ClassicAssert.IsTrue(expr)
Description
-Consider using the constraint model, Assert.That(expr, Is.True)
, instead of the classic model, Assert.IsTrue(expr)
.
+Consider using the constraint model, Assert.That(expr, Is.True)
, instead of the classic model,
+ClassicAssert.IsTrue(expr)
.
Motivation
The classic Assert model contains less flexibility than the constraint model,
-so this analyzer marks usages of Assert.IsTrue
from the classic Assert model.
+so this analyzer marks usages of ClassicAssert.IsTrue
from the classic Assert model.
[Test]
public void Test()
{
- Assert.IsTrue(expression);
+ ClassicAssert.IsTrue(expression);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.IsTrue(expression)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.IsTrue(expression)
with
Assert.That(expression, Is.True)
. So the code block above will be changed into.
[Test]
public void Test()
@@ -140,23 +141,24 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
-# NUnit2003: Consider using Assert.That(expr, Is.True) instead of Assert.IsTrue(expr)
+# NUnit2003: Consider using Assert.That(expr, Is.True) instead of ClassicAssert.IsTrue(expr)
dotnet_diagnostic.NUnit2003.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2003 // Consider using Assert.That(expr, Is.True) instead of Assert.IsTrue(expr)
+#pragma warning disable NUnit2003 // Consider using Assert.That(expr, Is.True) instead of ClassicAssert.IsTrue(expr)
Code violating the rule here
-#pragma warning restore NUnit2003 // Consider using Assert.That(expr, Is.True) instead of Assert.IsTrue(expr)
+#pragma warning restore NUnit2003 // Consider using Assert.That(expr, Is.True) instead of ClassicAssert.IsTrue(expr)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2003 // Consider using Assert.That(expr, Is.True) instead of Assert.IsTrue(expr)
+#pragma warning disable NUnit2003 // Consider using Assert.That(expr, Is.True) instead of ClassicAssert.IsTrue(expr)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2003:Consider using Assert.That(expr, Is.True) instead of Assert.IsTrue(expr)",
+ "NUnit2003:Consider using Assert.That(expr, Is.True) instead of ClassicAssert.IsTrue(expr)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2004.html b/articles/nunit-analyzers/NUnit2004.html
index 159f08665..5bac801bb 100644
--- a/articles/nunit-analyzers/NUnit2004.html
+++ b/articles/nunit-analyzers/NUnit2004.html
@@ -86,7 +86,7 @@
NUnit2004
-Consider using Assert.That(expr, Is.True) instead of Assert.True(expr)
+Consider using Assert.That(expr, Is.True) instead of ClassicAssert.True(expr)
Description
-Consider using the constraint model, Assert.That(expr, Is.True)
, instead of the classic model, Assert.True(expr)
.
+Consider using the constraint model, Assert.That(expr, Is.True)
, instead of the classic model,
+ClassicAssert.True(expr)
.
Motivation
The classic Assert model contains less flexibility than the constraint model,
-so this analyzer marks usages of Assert.True
from the classic Assert model.
+so this analyzer marks usages of ClassicAssert.True
from the classic Assert model.
[Test]
public void Test()
{
- Assert.True(expression);
+ ClassicAssert.True(expression);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.True(expression)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.True(expression)
with
Assert.That(expression, Is.True)
. So the code block above will be changed into.
[Test]
public void Test()
@@ -140,23 +141,24 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
-# NUnit2004: Consider using Assert.That(expr, Is.True) instead of Assert.True(expr)
+# NUnit2004: Consider using Assert.That(expr, Is.True) instead of ClassicAssert.True(expr)
dotnet_diagnostic.NUnit2004.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2004 // Consider using Assert.That(expr, Is.True) instead of Assert.True(expr)
+#pragma warning disable NUnit2004 // Consider using Assert.That(expr, Is.True) instead of ClassicAssert.True(expr)
Code violating the rule here
-#pragma warning restore NUnit2004 // Consider using Assert.That(expr, Is.True) instead of Assert.True(expr)
+#pragma warning restore NUnit2004 // Consider using Assert.That(expr, Is.True) instead of ClassicAssert.True(expr)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2004 // Consider using Assert.That(expr, Is.True) instead of Assert.True(expr)
+#pragma warning disable NUnit2004 // Consider using Assert.That(expr, Is.True) instead of ClassicAssert.True(expr)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2004:Consider using Assert.That(expr, Is.True) instead of Assert.True(expr)",
+ "NUnit2004:Consider using Assert.That(expr, Is.True) instead of ClassicAssert.True(expr)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2005.html b/articles/nunit-analyzers/NUnit2005.html
index 767efc77e..b30536875 100644
--- a/articles/nunit-analyzers/NUnit2005.html
+++ b/articles/nunit-analyzers/NUnit2005.html
@@ -86,7 +86,7 @@
NUnit2005
-Consider using Assert.That(actual, Is.EqualTo(expected)) instead of Assert.AreEqual(expected, actual)
+Consider using Assert.That(actual, Is.EqualTo(expected)) instead of ClassicAssert.AreEqual(expected, actual)
Description
Consider using the constraint model, Assert.That(actual, Is.EqualTo(expected))
, instead of the classic model,
-Assert.AreEqual(expected, actual)
.
+ClassicAssert.AreEqual(expected, actual)
.
Motivation
-The classic Assert model, Assert.AreEqual(expected, actual)
, makes it easy to mix the expected
and the actual
-parameter, so this analyzer marks usages of Assert.AreEqual
from the classic Assert model.
+The classic Assert model, ClassicAssert.AreEqual(expected, actual)
, makes it easy to mix the expected
and the
+actual
parameter, so this analyzer marks usages of ClassicAssert.AreEqual
from the classic Assert model.
[Test]
public void Test()
{
- Assert.AreEqual(expression1, expression2);
+ ClassicAssert.AreEqual(expression1, expression2);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.AreEqual(expression1, expression2)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.AreEqual(expression1, expression2)
with
Assert.That(expression2, Is.EqualTo(expression1))
. So the code block above will be changed into.
[Test]
public void Test()
@@ -144,21 +144,21 @@ Via ruleset file
Configure the severity per project, for more info see
MSDN.
Via .editorconfig file
-# NUnit2005: Consider using Assert.That(actual, Is.EqualTo(expected)) instead of Assert.AreEqual(expected, actual)
+# NUnit2005: Consider using Assert.That(actual, Is.EqualTo(expected)) instead of ClassicAssert.AreEqual(expected, actual)
dotnet_diagnostic.NUnit2005.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2005 // Consider using Assert.That(actual, Is.EqualTo(expected)) instead of Assert.AreEqual(expected, actual)
+#pragma warning disable NUnit2005 // Consider using Assert.That(actual, Is.EqualTo(expected)) instead of ClassicAssert.AreEqual(expected, actual)
Code violating the rule here
-#pragma warning restore NUnit2005 // Consider using Assert.That(actual, Is.EqualTo(expected)) instead of Assert.AreEqual(expected, actual)
+#pragma warning restore NUnit2005 // Consider using Assert.That(actual, Is.EqualTo(expected)) instead of ClassicAssert.AreEqual(expected, actual)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2005 // Consider using Assert.That(actual, Is.EqualTo(expected)) instead of Assert.AreEqual(expected, actual)
+#pragma warning disable NUnit2005 // Consider using Assert.That(actual, Is.EqualTo(expected)) instead of ClassicAssert.AreEqual(expected, actual)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2005:Consider using Assert.That(actual, Is.EqualTo(expected)) instead of Assert.AreEqual(expected, actual)",
+ "NUnit2005:Consider using Assert.That(actual, Is.EqualTo(expected)) instead of ClassicAssert.AreEqual(expected, actual)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2006.html b/articles/nunit-analyzers/NUnit2006.html
index 057508a9f..32c0077fb 100644
--- a/articles/nunit-analyzers/NUnit2006.html
+++ b/articles/nunit-analyzers/NUnit2006.html
@@ -86,7 +86,7 @@
NUnit2006
-Consider using Assert.That(actual, Is.Not.EqualTo(expected)) instead of Assert.AreNotEqual(expected, actual)
+Consider using Assert.That(actual, Is.Not.EqualTo(expected)) instead of ClassicAssert.AreNotEqual(expected, actual)
Description
Consider using the constraint model, Assert.That(actual, Is.Not.EqualTo(expected))
, instead of the classic model,
-Assert.AreNotEqual(expected, actual)
.
+ClassicAssert.AreNotEqual(expected, actual)
.
Motivation
-The classic Assert model, Assert.AreNotEqual(expected, actual)
, makes it easy to mix the expected
and the actual
-parameter, so this analyzer marks usages of Assert.AreNotEqual
from the classic Assert model.
+The classic Assert model, ClassicAssert.AreNotEqual(expected, actual)
, makes it easy to mix the expected
and the
+actual
parameter, so this analyzer marks usages of ClassicAssert.AreNotEqual
from the classic Assert model.
[Test]
public void Test()
{
- Assert.AreNotEqual(expression1, expression2)
+ ClassicAssert.AreNotEqual(expression1, expression2)
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.AreNotEqual(expression1, expression2)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.AreNotEqual(expression1, expression2)
with
Assert.That(expression2, Is.Not.EqualTo(expression1))
. So the code block above will be changed into.
[Test]
public void Test()
@@ -144,21 +144,21 @@ Via ruleset file
Configure the severity per project, for more info see
MSDN.
Via .editorconfig file
-# NUnit2006: Consider using Assert.That(actual, Is.Not.EqualTo(expected)) instead of Assert.AreNotEqual(expected, actual)
+# NUnit2006: Consider using Assert.That(actual, Is.Not.EqualTo(expected)) instead of ClassicAssert.AreNotEqual(expected, actual)
dotnet_diagnostic.NUnit2006.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2006 // Consider using Assert.That(actual, Is.Not.EqualTo(expected)) instead of Assert.AreNotEqual(expected, actual)
+#pragma warning disable NUnit2006 // Consider using Assert.That(actual, Is.Not.EqualTo(expected)) instead of ClassicAssert.AreNotEqual(expected, actual)
Code violating the rule here
-#pragma warning restore NUnit2006 // Consider using Assert.That(actual, Is.Not.EqualTo(expected)) instead of Assert.AreNotEqual(expected, actual)
+#pragma warning restore NUnit2006 // Consider using Assert.That(actual, Is.Not.EqualTo(expected)) instead of ClassicAssert.AreNotEqual(expected, actual)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2006 // Consider using Assert.That(actual, Is.Not.EqualTo(expected)) instead of Assert.AreNotEqual(expected, actual)
+#pragma warning disable NUnit2006 // Consider using Assert.That(actual, Is.Not.EqualTo(expected)) instead of ClassicAssert.AreNotEqual(expected, actual)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2006:Consider using Assert.That(actual, Is.Not.EqualTo(expected)) instead of Assert.AreNotEqual(expected, actual)",
+ "NUnit2006:Consider using Assert.That(actual, Is.Not.EqualTo(expected)) instead of ClassicAssert.AreNotEqual(expected, actual)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2007.html b/articles/nunit-analyzers/NUnit2007.html
index ef2e97f5c..9d1361163 100644
--- a/articles/nunit-analyzers/NUnit2007.html
+++ b/articles/nunit-analyzers/NUnit2007.html
@@ -113,7 +113,7 @@ The actual value should not b
Code |
-ConstActualValueUsageAnalyzer |
+ConstActualValueUsageAnalyzer |
@@ -130,7 +130,7 @@ Example Violation
{
var x = 5;
Assert.That(5, Is.EqualTo(x));
- Assert.AreEqual(x, 5);
+ ClassicAssert.AreEqual(x, 5);
}
Explanation
@@ -148,7 +148,7 @@ Fix
{
var x = 5;
Assert.That(x, Is.EqualTo(5));
- Assert.AreEqual(5, x);
+ ClassicAssert.AreEqual(5, x);
}
diff --git a/articles/nunit-analyzers/NUnit2008.html b/articles/nunit-analyzers/NUnit2008.html
index e5893eff3..9763ed497 100644
--- a/articles/nunit-analyzers/NUnit2008.html
+++ b/articles/nunit-analyzers/NUnit2008.html
@@ -113,7 +113,7 @@ Incorrect IgnoreCase usage
Code |
-IgnoreCaseUsageAnalyzer |
+IgnoreCaseUsageAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit2009.html b/articles/nunit-analyzers/NUnit2009.html
index 7b79de71a..b63782f0f 100644
--- a/articles/nunit-analyzers/NUnit2009.html
+++ b/articles/nunit-analyzers/NUnit2009.html
@@ -113,7 +113,7 @@ Code
-SameActualExpectedValueAnalyzer |
+SameActualExpectedValueAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit2010.html b/articles/nunit-analyzers/NUnit2010.html
index 847359897..6a4f1c2c4 100644
--- a/articles/nunit-analyzers/NUnit2010.html
+++ b/articles/nunit-analyzers/NUnit2010.html
@@ -113,7 +113,7 @@ Us
Code |
-EqualConstraintUsageAnalyzer |
+EqualConstraintUsageAnalyzer |
@@ -126,11 +126,11 @@ Motivation
[Test]
public void Test()
{
- Assert.True(actual == expected);
+ ClassicAssert.True(actual == expected);
}
How to fix violations
-
The analyzer comes with a code fix that will replace Assert.True(actual == expected)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.True(actual == expected)
with
Assert.That(actual, Is.EqualTo(expected))
. So the code block above will be changed into
[Test]
public void Test()
@@ -141,7 +141,8 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
# NUnit2010: Use EqualConstraint for better assertion messages in case of failure
dotnet_diagnostic.NUnit2010.severity = chosenSeverity
diff --git a/articles/nunit-analyzers/NUnit2011.html b/articles/nunit-analyzers/NUnit2011.html
index 0e4efb74c..2a3a626b8 100644
--- a/articles/nunit-analyzers/NUnit2011.html
+++ b/articles/nunit-analyzers/NUnit2011.html
@@ -113,7 +113,7 @@
Code |
-StringConstraintUsageAnalyzer |
+StringConstraintUsageAnalyzer |
@@ -128,11 +128,11 @@ Motivation
{
string actual = "...";
string expected = "...";
- Assert.True(actual.Contains(expected));
+ ClassicAssert.True(actual.Contains(expected));
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.True(actual.Contains(expected))
with
+
The analyzer comes with a code fix that will replace ClassicAssert.True(actual.Contains(expected))
with
Assert.That(actual, Does.Contain(expected))
. So the code block above will be changed into
[Test]
public void Test()
@@ -145,7 +145,8 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
# NUnit2011: Use ContainsConstraint for better assertion messages in case of failure
dotnet_diagnostic.NUnit2011.severity = chosenSeverity
diff --git a/articles/nunit-analyzers/NUnit2012.html b/articles/nunit-analyzers/NUnit2012.html
index 88ee072a0..0817264b2 100644
--- a/articles/nunit-analyzers/NUnit2012.html
+++ b/articles/nunit-analyzers/NUnit2012.html
@@ -113,7 +113,7 @@ Code
-StringConstraintUsageAnalyzer |
+StringConstraintUsageAnalyzer |
@@ -128,11 +128,11 @@ Motivation
{
string actual = "...";
string expected = "...";
- Assert.True(actual.StartsWith(expected));
+ ClassicAssert.True(actual.StartsWith(expected));
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.True(actual.StartWith(expected))
with
+
The analyzer comes with a code fix that will replace ClassicAssert.True(actual.StartWith(expected))
with
Assert.That(actual, Does.StartWith(expected))
. So the code block above will be changed into
[Test]
public void Test()
@@ -145,7 +145,8 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
# NUnit2012: Use StartsWithConstraint for better assertion messages in case of failure
dotnet_diagnostic.NUnit2012.severity = chosenSeverity
diff --git a/articles/nunit-analyzers/NUnit2013.html b/articles/nunit-analyzers/NUnit2013.html
index 95af139c3..05479ea4a 100644
--- a/articles/nunit-analyzers/NUnit2013.html
+++ b/articles/nunit-analyzers/NUnit2013.html
@@ -113,7 +113,7 @@
Code |
-StringConstraintUsageAnalyzer |
+StringConstraintUsageAnalyzer |
@@ -128,11 +128,11 @@ Motivation
{
string actual = "...";
string expected = "...";
- Assert.True(actual.EndsWith(expected));
+ ClassicAssert.True(actual.EndsWith(expected));
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.True(actual.EndsWith(expected))
with
+
The analyzer comes with a code fix that will replace ClassicAssert.True(actual.EndsWith(expected))
with
Assert.That(actual, Does.EndWith(expected))
. So the code block above will be changed into
[Test]
public void Test()
@@ -147,7 +147,8 @@ How to fix violations
### Via ruleset file
-Configure the severity per project, for more info see [MSDN](https://learn.microsoft.com/en-us/visualstudio/code-quality/using-rule-sets-to-group-code-analysis-rules?view=vs-2022).
+Configure the severity per project, for more info see
+[MSDN](https://learn.microsoft.com/en-us/visualstudio/code-quality/using-rule-sets-to-group-code-analysis-rules?view=vs-2022).
### Via .editorconfig file
diff --git a/articles/nunit-analyzers/NUnit2014.html b/articles/nunit-analyzers/NUnit2014.html
index 2d2d979f2..96177991b 100644
--- a/articles/nunit-analyzers/NUnit2014.html
+++ b/articles/nunit-analyzers/NUnit2014.html
@@ -113,7 +113,7 @@ Code
-SomeItemsConstraintUsageAnalyzer |
+SomeItemsConstraintUsageAnalyzer |
@@ -128,11 +128,11 @@ Motivation
{
var actual = new List<int> {1,2,3};
int expected = 1;
- Assert.True(actual.Contains(expected));
+ ClassicAssert.True(actual.Contains(expected));
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.True(actual.Contains(expected))
with
+
The analyzer comes with a code fix that will replace ClassicAssert.True(actual.Contains(expected))
with
Assert.That(actual, Does.Contain(expected))
. So the code block above will be changed into
[Test]
public void Test()
@@ -145,7 +145,8 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
# NUnit2014: Use SomeItemsConstraint for better assertion messages in case of failure
dotnet_diagnostic.NUnit2014.severity = chosenSeverity
diff --git a/articles/nunit-analyzers/NUnit2015.html b/articles/nunit-analyzers/NUnit2015.html
index 8a28750ff..eb3460314 100644
--- a/articles/nunit-analyzers/NUnit2015.html
+++ b/articles/nunit-analyzers/NUnit2015.html
@@ -86,7 +86,7 @@
NUnit2015
-Consider using Assert.That(actual, Is.SameAs(expected)) instead of Assert.AreSame(expected, actual)
+Consider using Assert.That(actual, Is.SameAs(expected)) instead of ClassicAssert.AreSame(expected, actual)
Description
Consider using the constraint model, Assert.That(actual, Is.SameAs(expected))
, instead of the classic model,
-Assert.AreSame(expected, actual)
.
+ClassicAssert.AreSame(expected, actual)
.
Motivation
-The assert Assert.AreSame
from the classic Assert model makes it easy to confuse the expected
and the actual
-argument, so this analyzer marks usages of Assert.AreSame
.
+The assert ClassicAssert.AreSame
from the classic Assert model makes it easy to confuse the expected
and the
+actual
argument, so this analyzer marks usages of ClassicAssert.AreSame
.
[Test]
public void Test()
{
- Assert.AreSame(expected, actual);
+ ClassicAssert.AreSame(expected, actual);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.AreSame(expected, actual)
with Assert.That(actual, Is.SameAs(expected))
. So the code block above will be changed into.
+The analyzer comes with a code fix that will replace ClassicAssert.AreSame(expected, actual)
with
+Assert.That(actual, Is.SameAs(expected))
. So the code block above will be changed into.
[Test]
public void Test()
{
@@ -143,21 +144,21 @@ Via ruleset file
Configure the severity per project, for more info see
MSDN.
Via .editorconfig file
-# NUnit2015: Consider using Assert.That(actual, Is.SameAs(expected)) instead of Assert.AreSame(expected, actual)
+# NUnit2015: Consider using Assert.That(actual, Is.SameAs(expected)) instead of ClassicAssert.AreSame(expected, actual)
dotnet_diagnostic.NUnit2015.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2015 // Consider using Assert.That(actual, Is.SameAs(expected)) instead of Assert.AreSame(expected, actual)
+#pragma warning disable NUnit2015 // Consider using Assert.That(actual, Is.SameAs(expected)) instead of ClassicAssert.AreSame(expected, actual)
Code violating the rule here
-#pragma warning restore NUnit2015 // Consider using Assert.That(actual, Is.SameAs(expected)) instead of Assert.AreSame(expected, actual)
+#pragma warning restore NUnit2015 // Consider using Assert.That(actual, Is.SameAs(expected)) instead of ClassicAssert.AreSame(expected, actual)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2015 // Consider using Assert.That(actual, Is.SameAs(expected)) instead of Assert.AreSame(expected, actual)
+#pragma warning disable NUnit2015 // Consider using Assert.That(actual, Is.SameAs(expected)) instead of ClassicAssert.AreSame(expected, actual)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2015:Consider using Assert.That(actual, Is.SameAs(expected)) instead of Assert.AreSame(expected, actual)",
+ "NUnit2015:Consider using Assert.That(actual, Is.SameAs(expected)) instead of ClassicAssert.AreSame(expected, actual)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2016.html b/articles/nunit-analyzers/NUnit2016.html
index 95c3f12e9..a84c406d3 100644
--- a/articles/nunit-analyzers/NUnit2016.html
+++ b/articles/nunit-analyzers/NUnit2016.html
@@ -86,7 +86,7 @@
NUnit2016
-Consider using Assert.That(expr, Is.Null) instead of Assert.Null(expr)
+Consider using Assert.That(expr, Is.Null) instead of ClassicAssert.Null(expr)
Description
-Consider using the constraint model, Assert.That(expr, Is.Null)
, instead of the classic model, Assert.Null(expr)
.
+Consider using the constraint model, Assert.That(expr, Is.Null)
, instead of the classic model,
+ClassicAssert.Null(expr)
.
Motivation
The classic Assert model contains less flexibility than the constraint model,
-so this analyzer marks usages of Assert.Null
from the classic Assert model.
+so this analyzer marks usages of ClassicAssert.Null
from the classic Assert model.
[Test]
public void Test()
{
object obj = null;
- Assert.Null(obj);
+ ClassicAssert.Null(obj);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.Null(expression)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.Null(expression)
with
Assert.That(expression, Is.Null)
. So the code block above will be changed into.
[Test]
public void Test()
@@ -142,23 +143,24 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
-# NUnit2016: Consider using Assert.That(expr, Is.Null) instead of Assert.Null(expr)
+# NUnit2016: Consider using Assert.That(expr, Is.Null) instead of ClassicAssert.Null(expr)
dotnet_diagnostic.NUnit2016.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2016 // Consider using Assert.That(expr, Is.Null) instead of Assert.Null(expr)
+#pragma warning disable NUnit2016 // Consider using Assert.That(expr, Is.Null) instead of ClassicAssert.Null(expr)
Code violating the rule here
-#pragma warning restore NUnit2016 // Consider using Assert.That(expr, Is.Null) instead of Assert.Null(expr)
+#pragma warning restore NUnit2016 // Consider using Assert.That(expr, Is.Null) instead of ClassicAssert.Null(expr)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2016 // Consider using Assert.That(expr, Is.Null) instead of Assert.Null(expr)
+#pragma warning disable NUnit2016 // Consider using Assert.That(expr, Is.Null) instead of ClassicAssert.Null(expr)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2016:Consider using Assert.That(expr, Is.Null) instead of Assert.Null(expr)",
+ "NUnit2016:Consider using Assert.That(expr, Is.Null) instead of ClassicAssert.Null(expr)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2017.html b/articles/nunit-analyzers/NUnit2017.html
index ff55d6a70..dd43a665f 100644
--- a/articles/nunit-analyzers/NUnit2017.html
+++ b/articles/nunit-analyzers/NUnit2017.html
@@ -86,7 +86,7 @@
NUnit2017
-Consider using Assert.That(expr, Is.Null) instead of Assert.IsNull(expr)
+Consider using Assert.That(expr, Is.Null) instead of ClassicAssert.IsNull(expr)
Description
-Consider using the constraint model, Assert.That(expr, Is.Null)
, instead of the classic model, Assert.IsNull(expr)
.
+Consider using the constraint model, Assert.That(expr, Is.Null)
, instead of the classic model,
+ClassicAssert.IsNull(expr)
.
Motivation
The classic Assert model contains less flexibility than the constraint model,
-so this analyzer marks usages of Assert.IsNull
from the classic Assert model.
+so this analyzer marks usages of ClassicAssert.IsNull
from the classic Assert model.
[Test]
public void Test()
{
object obj = null;
- Assert.IsNull(obj);
+ ClassicAssert.IsNull(obj);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.IsNull(expression)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.IsNull(expression)
with
Assert.That(expression, Is.Null)
. So the code block above will be changed into.
[Test]
public void Test()
@@ -142,23 +143,24 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
-# NUnit2017: Consider using Assert.That(expr, Is.Null) instead of Assert.IsNull(expr)
+# NUnit2017: Consider using Assert.That(expr, Is.Null) instead of ClassicAssert.IsNull(expr)
dotnet_diagnostic.NUnit2017.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2017 // Consider using Assert.That(expr, Is.Null) instead of Assert.IsNull(expr)
+#pragma warning disable NUnit2017 // Consider using Assert.That(expr, Is.Null) instead of ClassicAssert.IsNull(expr)
Code violating the rule here
-#pragma warning restore NUnit2017 // Consider using Assert.That(expr, Is.Null) instead of Assert.IsNull(expr)
+#pragma warning restore NUnit2017 // Consider using Assert.That(expr, Is.Null) instead of ClassicAssert.IsNull(expr)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2017 // Consider using Assert.That(expr, Is.Null) instead of Assert.IsNull(expr)
+#pragma warning disable NUnit2017 // Consider using Assert.That(expr, Is.Null) instead of ClassicAssert.IsNull(expr)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2017:Consider using Assert.That(expr, Is.Null) instead of Assert.IsNull(expr)",
+ "NUnit2017:Consider using Assert.That(expr, Is.Null) instead of ClassicAssert.IsNull(expr)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2018.html b/articles/nunit-analyzers/NUnit2018.html
index 16431c837..f4b6f3ee1 100644
--- a/articles/nunit-analyzers/NUnit2018.html
+++ b/articles/nunit-analyzers/NUnit2018.html
@@ -86,7 +86,7 @@
NUnit2018
-Consider using Assert.That(expr, Is.Not.Null) instead of Assert.NotNull(expr)
+Consider using Assert.That(expr, Is.Not.Null) instead of ClassicAssert.NotNull(expr)
Description
-Consider using the constraint model, Assert.That(expr, Is.Not.Null)
, instead of the classic model, Assert.NotNull(expr)
.
+Consider using the constraint model, Assert.That(expr, Is.Not.Null)
, instead of the classic model,
+ClassicAssert.NotNull(expr)
.
Motivation
The classic Assert model contains less flexibility than the constraint model,
-so this analyzer marks usages of Assert.NotNull
from the classic Assert model.
+so this analyzer marks usages of ClassicAssert.NotNull
from the classic Assert model.
[Test]
public void Test()
{
object obj = null;
- Assert.NotNull(obj);
+ ClassicAssert.NotNull(obj);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.NotNull(expression)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.NotNull(expression)
with
Assert.That(expression, Is.Not.Null)
. So the code block above will be changed into.
[Test]
public void Test()
@@ -142,23 +143,24 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
-# NUnit2018: Consider using Assert.That(expr, Is.Not.Null) instead of Assert.NotNull(expr)
+# NUnit2018: Consider using Assert.That(expr, Is.Not.Null) instead of ClassicAssert.NotNull(expr)
dotnet_diagnostic.NUnit2018.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2018 // Consider using Assert.That(expr, Is.Not.Null) instead of Assert.NotNull(expr)
+#pragma warning disable NUnit2018 // Consider using Assert.That(expr, Is.Not.Null) instead of ClassicAssert.NotNull(expr)
Code violating the rule here
-#pragma warning restore NUnit2018 // Consider using Assert.That(expr, Is.Not.Null) instead of Assert.NotNull(expr)
+#pragma warning restore NUnit2018 // Consider using Assert.That(expr, Is.Not.Null) instead of ClassicAssert.NotNull(expr)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2018 // Consider using Assert.That(expr, Is.Not.Null) instead of Assert.NotNull(expr)
+#pragma warning disable NUnit2018 // Consider using Assert.That(expr, Is.Not.Null) instead of ClassicAssert.NotNull(expr)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2018:Consider using Assert.That(expr, Is.Not.Null) instead of Assert.NotNull(expr)",
+ "NUnit2018:Consider using Assert.That(expr, Is.Not.Null) instead of ClassicAssert.NotNull(expr)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2019.html b/articles/nunit-analyzers/NUnit2019.html
index 19ba40e13..5e35598ab 100644
--- a/articles/nunit-analyzers/NUnit2019.html
+++ b/articles/nunit-analyzers/NUnit2019.html
@@ -86,7 +86,7 @@
NUnit2019
-Consider using Assert.That(expr, Is.Not.Null) instead of Assert.IsNotNull(expr)
+Consider using Assert.That(expr, Is.Not.Null) instead of ClassicAssert.IsNotNull(expr)
Description
-Consider using the constraint model, Assert.That(expr, Is.Not.Null)
, instead of the classic model, Assert.IsNotNull(expr)
.
+Consider using the constraint model, Assert.That(expr, Is.Not.Null)
, instead of the classic model,
+ClassicAssert.IsNotNull(expr)
.
Motivation
The classic Assert model contains less flexibility than the constraint model,
-so this analyzer marks usages of Assert.IsNotNull
from the classic Assert model.
+so this analyzer marks usages of ClassicAssert.IsNotNull
from the classic Assert model.
[Test]
public void Test()
{
object obj = null;
- Assert.IsNotNull(obj);
+ ClassicAssert.IsNotNull(obj);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.IsNotNull(expression)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.IsNotNull(expression)
with
Assert.That(expression, Is.Not.Null)
. So the code block above will be changed into.
[Test]
public void Test()
@@ -142,23 +143,24 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
-# NUnit2019: Consider using Assert.That(expr, Is.Not.Null) instead of Assert.IsNotNull(expr)
+# NUnit2019: Consider using Assert.That(expr, Is.Not.Null) instead of ClassicAssert.IsNotNull(expr)
dotnet_diagnostic.NUnit2019.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2019 // Consider using Assert.That(expr, Is.Not.Null) instead of Assert.IsNotNull(expr)
+#pragma warning disable NUnit2019 // Consider using Assert.That(expr, Is.Not.Null) instead of ClassicAssert.IsNotNull(expr)
Code violating the rule here
-#pragma warning restore NUnit2019 // Consider using Assert.That(expr, Is.Not.Null) instead of Assert.IsNotNull(expr)
+#pragma warning restore NUnit2019 // Consider using Assert.That(expr, Is.Not.Null) instead of ClassicAssert.IsNotNull(expr)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2019 // Consider using Assert.That(expr, Is.Not.Null) instead of Assert.IsNotNull(expr)
+#pragma warning disable NUnit2019 // Consider using Assert.That(expr, Is.Not.Null) instead of ClassicAssert.IsNotNull(expr)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2019:Consider using Assert.That(expr, Is.Not.Null) instead of Assert.IsNotNull(expr)",
+ "NUnit2019:Consider using Assert.That(expr, Is.Not.Null) instead of ClassicAssert.IsNotNull(expr)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2020.html b/articles/nunit-analyzers/NUnit2020.html
index d14f153f9..c217e4cfe 100644
--- a/articles/nunit-analyzers/NUnit2020.html
+++ b/articles/nunit-analyzers/NUnit2020.html
@@ -113,7 +113,7 @@ Incompatible types for SameAs
Code |
-SameAsIncompatibleTypesAnalyzer |
+SameAsIncompatibleTypesAnalyzer |
@@ -134,7 +134,8 @@ How to fix violations
Configure severity
Via ruleset file
-
Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
# NUnit2020: Incompatible types for SameAs constraint
dotnet_diagnostic.NUnit2020.severity = chosenSeverity
diff --git a/articles/nunit-analyzers/NUnit2021.html b/articles/nunit-analyzers/NUnit2021.html
index a88fb2da3..8c503f691 100644
--- a/articles/nunit-analyzers/NUnit2021.html
+++ b/articles/nunit-analyzers/NUnit2021.html
@@ -113,7 +113,7 @@ Incompatible types for EqualT
Code |
-EqualToIncompatibleTypesAnalyzer |
+EqualToIncompatibleTypesAnalyzer |
@@ -128,13 +128,15 @@ Motivation
Assert.That(foo, Is.EqualTo(bar));
-There is no way that instances of types Foo
and Bar
could be considered equal, therefore such assertion will always fail.
+There is no way that instances of types Foo
and Bar
could be considered equal, therefore such assertion will always
+fail.
How to fix violations
Fix your assertion (i.e. fix actual or expected value, or choose another constraint).
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
# NUnit2021: Incompatible types for EqualTo constraint
dotnet_diagnostic.NUnit2021.severity = chosenSeverity
diff --git a/articles/nunit-analyzers/NUnit2022.html b/articles/nunit-analyzers/NUnit2022.html
index 8ea90e798..1550382b6 100644
--- a/articles/nunit-analyzers/NUnit2022.html
+++ b/articles/nunit-analyzers/NUnit2022.html
@@ -113,7 +113,7 @@ Missing property required for
Code |
-MissingPropertyAnalyzer |
+MissingPropertyAnalyzer |
@@ -136,7 +136,8 @@ How to fix violations
Configure severity
Via ruleset file
-
Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
# NUnit2022: Missing property required for constraint
dotnet_diagnostic.NUnit2022.severity = chosenSeverity
diff --git a/articles/nunit-analyzers/NUnit2023.html b/articles/nunit-analyzers/NUnit2023.html
index 52cc47df4..00c0c39d5 100644
--- a/articles/nunit-analyzers/NUnit2023.html
+++ b/articles/nunit-analyzers/NUnit2023.html
@@ -113,7 +113,7 @@ Invalid NullConstraint usage
Code |
-NullConstraintUsageAnalyzer |
+NullConstraintUsageAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit2024.html b/articles/nunit-analyzers/NUnit2024.html
index c18841a9c..e13e4a6ed 100644
--- a/articles/nunit-analyzers/NUnit2024.html
+++ b/articles/nunit-analyzers/NUnit2024.html
@@ -113,7 +113,7 @@ Wrong actual type used wi
Code |
-StringConstraintWrongActualTypeAnalyzer |
+StringConstraintWrongActualTypeAnalyzer |
@@ -126,7 +126,8 @@ How to fix violations
Configure severity
Via ruleset file
-
Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
# NUnit2024: Wrong actual type used with String Constraint
dotnet_diagnostic.NUnit2024.severity = chosenSeverity
diff --git a/articles/nunit-analyzers/NUnit2025.html b/articles/nunit-analyzers/NUnit2025.html
index be036855d..87c1ff961 100644
--- a/articles/nunit-analyzers/NUnit2025.html
+++ b/articles/nunit-analyzers/NUnit2025.html
@@ -101,11 +101,11 @@ Wrong actual type used w
Severity |
-Error |
+Hidden |
Enabled |
-True |
+False |
Category |
@@ -113,7 +113,7 @@ Wrong actual type used w
Code |
-ContainsConstraintWrongActualTypeAnalyzer |
+ContainsConstraintWrongActualTypeAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit2026.html b/articles/nunit-analyzers/NUnit2026.html
index 1e57ef655..03da385d8 100644
--- a/articles/nunit-analyzers/NUnit2026.html
+++ b/articles/nunit-analyzers/NUnit2026.html
@@ -113,7 +113,7 @@ Code
-SomeItemsIncompatibleTypesAnalyzer |
+SomeItemsIncompatibleTypesAnalyzer |
diff --git a/articles/nunit-analyzers/NUnit2027.html b/articles/nunit-analyzers/NUnit2027.html
index b88987d92..f9b80c711 100644
--- a/articles/nunit-analyzers/NUnit2027.html
+++ b/articles/nunit-analyzers/NUnit2027.html
@@ -86,7 +86,7 @@
NUnit2027
-Consider using Assert.That(actual, Is.GreaterThan(expected)) instead of Assert.Greater(actual, expected)
+Consider using Assert.That(actual, Is.GreaterThan(expected)) instead of ClassicAssert.Greater(actual, expected)
Description
Consider using the constraint model, Assert.That(actual, Is.GreaterThan(expected))
, instead of the classic model,
-Assert.Greater(actual, expected)
.
+ClassicAssert.Greater(actual, expected)
.
Motivation
-The assert Assert.Greater
from the classic Assert model makes it easy to confuse the expected
and the actual
-argument, so this analyzer marks usages of Assert.Greater
.
+The assert ClassicAssert.Greater
from the classic Assert model makes it easy to confuse the expected
and the actual
+argument, so this analyzer marks usages of ClassicAssert.Greater
.
[Test]
public void Test()
{
- Assert.Greater(actual, expected);
+ ClassicAssert.Greater(actual, expected);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.Greater(actual, expected)
with Assert.That(actual, Is.GreaterThan(expected))
. So the code block above will be changed into.
+The analyzer comes with a code fix that will replace ClassicAssert.Greater(actual, expected)
with
+Assert.That(actual, Is.GreaterThan(expected))
. So the code block above will be changed into.
[Test]
public void Test()
{
@@ -143,21 +144,21 @@ Via ruleset file
Configure the severity per project, for more info see
MSDN.
Via .editorconfig file
-# NUnit2027: Consider using Assert.That(actual, Is.GreaterThan(expected)) instead of Assert.Greater(actual, expected)
+# NUnit2027: Consider using Assert.That(actual, Is.GreaterThan(expected)) instead of ClassicAssert.Greater(actual, expected)
dotnet_diagnostic.NUnit2027.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2027 // Consider using Assert.That(actual, Is.GreaterThan(expected)) instead of Assert.Greater(actual, expected)
+#pragma warning disable NUnit2027 // Consider using Assert.That(actual, Is.GreaterThan(expected)) instead of ClassicAssert.Greater(actual, expected)
Code violating the rule here
-#pragma warning restore NUnit2027 // Consider using Assert.That(actual, Is.GreaterThan(expected)) instead of Assert.Greater(actual, expected)
+#pragma warning restore NUnit2027 // Consider using Assert.That(actual, Is.GreaterThan(expected)) instead of ClassicAssert.Greater(actual, expected)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2027 // Consider using Assert.That(actual, Is.GreaterThan(expected)) instead of Assert.Greater(actual, expected)
+#pragma warning disable NUnit2027 // Consider using Assert.That(actual, Is.GreaterThan(expected)) instead of ClassicAssert.Greater(actual, expected)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2027:Consider using Assert.That(actual, Is.GreaterThan(expected)) instead of Assert.Greater(actual, expected)",
+ "NUnit2027:Consider using Assert.That(actual, Is.GreaterThan(expected)) instead of ClassicAssert.Greater(actual, expected)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2028.html b/articles/nunit-analyzers/NUnit2028.html
index 2749db6f2..eff40267a 100644
--- a/articles/nunit-analyzers/NUnit2028.html
+++ b/articles/nunit-analyzers/NUnit2028.html
@@ -86,7 +86,8 @@
NUnit2028
-Consider using Assert.That(actual, Is.GreaterThanOrEqualTo(expected)) instead of Assert.GreaterOrEqual(actual, expected)
+
+Consider using Assert.That(actual, Is.GreaterThanOrEqualTo(expected)) instead of ClassicAssert.GreaterOrEqual(actual, expected)
Description
Consider using the constraint model, Assert.That(actual, Is.GreaterThanOrEqualTo(expected))
, instead of the classic
-model, Assert.GreaterOrEqual(actual, expected)
.
+model, ClassicAssert.GreaterOrEqual(actual, expected)
.
Motivation
-The assert Assert.GreaterOrEqual
from the classic Assert model makes it easy to confuse the expected
and the
-actual
argument, so this analyzer marks usages of Assert.GreaterOrEqual
.
+The assert ClassicAssert.GreaterOrEqual
from the classic Assert model makes it easy to confuse the expected
and the
+actual
argument, so this analyzer marks usages of ClassicAssert.GreaterOrEqual
.
[Test]
public void Test()
{
- Assert.GreaterOrEqual(actual, expected);
+ ClassicAssert.GreaterOrEqual(actual, expected);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.GreaterOrEqual(actual, expected)
with Assert.That(actual, Is.GreaterThanOrEqualTo(expected))
. So the code block above will be changed into.
+The analyzer comes with a code fix that will replace ClassicAssert.GreaterOrEqual(actual, expected)
with
+Assert.That(actual, Is.GreaterThanOrEqualTo(expected))
. So the code block above will be changed into.
[Test]
public void Test()
{
@@ -143,21 +145,21 @@ Via ruleset file
Configure the severity per project, for more info see
MSDN.
Via .editorconfig file
-# NUnit2028: Consider using Assert.That(actual, Is.GreaterThanOrEqualTo(expected)) instead of Assert.GreaterOrEqual(actual, expected)
+# NUnit2028: Consider using Assert.That(actual, Is.GreaterThanOrEqualTo(expected)) instead of ClassicAssert.GreaterOrEqual(actual, expected)
dotnet_diagnostic.NUnit2028.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2028 // Consider using Assert.That(actual, Is.GreaterThanOrEqualTo(expected)) instead of Assert.GreaterOrEqual(actual, expected)
+#pragma warning disable NUnit2028 // Consider using Assert.That(actual, Is.GreaterThanOrEqualTo(expected)) instead of ClassicAssert.GreaterOrEqual(actual, expected)
Code violating the rule here
-#pragma warning restore NUnit2028 // Consider using Assert.That(actual, Is.GreaterThanOrEqualTo(expected)) instead of Assert.GreaterOrEqual(actual, expected)
+#pragma warning restore NUnit2028 // Consider using Assert.That(actual, Is.GreaterThanOrEqualTo(expected)) instead of ClassicAssert.GreaterOrEqual(actual, expected)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2028 // Consider using Assert.That(actual, Is.GreaterThanOrEqualTo(expected)) instead of Assert.GreaterOrEqual(actual, expected)
+#pragma warning disable NUnit2028 // Consider using Assert.That(actual, Is.GreaterThanOrEqualTo(expected)) instead of ClassicAssert.GreaterOrEqual(actual, expected)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2028:Consider using Assert.That(actual, Is.GreaterThanOrEqualTo(expected)) instead of Assert.GreaterOrEqual(actual, expected)",
+ "NUnit2028:Consider using Assert.That(actual, Is.GreaterThanOrEqualTo(expected)) instead of ClassicAssert.GreaterOrEqual(actual, expected)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2029.html b/articles/nunit-analyzers/NUnit2029.html
index 80baf9594..a377b1cce 100644
--- a/articles/nunit-analyzers/NUnit2029.html
+++ b/articles/nunit-analyzers/NUnit2029.html
@@ -86,7 +86,7 @@
NUnit2029
-Consider using Assert.That(actual, Is.LessThan(expected)) instead of Assert.Less(actual, expected)
+Consider using Assert.That(actual, Is.LessThan(expected)) instead of ClassicAssert.Less(actual, expected)
Description
Consider using the constraint model, Assert.That(actual, Is.LessThan(expected))
, instead of the classic model,
-Assert.Less(actual, expected)
.
+ClassicAssert.Less(actual, expected)
.
Motivation
-The assert Assert.Less
from the classic Assert model makes it easy to confuse the expected
and the actual
-argument, so this analyzer marks usages of Assert.Less
.
+The assert ClassicAssert.Less
from the classic Assert model makes it easy to confuse the expected
and the actual
+argument, so this analyzer marks usages of ClassicAssert.Less
.
[Test]
public void Test()
{
- Assert.Less(actual, expected);
+ ClassicAssert.Less(actual, expected);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.Less(actual, expected)
with Assert.That(actual, Is.LessThan(expected))
. So the code block above will be changed into.
+The analyzer comes with a code fix that will replace ClassicAssert.Less(actual, expected)
with
+Assert.That(actual, Is.LessThan(expected))
. So the code block above will be changed into.
[Test]
public void Test()
{
@@ -143,21 +144,21 @@ Via ruleset file
Configure the severity per project, for more info see
MSDN.
Via .editorconfig file
-# NUnit2029: Consider using Assert.That(actual, Is.LessThan(expected)) instead of Assert.Less(actual, expected)
+# NUnit2029: Consider using Assert.That(actual, Is.LessThan(expected)) instead of ClassicAssert.Less(actual, expected)
dotnet_diagnostic.NUnit2029.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2029 // Consider using Assert.That(actual, Is.LessThan(expected)) instead of Assert.Less(actual, expected)
+#pragma warning disable NUnit2029 // Consider using Assert.That(actual, Is.LessThan(expected)) instead of ClassicAssert.Less(actual, expected)
Code violating the rule here
-#pragma warning restore NUnit2029 // Consider using Assert.That(actual, Is.LessThan(expected)) instead of Assert.Less(actual, expected)
+#pragma warning restore NUnit2029 // Consider using Assert.That(actual, Is.LessThan(expected)) instead of ClassicAssert.Less(actual, expected)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2029 // Consider using Assert.That(actual, Is.LessThan(expected)) instead of Assert.Less(actual, expected)
+#pragma warning disable NUnit2029 // Consider using Assert.That(actual, Is.LessThan(expected)) instead of ClassicAssert.Less(actual, expected)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2029:Consider using Assert.That(actual, Is.LessThan(expected)) instead of Assert.Less(actual, expected)",
+ "NUnit2029:Consider using Assert.That(actual, Is.LessThan(expected)) instead of ClassicAssert.Less(actual, expected)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2030.html b/articles/nunit-analyzers/NUnit2030.html
index 17d472b7e..fec490758 100644
--- a/articles/nunit-analyzers/NUnit2030.html
+++ b/articles/nunit-analyzers/NUnit2030.html
@@ -86,7 +86,7 @@
NUnit2030
-Consider using Assert.That(actual, Is.LessThanOrEqualTo(expected)) instead of Assert.LessOrEqual(actual, expected)
+Consider using Assert.That(actual, Is.LessThanOrEqualTo(expected)) instead of ClassicAssert.LessOrEqual(actual, expected)
Description
Consider using the constraint model, Assert.That(actual, Is.LessThanOrEqualTo(expected))
, instead of the classic
-model, Assert.LessOrEqual(actual, expected)
.
+model, ClassicAssert.LessOrEqual(actual, expected)
.
Motivation
-The assert Assert.LessOrEqual
from the classic Assert model makes it easy to confuse the expected
and the actual
-argument, so this analyzer marks usages of Assert.LessOrEqual
.
+The assert ClassicAssert.LessOrEqual
from the classic Assert model makes it easy to confuse the expected
and the
+actual
argument, so this analyzer marks usages of ClassicAssert.LessOrEqual
.
[Test]
public void Test()
{
- Assert.LessOrEqual(actual, expected);
+ ClassicAssert.LessOrEqual(actual, expected);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.LessOrEqual(actual, expected)
with Assert.That(actual, Is.LessThanOrEqualTo(expected))
. So the code block above will be changed into.
+The analyzer comes with a code fix that will replace ClassicAssert.LessOrEqual(actual, expected)
with
+Assert.That(actual, Is.LessThanOrEqualTo(expected))
. So the code block above will be changed into.
[Test]
public void Test()
{
@@ -143,21 +144,21 @@ Via ruleset file
Configure the severity per project, for more info see
MSDN.
Via .editorconfig file
-# NUnit2030: Consider using Assert.That(actual, Is.LessThanOrEqualTo(expected)) instead of Assert.LessOrEqual(actual, expected)
+# NUnit2030: Consider using Assert.That(actual, Is.LessThanOrEqualTo(expected)) instead of ClassicAssert.LessOrEqual(actual, expected)
dotnet_diagnostic.NUnit2030.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2030 // Consider using Assert.That(actual, Is.LessThanOrEqualTo(expected)) instead of Assert.LessOrEqual(actual, expected)
+#pragma warning disable NUnit2030 // Consider using Assert.That(actual, Is.LessThanOrEqualTo(expected)) instead of ClassicAssert.LessOrEqual(actual, expected)
Code violating the rule here
-#pragma warning restore NUnit2030 // Consider using Assert.That(actual, Is.LessThanOrEqualTo(expected)) instead of Assert.LessOrEqual(actual, expected)
+#pragma warning restore NUnit2030 // Consider using Assert.That(actual, Is.LessThanOrEqualTo(expected)) instead of ClassicAssert.LessOrEqual(actual, expected)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2030 // Consider using Assert.That(actual, Is.LessThanOrEqualTo(expected)) instead of Assert.LessOrEqual(actual, expected)
+#pragma warning disable NUnit2030 // Consider using Assert.That(actual, Is.LessThanOrEqualTo(expected)) instead of ClassicAssert.LessOrEqual(actual, expected)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2030:Consider using Assert.That(actual, Is.LessThanOrEqualTo(expected)) instead of Assert.LessOrEqual(actual, expected)",
+ "NUnit2030:Consider using Assert.That(actual, Is.LessThanOrEqualTo(expected)) instead of ClassicAssert.LessOrEqual(actual, expected)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2031.html b/articles/nunit-analyzers/NUnit2031.html
index f4ffd1ad4..71b53d0f3 100644
--- a/articles/nunit-analyzers/NUnit2031.html
+++ b/articles/nunit-analyzers/NUnit2031.html
@@ -86,7 +86,7 @@
NUnit2031
-Consider using Assert.That(actual, Is.Not.SameAs(expected)) instead of Assert.AreNotSame(expected, actual)
+Consider using Assert.That(actual, Is.Not.SameAs(expected)) instead of ClassicAssert.AreNotSame(expected, actual)
Description
Consider using the constraint model, Assert.That(actual, Is.Not.SameAs(expected))
, instead of the classic model,
-Assert.AreNotSame(expected, actual)
.
+ClassicAssert.AreNotSame(expected, actual)
.
Motivation
-The assert Assert.AreNotSame
from the classic Assert model makes it easy to confuse the expected
and the actual
-argument, so this analyzer marks usages of Assert.AreNotSame
.
+The assert ClassicAssert.AreNotSame
from the classic Assert model makes it easy to confuse the expected
and the
+actual
argument, so this analyzer marks usages of ClassicAssert.AreNotSame
.
[Test]
public void Test()
{
- Assert.AreNotSame(expected, actual);
+ ClassicAssert.AreNotSame(expected, actual);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.AreNotSame(expected, actual)
with Assert.That(actual, Is.Not.SameAs(expected))
. So the code block above will be changed into.
+The analyzer comes with a code fix that will replace ClassicAssert.AreNotSame(expected, actual)
with
+Assert.That(actual, Is.Not.SameAs(expected))
. So the code block above will be changed into.
[Test]
public void Test()
{
@@ -143,21 +144,21 @@ Via ruleset file
Configure the severity per project, for more info see
MSDN.
Via .editorconfig file
-# NUnit2031: Consider using Assert.That(actual, Is.Not.SameAs(expected)) instead of Assert.AreNotSame(expected, actual)
+# NUnit2031: Consider using Assert.That(actual, Is.Not.SameAs(expected)) instead of ClassicAssert.AreNotSame(expected, actual)
dotnet_diagnostic.NUnit2031.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2031 // Consider using Assert.That(actual, Is.Not.SameAs(expected)) instead of Assert.AreNotSame(expected, actual)
+#pragma warning disable NUnit2031 // Consider using Assert.That(actual, Is.Not.SameAs(expected)) instead of ClassicAssert.AreNotSame(expected, actual)
Code violating the rule here
-#pragma warning restore NUnit2031 // Consider using Assert.That(actual, Is.Not.SameAs(expected)) instead of Assert.AreNotSame(expected, actual)
+#pragma warning restore NUnit2031 // Consider using Assert.That(actual, Is.Not.SameAs(expected)) instead of ClassicAssert.AreNotSame(expected, actual)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2031 // Consider using Assert.That(actual, Is.Not.SameAs(expected)) instead of Assert.AreNotSame(expected, actual)
+#pragma warning disable NUnit2031 // Consider using Assert.That(actual, Is.Not.SameAs(expected)) instead of ClassicAssert.AreNotSame(expected, actual)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2031:Consider using Assert.That(actual, Is.Not.SameAs(expected)) instead of Assert.AreNotSame(expected, actual)",
+ "NUnit2031:Consider using Assert.That(actual, Is.Not.SameAs(expected)) instead of ClassicAssert.AreNotSame(expected, actual)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2032.html b/articles/nunit-analyzers/NUnit2032.html
index 3a1f2f9f2..69705ce8d 100644
--- a/articles/nunit-analyzers/NUnit2032.html
+++ b/articles/nunit-analyzers/NUnit2032.html
@@ -86,7 +86,7 @@
NUnit2032
-Consider using Assert.That(expr, Is.Zero) instead of Assert.Zero(expr)
+Consider using Assert.That(expr, Is.Zero) instead of ClassicAssert.Zero(expr)
Description
-Consider using the constraint model, Assert.That(expr, Is.Zero)
, instead of the classic model, Assert.Zero(expr)
.
+Consider using the constraint model, Assert.That(expr, Is.Zero)
, instead of the classic model,
+ClassicAssert.Zero(expr)
.
Motivation
The classic Assert model contains less flexibility than the constraint model,
-so this analyzer marks usages of Assert.Zero
from the classic Assert model.
+so this analyzer marks usages of ClassicAssert.Zero
from the classic Assert model.
[Test]
public void Test()
{
- Assert.Zero(expression);
+ ClassicAssert.Zero(expression);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.Zero(expression)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.Zero(expression)
with
Assert.That(expression, Is.Zero)
. So the code block above will be changed into.
[Test]
public void Test()
@@ -140,23 +141,24 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
-# NUnit2032: Consider using Assert.That(expr, Is.Zero) instead of Assert.Zero(expr)
+# NUnit2032: Consider using Assert.That(expr, Is.Zero) instead of ClassicAssert.Zero(expr)
dotnet_diagnostic.NUnit2032.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2032 // Consider using Assert.That(expr, Is.Zero) instead of Assert.Zero(expr)
+#pragma warning disable NUnit2032 // Consider using Assert.That(expr, Is.Zero) instead of ClassicAssert.Zero(expr)
Code violating the rule here
-#pragma warning restore NUnit2032 // Consider using Assert.That(expr, Is.Zero) instead of Assert.Zero(expr)
+#pragma warning restore NUnit2032 // Consider using Assert.That(expr, Is.Zero) instead of ClassicAssert.Zero(expr)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2032 // Consider using Assert.That(expr, Is.Zero) instead of Assert.Zero(expr)
+#pragma warning disable NUnit2032 // Consider using Assert.That(expr, Is.Zero) instead of ClassicAssert.Zero(expr)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2032:Consider using Assert.That(expr, Is.Zero) instead of Assert.Zero(expr)",
+ "NUnit2032:Consider using Assert.That(expr, Is.Zero) instead of ClassicAssert.Zero(expr)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2033.html b/articles/nunit-analyzers/NUnit2033.html
index 16f863e2b..e1548c050 100644
--- a/articles/nunit-analyzers/NUnit2033.html
+++ b/articles/nunit-analyzers/NUnit2033.html
@@ -86,7 +86,7 @@
NUnit2033
-Consider using Assert.That(expr, Is.Not.Zero) instead of Assert.NotZero(expr)
+Consider using Assert.That(expr, Is.Not.Zero) instead of ClassicAssert.NotZero(expr)
Description
-Consider using the constraint model, Assert.That(expr, Is.Not.Zero)
, instead of the classic model, Assert.NotZero(expr)
.
+Consider using the constraint model, Assert.That(expr, Is.Not.Zero)
, instead of the classic model,
+ClassicAssert.NotZero(expr)
.
Motivation
The classic Assert model contains less flexibility than the constraint model,
-so this analyzer marks usages of Assert.NotZero
from the classic Assert model.
+so this analyzer marks usages of ClassicAssert.NotZero
from the classic Assert model.
[Test]
public void Test()
{
- Assert.NotZero(expression);
+ ClassicAssert.NotZero(expression);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.NotZero(expression)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.NotZero(expression)
with
Assert.That(expression, Is.Not.Zero)
. So the code block above will be changed into.
[Test]
public void Test()
@@ -140,23 +141,24 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
-# NUnit2033: Consider using Assert.That(expr, Is.Not.Zero) instead of Assert.NotZero(expr)
+# NUnit2033: Consider using Assert.That(expr, Is.Not.Zero) instead of ClassicAssert.NotZero(expr)
dotnet_diagnostic.NUnit2033.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2033 // Consider using Assert.That(expr, Is.Not.Zero) instead of Assert.NotZero(expr)
+#pragma warning disable NUnit2033 // Consider using Assert.That(expr, Is.Not.Zero) instead of ClassicAssert.NotZero(expr)
Code violating the rule here
-#pragma warning restore NUnit2033 // Consider using Assert.That(expr, Is.Not.Zero) instead of Assert.NotZero(expr)
+#pragma warning restore NUnit2033 // Consider using Assert.That(expr, Is.Not.Zero) instead of ClassicAssert.NotZero(expr)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2033 // Consider using Assert.That(expr, Is.Not.Zero) instead of Assert.NotZero(expr)
+#pragma warning disable NUnit2033 // Consider using Assert.That(expr, Is.Not.Zero) instead of ClassicAssert.NotZero(expr)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2033:Consider using Assert.That(expr, Is.Not.Zero) instead of Assert.NotZero(expr)",
+ "NUnit2033:Consider using Assert.That(expr, Is.Not.Zero) instead of ClassicAssert.NotZero(expr)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2034.html b/articles/nunit-analyzers/NUnit2034.html
index 29d3ead73..21ca70910 100644
--- a/articles/nunit-analyzers/NUnit2034.html
+++ b/articles/nunit-analyzers/NUnit2034.html
@@ -86,7 +86,7 @@
NUnit2034
-Consider using Assert.That(expr, Is.NaN) instead of Assert.IsNaN(expr)
+Consider using Assert.That(expr, Is.NaN) instead of ClassicAssert.IsNaN(expr)
Description
-Consider using the constraint model, Assert.That(expr, Is.NaN)
, instead of the classic model, Assert.IsNaN(expr)
.
+Consider using the constraint model, Assert.That(expr, Is.NaN)
, instead of the classic model,
+ClassicAssert.IsNaN(expr)
.
Motivation
The classic Assert model contains less flexibility than the constraint model,
-so this analyzer marks usages of Assert.IsNaN
from the classic Assert model.
+so this analyzer marks usages of ClassicAssert.IsNaN
from the classic Assert model.
[Test]
public void Test()
{
- Assert.IsNaN(expression);
+ ClassicAssert.IsNaN(expression);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.IsNaN(expression)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.IsNaN(expression)
with
Assert.That(expression, Is.NaN)
. So the code block above will be changed into.
[Test]
public void Test()
@@ -140,23 +141,24 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
-# NUnit2034: Consider using Assert.That(expr, Is.NaN) instead of Assert.IsNaN(expr)
+# NUnit2034: Consider using Assert.That(expr, Is.NaN) instead of ClassicAssert.IsNaN(expr)
dotnet_diagnostic.NUnit2034.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2034 // Consider using Assert.That(expr, Is.NaN) instead of Assert.IsNaN(expr)
+#pragma warning disable NUnit2034 // Consider using Assert.That(expr, Is.NaN) instead of ClassicAssert.IsNaN(expr)
Code violating the rule here
-#pragma warning restore NUnit2034 // Consider using Assert.That(expr, Is.NaN) instead of Assert.IsNaN(expr)
+#pragma warning restore NUnit2034 // Consider using Assert.That(expr, Is.NaN) instead of ClassicAssert.IsNaN(expr)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2034 // Consider using Assert.That(expr, Is.NaN) instead of Assert.IsNaN(expr)
+#pragma warning disable NUnit2034 // Consider using Assert.That(expr, Is.NaN) instead of ClassicAssert.IsNaN(expr)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2034:Consider using Assert.That(expr, Is.NaN) instead of Assert.IsNaN(expr)",
+ "NUnit2034:Consider using Assert.That(expr, Is.NaN) instead of ClassicAssert.IsNaN(expr)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2035.html b/articles/nunit-analyzers/NUnit2035.html
index 140cf5d54..c961ae19e 100644
--- a/articles/nunit-analyzers/NUnit2035.html
+++ b/articles/nunit-analyzers/NUnit2035.html
@@ -86,7 +86,7 @@
NUnit2035
-Consider using Assert.That(collection, Is.Empty) instead of Assert.IsEmpty(collection)
+Consider using Assert.That(collection, Is.Empty) instead of ClassicAssert.IsEmpty(collection)
Description
-Consider using the constraint model, Assert.That(collection, Is.Empty)
, instead of the classic model, Assert.IsEmpty(collection)
.
+Consider using the constraint model, Assert.That(collection, Is.Empty)
, instead of the classic model,
+ClassicAssert.IsEmpty(collection)
.
Motivation
The classic Assert model contains less flexibility than the constraint model,
-so this analyzer marks usages of Assert.IsEmpty
from the classic Assert model.
+so this analyzer marks usages of ClassicAssert.IsEmpty
from the classic Assert model.
[Test]
public void Test()
{
- Assert.IsEmpty(collection);
+ ClassicAssert.IsEmpty(collection);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.IsEmpty(collection)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.IsEmpty(collection)
with
Assert.That(collection, Is.Empty)
. So the code block above will be changed into.
[Test]
public void Test()
@@ -140,23 +141,24 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
-# NUnit2035: Consider using Assert.That(collection, Is.Empty) instead of Assert.IsEmpty(collection)
+# NUnit2035: Consider using Assert.That(collection, Is.Empty) instead of ClassicAssert.IsEmpty(collection)
dotnet_diagnostic.NUnit2035.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2035 // Consider using Assert.That(collection, Is.Empty) instead of Assert.IsEmpty(collection)
+#pragma warning disable NUnit2035 // Consider using Assert.That(collection, Is.Empty) instead of ClassicAssert.IsEmpty(collection)
Code violating the rule here
-#pragma warning restore NUnit2035 // Consider using Assert.That(collection, Is.Empty) instead of Assert.IsEmpty(collection)
+#pragma warning restore NUnit2035 // Consider using Assert.That(collection, Is.Empty) instead of ClassicAssert.IsEmpty(collection)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2035 // Consider using Assert.That(collection, Is.Empty) instead of Assert.IsEmpty(collection)
+#pragma warning disable NUnit2035 // Consider using Assert.That(collection, Is.Empty) instead of ClassicAssert.IsEmpty(collection)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2035:Consider using Assert.That(collection, Is.Empty) instead of Assert.IsEmpty(collection)",
+ "NUnit2035:Consider using Assert.That(collection, Is.Empty) instead of ClassicAssert.IsEmpty(collection)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2036.html b/articles/nunit-analyzers/NUnit2036.html
index 6abe74165..56fa99788 100644
--- a/articles/nunit-analyzers/NUnit2036.html
+++ b/articles/nunit-analyzers/NUnit2036.html
@@ -86,7 +86,7 @@
NUnit2036
-Consider using Assert.That(collection, Is.Not.Empty) instead of Assert.IsNotEmpty(collection)
+Consider using Assert.That(collection, Is.Not.Empty) instead of ClassicAssert.IsNotEmpty(collection)
Description
-Consider using the constraint model, Assert.That(collection, Is.Not.Empty)
, instead of the classic model, Assert.IsNotEmpty(collection)
.
+Consider using the constraint model, Assert.That(collection, Is.Not.Empty)
, instead of the classic model,
+ClassicAssert.IsNotEmpty(collection)
.
Motivation
The classic Assert model contains less flexibility than the constraint model,
-so this analyzer marks usages of Assert.IsNotEmpty
from the classic Assert model.
+so this analyzer marks usages of ClassicAssert.IsNotEmpty
from the classic Assert model.
[Test]
public void Test()
{
- Assert.IsNotEmpty(collection);
+ ClassicAssert.IsNotEmpty(collection);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.IsNotEmpty(collection)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.IsNotEmpty(collection)
with
Assert.That(collection, Is.Not.Empty)
. So the code block above will be changed into.
[Test]
public void Test()
@@ -140,23 +141,24 @@ How to fix violations
Configure severity
Via ruleset file
-Configure the severity per project, for more info see MSDN.
+Configure the severity per project, for more info see
+MSDN.
Via .editorconfig file
-# NUnit2036: Consider using Assert.That(collection, Is.Not.Empty) instead of Assert.IsNotEmpty(collection)
+# NUnit2036: Consider using Assert.That(collection, Is.Not.Empty) instead of ClassicAssert.IsNotEmpty(collection)
dotnet_diagnostic.NUnit2036.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2036 // Consider using Assert.That(collection, Is.Not.Empty) instead of Assert.IsNotEmpty(collection)
+#pragma warning disable NUnit2036 // Consider using Assert.That(collection, Is.Not.Empty) instead of ClassicAssert.IsNotEmpty(collection)
Code violating the rule here
-#pragma warning restore NUnit2036 // Consider using Assert.That(collection, Is.Not.Empty) instead of Assert.IsNotEmpty(collection)
+#pragma warning restore NUnit2036 // Consider using Assert.That(collection, Is.Not.Empty) instead of ClassicAssert.IsNotEmpty(collection)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2036 // Consider using Assert.That(collection, Is.Not.Empty) instead of Assert.IsNotEmpty(collection)
+#pragma warning disable NUnit2036 // Consider using Assert.That(collection, Is.Not.Empty) instead of ClassicAssert.IsNotEmpty(collection)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2036:Consider using Assert.That(collection, Is.Not.Empty) instead of Assert.IsNotEmpty(collection)",
+ "NUnit2036:Consider using Assert.That(collection, Is.Not.Empty) instead of ClassicAssert.IsNotEmpty(collection)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2037.html b/articles/nunit-analyzers/NUnit2037.html
index faf24d677..c0662786b 100644
--- a/articles/nunit-analyzers/NUnit2037.html
+++ b/articles/nunit-analyzers/NUnit2037.html
@@ -86,7 +86,7 @@
NUnit2037
-Consider using Assert.That(collection, Does.Contain(instance)) instead of Assert.Contains(instance, collection)
+Consider using Assert.That(collection, Does.Contain(instance)) instead of ClassicAssert.Contains(instance, collection)
Description
Consider using the constraint model, Assert.That(collection, Does.Contain(instance))
, instead of the classic model,
-Assert.Contains(instance, collection)
.
+ClassicAssert.Contains(instance, collection)
.
Motivation
-The assert Assert.Contains
from the classic Assert model makes it easy to confuse the instance
and the collection
-argument, so this analyzer marks usages of Assert.Contains
.
+The assert ClassicAssert.Contains
from the classic Assert model makes it easy to confuse the instance
and the
+collection
argument, so this analyzer marks usages of ClassicAssert.Contains
.
[Test]
public void Test()
{
- Assert.Contains(instance, collection);
+ ClassicAssert.Contains(instance, collection);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.Contains(instance, collection)
with
+
The analyzer comes with a code fix that will replace ClassicAssert.Contains(instance, collection)
with
Assert.That(collection, Does.Contain(instance))
. So the code block above will be changed into.
[Test]
public void Test()
@@ -144,21 +144,21 @@ Via ruleset file
Configure the severity per project, for more info see
MSDN.
Via .editorconfig file
-# NUnit2037: Consider using Assert.That(collection, Does.Contain(instance)) instead of Assert.Contains(instance, collection)
+# NUnit2037: Consider using Assert.That(collection, Does.Contain(instance)) instead of ClassicAssert.Contains(instance, collection)
dotnet_diagnostic.NUnit2037.severity = chosenSeverity
where chosenSeverity
can be one of none
, silent
, suggestion
, warning
, or error
.
Via #pragma directive
-#pragma warning disable NUnit2037 // Consider using Assert.That(collection, Does.Contain(instance)) instead of Assert.Contains(instance, collection)
+#pragma warning disable NUnit2037 // Consider using Assert.That(collection, Does.Contain(instance)) instead of ClassicAssert.Contains(instance, collection)
Code violating the rule here
-#pragma warning restore NUnit2037 // Consider using Assert.That(collection, Does.Contain(instance)) instead of Assert.Contains(instance, collection)
+#pragma warning restore NUnit2037 // Consider using Assert.That(collection, Does.Contain(instance)) instead of ClassicAssert.Contains(instance, collection)
Or put this at the top of the file to disable all instances.
-#pragma warning disable NUnit2037 // Consider using Assert.That(collection, Does.Contain(instance)) instead of Assert.Contains(instance, collection)
+#pragma warning disable NUnit2037 // Consider using Assert.That(collection, Does.Contain(instance)) instead of ClassicAssert.Contains(instance, collection)
Via attribute [SuppressMessage]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion",
- "NUnit2037:Consider using Assert.That(collection, Does.Contain(instance)) instead of Assert.Contains(instance, collection)",
+ "NUnit2037:Consider using Assert.That(collection, Does.Contain(instance)) instead of ClassicAssert.Contains(instance, collection)",
Justification = "Reason...")]
diff --git a/articles/nunit-analyzers/NUnit2038.html b/articles/nunit-analyzers/NUnit2038.html
index f65943f05..c274cbe82 100644
--- a/articles/nunit-analyzers/NUnit2038.html
+++ b/articles/nunit-analyzers/NUnit2038.html
@@ -86,7 +86,7 @@
NUnit2038
-Consider using Assert.That(actual, Is.InstanceOf(expected)) instead of Assert.IsInstanceOf(expected, actual)
+Consider using Assert.That(actual, Is.InstanceOf(expected)) instead of ClassicAssert.IsInstanceOf(expected, actual)
Description
Consider using the constraint model, Assert.That(actual, Is.InstanceOf(expected))
, instead of the classic model,
-Assert.IsInstanceOf(expected, actual)
.
+ClassicAssert.IsInstanceOf(expected, actual)
.
Motivation
-The assert Assert.IsInstanceOf
from the classic Assert model makes it easy to confuse the expected
and the actual
-argument, so this analyzer marks usages of Assert.IsInstanceOf
.
+The assert ClassicAssert.IsInstanceOf
from the classic Assert model makes it easy to confuse the expected
and the
+actual
argument, so this analyzer marks usages of ClassicAssert.IsInstanceOf
.
[Test]
public void Test()
{
- Assert.IsInstanceOf(expected, actual);
+ ClassicAssert.IsInstanceOf(expected, actual);
}
How to fix violations
-The analyzer comes with a code fix that will replace Assert.IsInstanceOf(expected, actual)
with Assert.That(actual, Is.InstanceOf(expected))
. So the code block above will be changed into.
+The analyzer comes with a code fix that will replace ClassicAssert.IsInstanceOf(expected, actual)
with
+Assert.That(actual, Is.InstanceOf(expected))
. So the code block above will be changed into.
[Test]
public void Test()
{
@@ -143,21 +144,21 @@ Via ruleset file
Configure the severity per project, for more info see
MSDN.
Via .editorconfig file
-# NUnit2038: Consider using Assert.That(actual, Is.InstanceOf(expected)) instead of Assert.IsInstanceOf(expected, actual)
+