Skip to content

Commit

Permalink
upgrade xunit to v3
Browse files Browse the repository at this point in the history
Signed-off-by: Caleb Lloyd <[email protected]>
  • Loading branch information
caleblloyd committed Jan 12, 2025
1 parent af04c71 commit 73e0e8d
Show file tree
Hide file tree
Showing 20 changed files with 95 additions and 109 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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 ####

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.v3" Version="1.0.1" />
<Using Include="Xunit" />
</ItemGroup>

Expand Down
12 changes: 0 additions & 12 deletions tests/NATS.Client.Core.MemoryTests/NatsConsumeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
26 changes: 12 additions & 14 deletions tests/NATS.Client.Core.Tests/NATS.Client.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,32 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.5.1"/>
<PackageReference Include="ProcessX" Version="1.5.4"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0"/>
<PackageReference Include="xunit" Version="2.4.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="FluentAssertions" Version="6.5.1" />
<PackageReference Include="ProcessX" Version="1.5.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit"/>
<Using Include="Xunit.Abstractions"/>
<Using Include="FluentAssertions"/>
<Using Include="NATS.Client.Core"/>
<Using Include="NATS.Client.Core.Internal"/>
<Using Include="NATS.Client.Core.Commands"/>
<Using Include="Xunit" />
<Using Include="FluentAssertions" />
<Using Include="NATS.Client.Core" />
<Using Include="NATS.Client.Core.Internal" />
<Using Include="NATS.Client.Core.Commands" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NATS.Client.Serializers.Json\NATS.Client.Serializers.Json.csproj" />
<ProjectReference Include="..\NATS.Client.TestUtilities\NATS.Client.TestUtilities.csproj"/>
<ProjectReference Include="..\..\src\NATS.Client.Core\NATS.Client.Core.csproj"/>
<ProjectReference Include="..\NATS.Client.TestUtilities\NATS.Client.TestUtilities.csproj" />
<ProjectReference Include="..\..\src\NATS.Client.Core\NATS.Client.Core.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions tests/NATS.Client.Core.Tests/TlsOptsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ 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)]
[InlineData(null, null, "resources/certs/chainedclient-cert-bundle.pfx", 8)]
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";

Expand Down
28 changes: 13 additions & 15 deletions tests/NATS.Client.Core2.Tests/NATS.Client.Core2.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,42 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.5.1"/>
<PackageReference Include="ProcessX" Version="1.5.4"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0"/>
<PackageReference Include="xunit" Version="2.4.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="FluentAssertions" Version="6.5.1" />
<PackageReference Include="ProcessX" Version="1.5.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit"/>
<Using Include="Xunit.Abstractions"/>
<Using Include="FluentAssertions"/>
<Using Include="NATS.Client.Core"/>
<Using Include="NATS.Client.Core.Internal"/>
<Using Include="NATS.Client.Core.Commands"/>
<Using Include="Xunit" />
<Using Include="FluentAssertions" />
<Using Include="NATS.Client.Core" />
<Using Include="NATS.Client.Core.Internal" />
<Using Include="NATS.Client.Core.Commands" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NATS.Client.Serializers.Json\NATS.Client.Serializers.Json.csproj" />
<ProjectReference Include="..\..\src\NATS.Client.Core\NATS.Client.Core.csproj"/>
<ProjectReference Include="..\..\src\NATS.Client.Core\NATS.Client.Core.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="..\NATS.Client.Core.Tests\resources\**\*">
<Link>resources\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<Compile Include="..\NATS.Client.Platform.Windows.Tests\NatsServerProcess.cs" />
<Compile Include="..\NATS.Client.TestUtilities\InMemoryTestLoggerFactory.cs" />
Expand Down
24 changes: 11 additions & 13 deletions tests/NATS.Client.CoreUnit.Tests/NATS.Client.CoreUnit.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,33 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.5.1"/>
<PackageReference Include="ProcessX" Version="1.5.4"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0"/>
<PackageReference Include="xunit" Version="2.4.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="FluentAssertions" Version="6.5.1" />
<PackageReference Include="ProcessX" Version="1.5.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit"/>
<Using Include="Xunit.Abstractions"/>
<Using Include="FluentAssertions"/>
<Using Include="NATS.Client.Core"/>
<Using Include="NATS.Client.Core.Internal"/>
<Using Include="NATS.Client.Core.Commands"/>
<Using Include="Xunit" />
<Using Include="FluentAssertions" />
<Using Include="NATS.Client.Core" />
<Using Include="NATS.Client.Core.Internal" />
<Using Include="NATS.Client.Core.Commands" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NATS.Client.Serializers.Json\NATS.Client.Serializers.Json.csproj" />
<ProjectReference Include="..\..\src\NATS.Client.Core\NATS.Client.Core.csproj"/>
<ProjectReference Include="..\..\src\NATS.Client.Core\NATS.Client.Core.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -21,7 +21,6 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<Using Include="Xunit" />
<Using Include="Xunit.Abstractions" />
<Using Include="FluentAssertions" />
<Using Include="NATS.Client.Core" />
<Using Include="NATS.Client.Core.Internal" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -21,7 +21,6 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<Using Include="Xunit" />
<Using Include="Xunit.Abstractions" />
<Using Include="FluentAssertions" />
<Using Include="NATS.Client.Core" />
<Using Include="NATS.Client.Core.Internal" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -21,7 +21,6 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<Using Include="Xunit" />
<Using Include="Xunit.Abstractions" />
<Using Include="FluentAssertions" />
<Using Include="NATS.Client.Core" />
<Using Include="NATS.Client.Core.Internal" />
Expand Down
1 change: 0 additions & 1 deletion tests/NATS.Client.Platform.Windows.Tests/BasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@

<ItemGroup>
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageReference Include="xunit" Version="2.5.3"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3"/>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit"/>
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion tests/NATS.Client.Platform.Windows.Tests/TlsTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Security.Authentication;
using NATS.Client.Core;
using Xunit.Abstractions;

namespace NATS.Client.Platform.Windows.Tests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -21,7 +21,6 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<Using Include="Xunit" />
<Using Include="Xunit.Abstractions" />
<Using Include="FluentAssertions" />
<Using Include="NATS.Client.Core" />
<Using Include="NATS.Client.Services" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,30 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.5.1"/>
<PackageReference Include="ProcessX" Version="1.5.4"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0"/>
<PackageReference Include="xunit" Version="2.4.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="FluentAssertions" Version="6.5.1" />
<PackageReference Include="ProcessX" Version="1.5.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit"/>
<Using Include="Xunit.Abstractions"/>
<Using Include="FluentAssertions"/>
<Using Include="NATS.Client"/>
<Using Include="Xunit" />
<Using Include="FluentAssertions" />
<Using Include="NATS.Client" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NATS.Client.JetStream\NATS.Client.JetStream.csproj" />
<ProjectReference Include="..\NATS.Client.TestUtilities\NATS.Client.TestUtilities.csproj"/>
<ProjectReference Include="..\..\src\NATS.Client.Simplified\NATS.Client.Simplified.csproj"/>
<ProjectReference Include="..\NATS.Client.TestUtilities\NATS.Client.TestUtilities.csproj" />
<ProjectReference Include="..\..\src\NATS.Client.Simplified\NATS.Client.Simplified.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
<PackageReference Include="FluentAssertions" Version="6.5.1" />
<PackageReference Include="ProcessX" Version="1.5.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit" />
<Using Include="Xunit.Abstractions" />
<Using Include="FluentAssertions" />
<Using Include="NATS.Client.Core" />
<Using Include="NATS.Client.Core.Internal" />
Expand Down
Loading

0 comments on commit 73e0e8d

Please sign in to comment.