From 73e0e8daed86ac6bc0daa16d56123f7232291c19 Mon Sep 17 00:00:00 2001 From: Caleb Lloyd Date: Sun, 12 Jan 2025 11:15:27 -0500 Subject: [PATCH] upgrade xunit to v3 Signed-off-by: Caleb Lloyd --- .editorconfig | 3 ++ .../NATS.Client.CheckNativeAot.csproj | 2 +- .../NatsConsumeTests.cs | 12 -------- .../NATS.Client.Core.Tests.csproj | 26 ++++++++--------- tests/NATS.Client.Core.Tests/TlsOptsTest.cs | 4 +-- .../NATS.Client.Core2.Tests.csproj | 28 +++++++++---------- .../NATS.Client.CoreUnit.Tests.csproj | 24 ++++++++-------- .../NATS.Client.JetStream.Tests.csproj | 5 ++-- .../NATS.Client.KeyValueStore.Tests.csproj | 5 ++-- .../NATS.Client.ObjectStore.Tests.csproj | 5 ++-- .../BasicTests.cs | 1 - .../NATS.Client.Platform.Windows.Tests.csproj | 13 +++++---- .../TlsTests.cs | 1 - .../NATS.Client.Services.Tests.csproj | 5 ++-- .../NATS.Client.Simplified.Tests.csproj | 22 +++++++-------- .../NATS.Client.TestUtilities.csproj | 3 +- tests/NATS.Client.TestUtilities/NatsServer.cs | 10 +++++++ .../OutputHelperLogger.cs | 1 - ...Microsoft.DependencyInjection.Tests.csproj | 9 +++--- .../NATS.Net.OpenTelemetry.Tests.csproj | 25 ++++++++--------- 20 files changed, 95 insertions(+), 109 deletions(-) diff --git a/.editorconfig b/.editorconfig index eac0d4922..3dc70f97d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -290,6 +290,9 @@ csharp_style_expression_bodied_lambdas = true:silent csharp_style_expression_bodied_local_functions = false:silent csharp_space_around_binary_operators = before_and_after +# xunit Analyzers +dotnet_diagnostic.xUnit1051.severity = none # Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive + [*.{cs,vb}] #### Naming styles #### diff --git a/tests/NATS.Client.CheckNativeAot/NATS.Client.CheckNativeAot.csproj b/tests/NATS.Client.CheckNativeAot/NATS.Client.CheckNativeAot.csproj index 06039b63b..0bb2a9e49 100644 --- a/tests/NATS.Client.CheckNativeAot/NATS.Client.CheckNativeAot.csproj +++ b/tests/NATS.Client.CheckNativeAot/NATS.Client.CheckNativeAot.csproj @@ -11,7 +11,7 @@ - + diff --git a/tests/NATS.Client.Core.MemoryTests/NatsConsumeTests.cs b/tests/NATS.Client.Core.MemoryTests/NatsConsumeTests.cs index b1dc35ad0..a4c17b5f2 100644 --- a/tests/NATS.Client.Core.MemoryTests/NatsConsumeTests.cs +++ b/tests/NATS.Client.Core.MemoryTests/NatsConsumeTests.cs @@ -3,7 +3,6 @@ using NATS.Client.JetStream; using NATS.Client.JetStream.Internal; using NATS.Client.JetStream.Models; -using Xunit.Abstractions; namespace NATS.Client.Core.MemoryTests; @@ -193,14 +192,3 @@ public void Subscription_should_not_be_collected_when_in_ordered_consume_async_e } } } - -public class TestTextWriterOutput : ITestOutputHelper -{ - private readonly TextWriter _out; - - public TestTextWriterOutput(TextWriter @out) => _out = @out; - - public void WriteLine(string message) => _out.WriteLine(message); - - public void WriteLine(string format, params object[] args) => _out.WriteLine(format, args); -} diff --git a/tests/NATS.Client.Core.Tests/NATS.Client.Core.Tests.csproj b/tests/NATS.Client.Core.Tests/NATS.Client.Core.Tests.csproj index 0b964f3f3..e165c3680 100644 --- a/tests/NATS.Client.Core.Tests/NATS.Client.Core.Tests.csproj +++ b/tests/NATS.Client.Core.Tests/NATS.Client.Core.Tests.csproj @@ -11,11 +11,11 @@ - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -23,22 +23,20 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - - - - + + + + + - - + + diff --git a/tests/NATS.Client.Core.Tests/TlsOptsTest.cs b/tests/NATS.Client.Core.Tests/TlsOptsTest.cs index 8262ec8df..59512aa2e 100644 --- a/tests/NATS.Client.Core.Tests/TlsOptsTest.cs +++ b/tests/NATS.Client.Core.Tests/TlsOptsTest.cs @@ -138,7 +138,7 @@ static async Task ValidateAsync(NatsTlsOpts opts) } } - [SkippableTheory] + [Theory] [InlineData("resources/certs/client-cert.pem", "resources/certs/client-key.pem", null, 6)] [InlineData(null, null, "resources/certs/client-cert-bundle.pfx", 6)] [InlineData("resources/certs/chainedclient-cert.pem", "resources/certs/chainedclient-key.pem", null, 8)] @@ -146,7 +146,7 @@ static async Task ValidateAsync(NatsTlsOpts opts) public async Task Client_connect(string? clientCertFile, string? clientKeyFile, string? clientCertBundleFile, int minimumFrameworkVersion) { var version = int.Parse(Regex.Match(RuntimeInformation.FrameworkDescription, @"(\d+)\.\d").Groups[1].Value); - Skip.IfNot(version >= minimumFrameworkVersion, $"Requires .NET {minimumFrameworkVersion}"); + Assert.SkipUnless(version >= minimumFrameworkVersion, $"Requires .NET {minimumFrameworkVersion}"); const string caFile = "resources/certs/ca-cert.pem"; diff --git a/tests/NATS.Client.Core2.Tests/NATS.Client.Core2.Tests.csproj b/tests/NATS.Client.Core2.Tests/NATS.Client.Core2.Tests.csproj index 53dc4e386..6cda41ace 100644 --- a/tests/NATS.Client.Core2.Tests/NATS.Client.Core2.Tests.csproj +++ b/tests/NATS.Client.Core2.Tests/NATS.Client.Core2.Tests.csproj @@ -12,11 +12,11 @@ - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -24,32 +24,30 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - - - - + + + + + - + - + resources\%(RecursiveDir)%(Filename)%(Extension) PreserveNewest - + diff --git a/tests/NATS.Client.CoreUnit.Tests/NATS.Client.CoreUnit.Tests.csproj b/tests/NATS.Client.CoreUnit.Tests/NATS.Client.CoreUnit.Tests.csproj index 501e49cc0..1ac7c56c9 100644 --- a/tests/NATS.Client.CoreUnit.Tests/NATS.Client.CoreUnit.Tests.csproj +++ b/tests/NATS.Client.CoreUnit.Tests/NATS.Client.CoreUnit.Tests.csproj @@ -12,11 +12,11 @@ - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -24,23 +24,21 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - - - - + + + + + - + diff --git a/tests/NATS.Client.JetStream.Tests/NATS.Client.JetStream.Tests.csproj b/tests/NATS.Client.JetStream.Tests/NATS.Client.JetStream.Tests.csproj index 19a65ee77..cff8c2b18 100644 --- a/tests/NATS.Client.JetStream.Tests/NATS.Client.JetStream.Tests.csproj +++ b/tests/NATS.Client.JetStream.Tests/NATS.Client.JetStream.Tests.csproj @@ -11,8 +11,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -21,7 +21,6 @@ all - diff --git a/tests/NATS.Client.KeyValueStore.Tests/NATS.Client.KeyValueStore.Tests.csproj b/tests/NATS.Client.KeyValueStore.Tests/NATS.Client.KeyValueStore.Tests.csproj index 63bcf2bc1..17292da38 100644 --- a/tests/NATS.Client.KeyValueStore.Tests/NATS.Client.KeyValueStore.Tests.csproj +++ b/tests/NATS.Client.KeyValueStore.Tests/NATS.Client.KeyValueStore.Tests.csproj @@ -11,8 +11,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -21,7 +21,6 @@ all - diff --git a/tests/NATS.Client.ObjectStore.Tests/NATS.Client.ObjectStore.Tests.csproj b/tests/NATS.Client.ObjectStore.Tests/NATS.Client.ObjectStore.Tests.csproj index 0139097b5..2c6d7bc84 100644 --- a/tests/NATS.Client.ObjectStore.Tests/NATS.Client.ObjectStore.Tests.csproj +++ b/tests/NATS.Client.ObjectStore.Tests/NATS.Client.ObjectStore.Tests.csproj @@ -11,8 +11,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -21,7 +21,6 @@ all - diff --git a/tests/NATS.Client.Platform.Windows.Tests/BasicTests.cs b/tests/NATS.Client.Platform.Windows.Tests/BasicTests.cs index 56e8a8103..e211153bf 100644 --- a/tests/NATS.Client.Platform.Windows.Tests/BasicTests.cs +++ b/tests/NATS.Client.Platform.Windows.Tests/BasicTests.cs @@ -5,7 +5,6 @@ using NATS.Client.ObjectStore; using NATS.Client.Serializers.Json; using NATS.Client.Services; -using Xunit.Abstractions; namespace NATS.Client.Platform.Windows.Tests; diff --git a/tests/NATS.Client.Platform.Windows.Tests/NATS.Client.Platform.Windows.Tests.csproj b/tests/NATS.Client.Platform.Windows.Tests/NATS.Client.Platform.Windows.Tests.csproj index 8f3208efb..552de380a 100644 --- a/tests/NATS.Client.Platform.Windows.Tests/NATS.Client.Platform.Windows.Tests.csproj +++ b/tests/NATS.Client.Platform.Windows.Tests/NATS.Client.Platform.Windows.Tests.csproj @@ -12,16 +12,19 @@ - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + - + diff --git a/tests/NATS.Client.Platform.Windows.Tests/TlsTests.cs b/tests/NATS.Client.Platform.Windows.Tests/TlsTests.cs index 593eda5ef..1254ba743 100644 --- a/tests/NATS.Client.Platform.Windows.Tests/TlsTests.cs +++ b/tests/NATS.Client.Platform.Windows.Tests/TlsTests.cs @@ -1,6 +1,5 @@ using System.Security.Authentication; using NATS.Client.Core; -using Xunit.Abstractions; namespace NATS.Client.Platform.Windows.Tests; diff --git a/tests/NATS.Client.Services.Tests/NATS.Client.Services.Tests.csproj b/tests/NATS.Client.Services.Tests/NATS.Client.Services.Tests.csproj index 0f784d731..e60a74b5e 100644 --- a/tests/NATS.Client.Services.Tests/NATS.Client.Services.Tests.csproj +++ b/tests/NATS.Client.Services.Tests/NATS.Client.Services.Tests.csproj @@ -11,8 +11,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -21,7 +21,6 @@ all - diff --git a/tests/NATS.Client.Simplified.Tests/NATS.Client.Simplified.Tests.csproj b/tests/NATS.Client.Simplified.Tests/NATS.Client.Simplified.Tests.csproj index e189806b8..607af6f91 100644 --- a/tests/NATS.Client.Simplified.Tests/NATS.Client.Simplified.Tests.csproj +++ b/tests/NATS.Client.Simplified.Tests/NATS.Client.Simplified.Tests.csproj @@ -11,11 +11,11 @@ - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -23,20 +23,18 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - - + + + - - + + diff --git a/tests/NATS.Client.TestUtilities/NATS.Client.TestUtilities.csproj b/tests/NATS.Client.TestUtilities/NATS.Client.TestUtilities.csproj index 437d1b3c6..e93cdfccc 100644 --- a/tests/NATS.Client.TestUtilities/NATS.Client.TestUtilities.csproj +++ b/tests/NATS.Client.TestUtilities/NATS.Client.TestUtilities.csproj @@ -13,14 +13,13 @@ - + - diff --git a/tests/NATS.Client.TestUtilities/NatsServer.cs b/tests/NATS.Client.TestUtilities/NatsServer.cs index 3de63b5d0..43bd0b2f5 100644 --- a/tests/NATS.Client.TestUtilities/NatsServer.cs +++ b/tests/NATS.Client.TestUtilities/NatsServer.cs @@ -564,6 +564,16 @@ public async ValueTask DisposeAsync() public class NullOutputHelper : ITestOutputHelper { + public string Output => string.Empty; + + public void Write(string message) + { + } + + public void Write(string format, params object[] args) + { + } + public void WriteLine(string message) { } diff --git a/tests/NATS.Client.TestUtilities/OutputHelperLogger.cs b/tests/NATS.Client.TestUtilities/OutputHelperLogger.cs index 75f5285e4..dba1510b2 100644 --- a/tests/NATS.Client.TestUtilities/OutputHelperLogger.cs +++ b/tests/NATS.Client.TestUtilities/OutputHelperLogger.cs @@ -1,6 +1,5 @@ using System; using Microsoft.Extensions.Logging; -using Xunit.Abstractions; namespace NATS.Client.Core.Tests; diff --git a/tests/NATS.Extensions.Microsoft.DependencyInjection.Tests/NATS.Extensions.Microsoft.DependencyInjection.Tests.csproj b/tests/NATS.Extensions.Microsoft.DependencyInjection.Tests/NATS.Extensions.Microsoft.DependencyInjection.Tests.csproj index e4d3dd79f..9822666b9 100644 --- a/tests/NATS.Extensions.Microsoft.DependencyInjection.Tests/NATS.Extensions.Microsoft.DependencyInjection.Tests.csproj +++ b/tests/NATS.Extensions.Microsoft.DependencyInjection.Tests/NATS.Extensions.Microsoft.DependencyInjection.Tests.csproj @@ -10,9 +10,9 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -23,8 +23,7 @@ - - + diff --git a/tests/NATS.Net.OpenTelemetry.Tests/NATS.Net.OpenTelemetry.Tests.csproj b/tests/NATS.Net.OpenTelemetry.Tests/NATS.Net.OpenTelemetry.Tests.csproj index 154d1ecf7..99a58117f 100644 --- a/tests/NATS.Net.OpenTelemetry.Tests/NATS.Net.OpenTelemetry.Tests.csproj +++ b/tests/NATS.Net.OpenTelemetry.Tests/NATS.Net.OpenTelemetry.Tests.csproj @@ -10,11 +10,11 @@ - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -25,18 +25,17 @@ - - - - - - + + + + + - - + +