Skip to content

Commit

Permalink
Merge pull request #788 from nunit/chore/bump-nunit-version
Browse files Browse the repository at this point in the history
chore: Bump NUnit to version 4.2.2
  • Loading branch information
mikkelbu authored Nov 3, 2024
2 parents e026ba5 + b643c64 commit 405d2c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,57 +15,6 @@ namespace NUnit.Analyzers.Tests.TestCaseUsage
[TestFixture]
public sealed class TestCaseUsageAnalyzerTests
{
#if NUNIT4
#if NET6_0_OR_GREATER
// This can go once NUnit 4.2.0 is released and we update our reference.
private const string GenericTestCaseAttributeSource = """
using System;

namespace NUnit.Framework
{
#pragma warning disable CA1019 // Define accessors for attribute arguments

/// <summary>
/// Marks a method as a parameterized test suite and provides arguments for each test case.
/// </summary>
/// <typeparam name="T">The type of the argument for the test case.</typeparam>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
public sealed class TestCaseAttribute<T> : TestCaseAttribute
{
/// <summary>
/// Initializes a new instance of the <see cref="TestCaseAttribute{T}"/> class.
/// </summary>
/// <param name="argument">The argument for the test case.</param>
public TestCaseAttribute(T argument)
: base(new object?[] { argument })
{
this.TypeArgs = new[] { typeof(T) };
}
}

/// <summary>
/// Marks a method as a parameterized test suite and provides arguments for each test case.
/// </summary>
/// <typeparam name="T">The type of the argument for the test case.</typeparam>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
public sealed class TestCaseAttribute<T1, T2> : TestCaseAttribute
{
/// <summary>
/// Initializes a new instance of the <see cref="TestCaseAttribute{T1,T2}"/> class.
/// </summary>
/// <param name="argument">The argument for the test case.</param>
public TestCaseAttribute(T1 argument1, T2 argument2)
: base(new object?[] { argument1, argument2 })
{
this.TypeArgs = new[] { typeof(T1), typeof(T2) };
}
}
}

""";
#endif
#endif

private readonly DiagnosticAnalyzer analyzer = new TestCaseUsageAnalyzer();

private static IEnumerable<TestCaseData> SpecialConversions
Expand Down Expand Up @@ -818,7 +767,7 @@ class AnalyzeWhenArgumentIsGenericTypeParameter
[TestCase<byte>(2)]
public void Test(byte a) { }
}");
RoslynAssert.Valid(this.analyzer, GenericTestCaseAttributeSource, testCode);
RoslynAssert.Valid(this.analyzer, testCode);
}

[Test]
Expand All @@ -830,7 +779,7 @@ class AnalyzeWhenArgumentIsGenericTypeParameter
[TestCase<byte, uint>(2, 3)]
public void Test(byte a, uint b) { }
}");
RoslynAssert.Valid(this.analyzer, GenericTestCaseAttributeSource, testCode);
RoslynAssert.Valid(this.analyzer, testCode);
}

[Test]
Expand All @@ -844,7 +793,7 @@ public void Test(int a) { }
}");
RoslynAssert.Diagnostics(this.analyzer,
ExpectedDiagnostic.Create(AnalyzerIdentifiers.TestCaseParameterTypeMismatchUsage),
GenericTestCaseAttributeSource, testCode);
testCode);
}

[Test]
Expand All @@ -858,7 +807,7 @@ public void Test(int a, uint b) { }
}");
RoslynAssert.Diagnostics(this.analyzer,
ExpectedDiagnostic.Create(AnalyzerIdentifiers.TestCaseParameterTypeMismatchUsage),
GenericTestCaseAttributeSource, testCode);
testCode);
}

[Test]
Expand All @@ -873,7 +822,7 @@ public sealed class AnalyzeWhenTestMethodHasTypeParameterArgumentType
[TestCase<double>(1)]
public void TestWithGenericParameter<T>(T arg1) { }
}");
RoslynAssert.Valid(this.analyzer, GenericTestCaseAttributeSource, testCode);
RoslynAssert.Valid(this.analyzer, testCode);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/nunit.analyzers.tests/nunit.analyzers.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</ItemGroup>

<ItemGroup Condition="'$(NUnitVersion)' == '4'">
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit" Version="4.2.2" />
</ItemGroup>

<ItemGroup Condition="'$(NUnitVersion)' == '3'">
Expand Down

0 comments on commit 405d2c4

Please sign in to comment.