Skip to content

Commit

Permalink
Code review commit.
Browse files Browse the repository at this point in the history
Use ClassicAssert consistently.
  • Loading branch information
manfred-brands committed Oct 28, 2023
1 parent 669ee3a commit ecdf110
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ namespace NUnit.Analyzers.Tests.DiagnosticSuppressors
{
public class DereferencePossiblyNullReferenceSuppressorTests
{
#if NUNIT4
private const string ClassicAssert = "ClassicAssert";
#else
private const string ClassicAssert = "Assert";
#endif

private const string ABDefinition = @"
private static A? GetA(bool create) => create ? new A() : default(A);
Expand Down Expand Up @@ -129,7 +123,7 @@ public void Parameter()
[TestCase("""")]
public void Test(string? s)
{{
{ClassicAssert}.NotNull(s);
ClassicAssert.NotNull(s);
DoSomething(↓s);
}}
Expand All @@ -152,7 +146,7 @@ public void NullableCast()
public void Test()
{{
int? possibleNull = GetNext();
{ClassicAssert}.NotNull(possibleNull);
ClassicAssert.NotNull(possibleNull);
int i = ↓(int)possibleNull;
AssertOne(i);
}}
Expand Down Expand Up @@ -255,7 +249,7 @@ public void WithReassignedAfterAssert()
[TestCase("""")]
public void Test(string? s)
{{
{ClassicAssert}.NotNull(s);
ClassicAssert.NotNull(s);
s = null;
Assert.That(↓s.Length, Is.GreaterThan(0));
}}
Expand All @@ -274,7 +268,7 @@ public void WithReassignedFieldAfterAssert()
[Test]
public void Test()
{{
{ClassicAssert}.NotNull(this.s);
ClassicAssert.NotNull(this.s);
this.s = null;
Assert.That(↓this.s.Length, Is.GreaterThan(0));
}}
Expand Down Expand Up @@ -357,7 +351,7 @@ public void Test(string? s)
{{
Assert.Multiple(() =>
{{
{ClassicAssert}.NotNull(s);
ClassicAssert.NotNull(s);
Assert.That(↓s.Length, Is.GreaterThan(0));
}});
}}
Expand All @@ -368,8 +362,8 @@ public void Test(string? s)
testCode);
}

[TestCase($"{ClassicAssert}.True(nullable.HasValue)")]
[TestCase($"{ClassicAssert}.IsTrue(nullable.HasValue)")]
[TestCase("ClassicAssert.True(nullable.HasValue)")]
[TestCase("ClassicAssert.IsTrue(nullable.HasValue)")]
[TestCase("Assert.That(nullable.HasValue, \"Ensure Value is set\")")]
[TestCase("Assert.That(nullable.HasValue)")]
[TestCase("Assert.That(nullable.HasValue, Is.True)")]
Expand All @@ -390,8 +384,8 @@ public void Test(int? nullable)
testCode);
}

[TestCase($"{ClassicAssert}.False(nullable.HasValue)")]
[TestCase($"{ClassicAssert}.IsFalse(nullable.HasValue)")]
[TestCase("ClassicAssert.False(nullable.HasValue)")]
[TestCase("ClassicAssert.IsFalse(nullable.HasValue)")]
[TestCase("Assert.That(!nullable.HasValue)")]
[TestCase("Assert.That(nullable.HasValue, Is.False)")]
[TestCase("Assert.That(nullable, Is.Null)")]
Expand Down Expand Up @@ -786,7 +780,7 @@ public void Test()
{{
object? possibleNull = GetNext();
object? assertedNotNull = possibleNull;
{ClassicAssert}.NotNull(assertedNotNull);
ClassicAssert.NotNull(assertedNotNull);
↓DoNothing(assertedNotNull);
}}
Expand All @@ -812,7 +806,7 @@ public void Test()
{{
object? possibleNull = GetNext();
object? assertedNotNull = GetNext();
{ClassicAssert}.NotNull(assertedNotNull);
ClassicAssert.NotNull(assertedNotNull);
↓DoNothing(assertedNotNull, possibleNull);
}}
Expand All @@ -839,7 +833,7 @@ public void Test()
{{
object? possibleNull = GetNext();
object? assertedNotNull = GetNext();
{ClassicAssert}.NotNull(assertedNotNull);
ClassicAssert.NotNull(assertedNotNull);
↓DoNothing(assertedNotNull, assertedNotNull);
}}
Expand All @@ -866,7 +860,7 @@ public void Test()
{{
object? possibleNull = GetNext();
object? assertedNotNull = GetNext();
{ClassicAssert}.NotNull(assertedNotNull);
ClassicAssert.NotNull(assertedNotNull);
↓DoNothing(assertedNotNull, assertedNotNull);
}}
Expand All @@ -892,7 +886,7 @@ public void Test()
{{
object? possibleNull = GetNext();
object? assertedNotNull = possibleNull;
{ClassicAssert}.NotNull(assertedNotNull);
ClassicAssert.NotNull(assertedNotNull);
↓DoNothing(possibleNull);
}}
Expand Down Expand Up @@ -920,7 +914,7 @@ public void Test()
{{
object? possibleNull = GetNext();
object? assertedNotNull = GetNext();
{ClassicAssert}.NotNull(assertedNotNull);
ClassicAssert.NotNull(assertedNotNull);
↓DoNothing(assertedNotNull, possibleNull);
}}
Expand Down
2 changes: 1 addition & 1 deletion src/nunit.analyzers.tests/DocumentationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace NUnit.Analyzers.Tests
{
public class DocumentationTests
{
// Overload of Append(InterpolatedStringHanlder) with IFormatProvider not available in .NET 462
// Overload of Append(AppendInterpolatedStringHandler) with IFormatProvider not available in .NET 462
#pragma warning disable CA1305 // Specify IFormatProvider

private static readonly IReadOnlyList<DiagnosticAnalyzer> analyzers =
Expand Down

0 comments on commit ecdf110

Please sign in to comment.