Skip to content

Commit adf6313

Browse files
committed
Update to NUnit 4 (using some legacy assertion methods)
1 parent 918bcd0 commit adf6313

35 files changed

Lines changed: 62 additions & 24 deletions

tests/DocoptNet.Tests/ArgumentMatchTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace DocoptNet.Tests
33
using NUnit.Framework;
44
using static DocoptNet.Tests.ArgumentFactory;
55
using static DocoptNet.Tests.PatternFactory;
6+
using Assert = NUnit.Framework.Legacy.ClassicAssert;
67

78
[TestFixture]
89
public class ArgumentMatchTests

tests/DocoptNet.Tests/ArgumentTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace DocoptNet.Tests
22
{
33
using NUnit.Framework;
44
using static DocoptNet.Tests.ArgumentFactory;
5+
using Assert = NUnit.Framework.Legacy.ClassicAssert;
56

67
[TestFixture]
78
public class ArgumentTests

tests/DocoptNet.Tests/Assumptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace DocoptNet.Tests
22
{
33
using System;
44
using NUnit.Framework;
5+
using Assert = NUnit.Framework.Legacy.ClassicAssert;
56

67
/// <summary>
78
/// Set of tests to validate assumptions about the BCL or other APIs.

tests/DocoptNet.Tests/BasicPatternMatchingTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace DocoptNet.Tests
33
using NUnit.Framework;
44
using static DocoptNet.Tests.ArgumentFactory;
55
using static DocoptNet.Tests.PatternFactory;
6+
using Assert = NUnit.Framework.Legacy.ClassicAssert;
67

78
[TestFixture]
89
public class BasicPatternMatchingTests

tests/DocoptNet.Tests/CodeGeneration/LanguageAgnosticTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace DocoptNet.Tests.CodeGeneration
44
{
55
using System;
66
using System.Collections.Generic;
7+
using System.Diagnostics;
78
using System.Globalization;
89
using System.Reflection;
910
using System.Text.RegularExpressions;
@@ -100,14 +101,15 @@ e is AssertionException
100101
if (expected.StartsWith("{"))
101102
{
102103
var expectedDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(expected);
104+
Debug.Assert(expectedDict is not null);
103105
var actualDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(actual);
104106
Assert.That(actualDict, Is.EquivalentTo(expectedDict));
105107
}
106108
else
107109
{
108110
var expected1 = JsonConvert.DeserializeObject(expected)!.ToString();
109111
var actual1 = JsonConvert.DeserializeObject(actual)!.ToString();
110-
Assert.AreEqual(expected1, actual1);
112+
Assert.That(actual1, Is.EqualTo(expected1));
111113
}
112114
}
113115
}

tests/DocoptNet.Tests/CodeGeneration/SourceGeneratorTests.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,9 @@ void AssertMatchesSnapshot((string Path, SourceText Text)[] sources,
267267

268268
var diagnostics = outputCompilation.GetDiagnostics();
269269

270-
Assert.False(diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error),
271-
"Failed: " + diagnostics.FirstOrDefault()?.GetMessage());
270+
Assert.That(diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error),
271+
Is.False,
272+
"Failed: " + diagnostics.FirstOrDefault()?.GetMessage());
272273

273274
var testPath = Path.Combine(nameof(SourceGeneratorTests), callerName!);
274275
var actualSourcesPath = Path.Combine(TestContext.CurrentContext.WorkDirectory, testPath);
@@ -601,14 +602,16 @@ internal static Assembly GenerateProgram(params (string Path, SourceText Text)[]
601602
out var outputCompilation,
602603
out var generateDiagnostics);
603604

604-
Assert.False(generateDiagnostics.Any(d => d.Severity == DiagnosticSeverity.Error),
605-
"Failed: " + generateDiagnostics.FirstOrDefault()?.GetMessage());
605+
Assert.That(generateDiagnostics.Any(d => d.Severity == DiagnosticSeverity.Error),
606+
Is.False,
607+
"Failed: " + generateDiagnostics.FirstOrDefault()?.GetMessage());
606608

607609
using var ms = new MemoryStream();
608610
var emitResult = outputCompilation.Emit(ms);
609611

610-
Assert.False(emitResult.Diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error),
611-
"Failed: " + emitResult.Diagnostics.FirstOrDefault());
612+
Assert.That(emitResult.Diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error),
613+
Is.False,
614+
"Failed: " + emitResult.Diagnostics.FirstOrDefault());
612615

613616
ms.Position = 0;
614617

tests/DocoptNet.Tests/CommandMatchTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace DocoptNet.Tests
33
using NUnit.Framework;
44
using static DocoptNet.Tests.ArgumentFactory;
55
using static DocoptNet.Tests.PatternFactory;
6+
using Assert = NUnit.Framework.Legacy.ClassicAssert;
67

78
[TestFixture]
89
public class CommandMatchTests

tests/DocoptNet.Tests/CommandsTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace DocoptNet.Tests
22
{
33
using System.Collections.Generic;
44
using NUnit.Framework;
5+
using Assert = NUnit.Framework.Legacy.ClassicAssert;
56

67
[TestFixture]
78
public class CommandsTests

tests/DocoptNet.Tests/CountMultipleFlagsTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace DocoptNet.Tests
22
{
33
using System.Collections.Generic;
44
using NUnit.Framework;
5+
using Assert = NUnit.Framework.Legacy.ClassicAssert;
56

67
[TestFixture]
78
public class CountMultipleFlagsTests

tests/DocoptNet.Tests/DefaultValueForPositionalArgumentsTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace DocoptNet.Tests
22
{
33
using System.Collections.Generic;
44
using NUnit.Framework;
5+
using Assert = NUnit.Framework.Legacy.ClassicAssert;
56

67
[TestFixture]
78
public class DefaultValueForPositionalArgumentsTests

0 commit comments

Comments
 (0)