Skip to content

Commit 6115792

Browse files
authored
Merge pull request #33 from gonace/xunit-migrate-to-v3
Xunit migrate to v3
2 parents 2e7f7d9 + 4f93f48 commit 6115792

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

Cronitor.Tests/Cronitor.Tests.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
<TargetFrameworks>net9.0;net8.0;net48</TargetFrameworks>
1111
<IsPackable>false</IsPackable>
1212
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
13+
<OutputType>Exe</OutputType>
1314
</PropertyGroup>
1415

1516
<ItemGroup>
1617
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
1718
<PackageReference Include="Moq" Version="4.20.72" />
1819
<PackageReference Include="System.Net.Http" Version="4.3.4" />
19-
<PackageReference Include="xunit" Version="2.9.3" />
20-
<PackageReference Include="xunit.runner.console" Version="2.9.3">
20+
<PackageReference Include="xunit.v3" Version="3.1.0" />
21+
<PackageReference Include="xunit.v3.runner.console" Version="3.1.0">
2122
<PrivateAssets>all</PrivateAssets>
2223
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2324
</PackageReference>

Cronitor.Tests/CronitorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void ShouldConfigureCronitor()
1717
Assert.NotNull(Cronitor.Telemetries);
1818
}
1919

20-
[Fact]
20+
[Fact(Explicit = true)]
2121
public void ShouldThrowExceptionIfNotConfigured()
2222
{
2323
Assert.Throws<NotConfiguredException>(() => Cronitor.Issues);

Cronitor.Tests/Helpers/JsonDataAttribute.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
using System.IO;
44
using System.Reflection;
55
using System.Text;
6+
using System.Threading.Tasks;
7+
using Xunit;
68
using Xunit.Sdk;
9+
using Xunit.v3;
710

811
namespace Cronitor.Tests.Helpers
912
{
@@ -16,14 +19,20 @@ public JsonDataAttribute(string filePath)
1619
_filePath = filePath;
1720
}
1821

19-
public override IEnumerable<object[]> GetData(MethodInfo method)
22+
public override ValueTask<IReadOnlyCollection<ITheoryDataRow>> GetData(MethodInfo testMethod, DisposalTracker disposalTracker)
2023
{
2124
var directoryPath = AppContext.BaseDirectory;
2225

2326
var file = string.Concat(directoryPath, "\\Files\\", _filePath.Replace("/", "\\"));
2427
var content = File.ReadAllText(file, Encoding.UTF8);
28+
var data = new List<ITheoryDataRow> { new TheoryDataRow(content) };
2529

26-
return new List<object[]> { new object[] { content } };
30+
return new ValueTask<IReadOnlyCollection<ITheoryDataRow>>(data);
31+
}
32+
33+
public override bool SupportsDiscoveryEnumeration()
34+
{
35+
return true;
2736
}
2837
}
2938
}

Cronitor.Tests/Helpers/UseCultureAttribute.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Globalization;
33
using System.Reflection;
44
using System.Threading;
5-
using Xunit.Sdk;
5+
using Xunit.v3;
66

77
namespace Cronitor.Tests.Helpers
88
{
@@ -64,7 +64,8 @@ public UseCultureAttribute(string culture, string uiCulture)
6464
/// and replaces them with the new cultures defined in the constructor.
6565
/// </summary>
6666
/// <param name="methodUnderTest">The method under test</param>
67-
public override void Before(MethodInfo methodUnderTest)
67+
/// <param name="test"></param>
68+
public override void Before(MethodInfo methodUnderTest, IXunitTest test)
6869
{
6970
_originalCulture = Thread.CurrentThread.CurrentCulture;
7071
_originalUiCulture = Thread.CurrentThread.CurrentUICulture;
@@ -78,7 +79,8 @@ public override void Before(MethodInfo methodUnderTest)
7879
/// <see cref="CultureInfo.CurrentUICulture" /> to <see cref="Thread.CurrentPrincipal" />
7980
/// </summary>
8081
/// <param name="methodUnderTest">The method under test</param>
81-
public override void After(MethodInfo methodUnderTest)
82+
/// <param name="test"></param>
83+
public override void After(MethodInfo methodUnderTest, IXunitTest test)
8284
{
8385
Thread.CurrentThread.CurrentCulture = _originalCulture;
8486
Thread.CurrentThread.CurrentUICulture = _originalUiCulture;

0 commit comments

Comments
 (0)