Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cronitor.Tests/Cronitor.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
<TargetFrameworks>net9.0;net8.0;net48</TargetFrameworks>
<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.console" Version="2.9.3">
<PackageReference Include="xunit.v3" Version="3.1.0" />
<PackageReference Include="xunit.v3.runner.console" Version="3.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion Cronitor.Tests/CronitorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void ShouldConfigureCronitor()
Assert.NotNull(Cronitor.Telemetries);
}

[Fact]
[Fact(Explicit = true)]
public void ShouldThrowExceptionIfNotConfigured()
{
Assert.Throws<NotConfiguredException>(() => Cronitor.Issues);
Expand Down
13 changes: 11 additions & 2 deletions Cronitor.Tests/Helpers/JsonDataAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -16,14 +19,20 @@ public JsonDataAttribute(string filePath)
_filePath = filePath;
}

public override IEnumerable<object[]> GetData(MethodInfo method)
public override ValueTask<IReadOnlyCollection<ITheoryDataRow>> 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<ITheoryDataRow> { new TheoryDataRow(content) };

return new List<object[]> { new object[] { content } };
return new ValueTask<IReadOnlyCollection<ITheoryDataRow>>(data);
}

public override bool SupportsDiscoveryEnumeration()
{
return true;
}
}
}
8 changes: 5 additions & 3 deletions Cronitor.Tests/Helpers/UseCultureAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Globalization;
using System.Reflection;
using System.Threading;
using Xunit.Sdk;
using Xunit.v3;

namespace Cronitor.Tests.Helpers
{
Expand Down Expand Up @@ -64,7 +64,8 @@ public UseCultureAttribute(string culture, string uiCulture)
/// and replaces them with the new cultures defined in the constructor.
/// </summary>
/// <param name="methodUnderTest">The method under test</param>
public override void Before(MethodInfo methodUnderTest)
/// <param name="test"></param>
public override void Before(MethodInfo methodUnderTest, IXunitTest test)
{
_originalCulture = Thread.CurrentThread.CurrentCulture;
_originalUiCulture = Thread.CurrentThread.CurrentUICulture;
Expand All @@ -78,7 +79,8 @@ public override void Before(MethodInfo methodUnderTest)
/// <see cref="CultureInfo.CurrentUICulture" /> to <see cref="Thread.CurrentPrincipal" />
/// </summary>
/// <param name="methodUnderTest">The method under test</param>
public override void After(MethodInfo methodUnderTest)
/// <param name="test"></param>
public override void After(MethodInfo methodUnderTest, IXunitTest test)
{
Thread.CurrentThread.CurrentCulture = _originalCulture;
Thread.CurrentThread.CurrentUICulture = _originalUiCulture;
Expand Down