From e1d42b4ffe161e30c1b754189f40bcc1258c3ea1 Mon Sep 17 00:00:00 2001 From: Erik Hennerfors Date: Fri, 31 Oct 2025 09:50:50 +0100 Subject: [PATCH 1/2] Updated to xunit.v3 --- Cronitor.Tests/Cronitor.Tests.csproj | 5 +++-- Cronitor.Tests/Helpers/JsonDataAttribute.cs | 13 +++++++++++-- Cronitor.Tests/Helpers/UseCultureAttribute.cs | 8 +++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Cronitor.Tests/Cronitor.Tests.csproj b/Cronitor.Tests/Cronitor.Tests.csproj index df84e63..77f9eb7 100644 --- a/Cronitor.Tests/Cronitor.Tests.csproj +++ b/Cronitor.Tests/Cronitor.Tests.csproj @@ -10,14 +10,15 @@ net9.0;net8.0;net48 false true + Exe - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Cronitor.Tests/Helpers/JsonDataAttribute.cs b/Cronitor.Tests/Helpers/JsonDataAttribute.cs index d9f33ee..9cce449 100644 --- a/Cronitor.Tests/Helpers/JsonDataAttribute.cs +++ b/Cronitor.Tests/Helpers/JsonDataAttribute.cs @@ -3,7 +3,10 @@ using System.IO; using System.Reflection; using System.Text; +using System.Threading.Tasks; +using Xunit; using Xunit.Sdk; +using Xunit.v3; namespace Cronitor.Tests.Helpers { @@ -16,14 +19,20 @@ public JsonDataAttribute(string filePath) _filePath = filePath; } - public override IEnumerable GetData(MethodInfo method) + public override ValueTask> GetData(MethodInfo testMethod, DisposalTracker disposalTracker) { var directoryPath = AppContext.BaseDirectory; var file = string.Concat(directoryPath, "\\Files\\", _filePath.Replace("/", "\\")); var content = File.ReadAllText(file, Encoding.UTF8); + var data = new List { new TheoryDataRow(content) }; - return new List { new object[] { content } }; + return new ValueTask>(data); + } + + public override bool SupportsDiscoveryEnumeration() + { + return true; } } } \ No newline at end of file diff --git a/Cronitor.Tests/Helpers/UseCultureAttribute.cs b/Cronitor.Tests/Helpers/UseCultureAttribute.cs index 4dd225c..6a90a84 100644 --- a/Cronitor.Tests/Helpers/UseCultureAttribute.cs +++ b/Cronitor.Tests/Helpers/UseCultureAttribute.cs @@ -2,7 +2,7 @@ using System.Globalization; using System.Reflection; using System.Threading; -using Xunit.Sdk; +using Xunit.v3; namespace Cronitor.Tests.Helpers { @@ -64,7 +64,8 @@ public UseCultureAttribute(string culture, string uiCulture) /// and replaces them with the new cultures defined in the constructor. /// /// The method under test - public override void Before(MethodInfo methodUnderTest) + /// + public override void Before(MethodInfo methodUnderTest, IXunitTest test) { _originalCulture = Thread.CurrentThread.CurrentCulture; _originalUiCulture = Thread.CurrentThread.CurrentUICulture; @@ -78,7 +79,8 @@ public override void Before(MethodInfo methodUnderTest) /// to /// /// The method under test - public override void After(MethodInfo methodUnderTest) + /// + public override void After(MethodInfo methodUnderTest, IXunitTest test) { Thread.CurrentThread.CurrentCulture = _originalCulture; Thread.CurrentThread.CurrentUICulture = _originalUiCulture; From 4f93f483b7c05670b37daf27d29bb69c52a80839 Mon Sep 17 00:00:00 2001 From: Erik Hennerfors Date: Fri, 31 Oct 2025 09:56:01 +0100 Subject: [PATCH 2/2] Fixed failing test --- Cronitor.Tests/CronitorTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cronitor.Tests/CronitorTests.cs b/Cronitor.Tests/CronitorTests.cs index 6faf459..029d06e 100644 --- a/Cronitor.Tests/CronitorTests.cs +++ b/Cronitor.Tests/CronitorTests.cs @@ -17,7 +17,7 @@ public void ShouldConfigureCronitor() Assert.NotNull(Cronitor.Telemetries); } - [Fact] + [Fact(Explicit = true)] public void ShouldThrowExceptionIfNotConfigured() { Assert.Throws(() => Cronitor.Issues);