Skip to content

Commit

Permalink
Added CookieCrumble.Xunit3 (#7846)
Browse files Browse the repository at this point in the history
  • Loading branch information
glen-84 authored Dec 18, 2024
1 parent c31b5e5 commit 91b8977
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/CookieCrumble/CookieCrumble.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CookieCrumble.TUnit", "src\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CookieCrumble.Xunit", "src\CookieCrumble.Xunit\CookieCrumble.Xunit.csproj", "{CEE25A68-69B5-4CFD-9C35-E82736B1E205}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CookieCrumble.Xunit3", "src\CookieCrumble.Xunit3\CookieCrumble.Xunit3.csproj", "{20ED55B7-E3E7-4CDB-A3CE-87BCB42A4264}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{EB8F1D90-60D6-48FA-9744-D4180A0E4AC0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CookieCrumble.Tests", "test\CookieCrumble.Tests\CookieCrumble.Tests.csproj", "{844E7501-7ED6-4548-8E99-D8E50D4F39A4}"
Expand Down Expand Up @@ -48,6 +50,10 @@ Global
{CEE25A68-69B5-4CFD-9C35-E82736B1E205}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEE25A68-69B5-4CFD-9C35-E82736B1E205}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CEE25A68-69B5-4CFD-9C35-E82736B1E205}.Release|Any CPU.Build.0 = Release|Any CPU
{20ED55B7-E3E7-4CDB-A3CE-87BCB42A4264}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{20ED55B7-E3E7-4CDB-A3CE-87BCB42A4264}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20ED55B7-E3E7-4CDB-A3CE-87BCB42A4264}.Release|Any CPU.ActiveCfg = Release|Any CPU
{20ED55B7-E3E7-4CDB-A3CE-87BCB42A4264}.Release|Any CPU.Build.0 = Release|Any CPU
{844E7501-7ED6-4548-8E99-D8E50D4F39A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{844E7501-7ED6-4548-8E99-D8E50D4F39A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{844E7501-7ED6-4548-8E99-D8E50D4F39A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -59,6 +65,7 @@ Global
{9B57E4BC-E62A-4B7B-94FB-462C5F92D35B} = {2465C122-714C-4D0A-A24D-D9C22A25D73A}
{CB61556C-4E8D-4B70-9CD8-C9CB254BB423} = {2465C122-714C-4D0A-A24D-D9C22A25D73A}
{CEE25A68-69B5-4CFD-9C35-E82736B1E205} = {2465C122-714C-4D0A-A24D-D9C22A25D73A}
{20ED55B7-E3E7-4CDB-A3CE-87BCB42A4264} = {2465C122-714C-4D0A-A24D-D9C22A25D73A}
{844E7501-7ED6-4548-8E99-D8E50D4F39A4} = {EB8F1D90-60D6-48FA-9744-D4180A0E4AC0}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="xunit.v3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../CookieCrumble/CookieCrumble.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace CookieCrumble.Xunit3;

public static class CookieCrumbleXunit3
{
public static void Initialize()
{
Snapshot.RegisterTestFramework(new Xunit3Framework());
}
}
22 changes: 22 additions & 0 deletions src/CookieCrumble/src/CookieCrumble.Xunit3/Xunit3Framework.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Reflection;
using Xunit;
using Xunit.Sdk;

namespace CookieCrumble.Xunit3;

public class Xunit3Framework : ITestFramework
{
public bool IsValidTestMethod(MemberInfo? method)
=> IsFactTestMethod(method) || IsTheoryTestMethod(method);

private static bool IsFactTestMethod(MemberInfo? method)
=> method?.GetCustomAttributes(typeof(FactAttribute)).Any() ?? false;

private static bool IsTheoryTestMethod(MemberInfo? method)
=> method?.GetCustomAttributes(typeof(TheoryAttribute)).Any() ?? false;

public void ThrowTestException(string message)
{
throw new XunitException(message);
}
}
1 change: 1 addition & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<PackageVersion Include="System.Reactive" Version="6.0.0" />
<PackageVersion Include="Xunit" Version="2.9.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="xunit.v3" Version="1.0.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="17.12.5" />
<PackageVersion Include="TUnit" Version="0.4.71" />
</ItemGroup>
Expand Down

0 comments on commit 91b8977

Please sign in to comment.