Skip to content

Commit dd5ab97

Browse files
Add xunit.v3 package (#51)
* Add xunit.v3 package * Rebased
1 parent d5676c2 commit dd5ab97

File tree

15 files changed

+424
-9
lines changed

15 files changed

+424
-9
lines changed

.github/workflows/publish.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ jobs:
2020
PROJECT_FILE_PATH: src/Exercism.Tests/Exercism.Tests.csproj
2121
NUGET_KEY: ${{ secrets.NUGET_API_KEY }}
2222
INCLUDE_SYMBOLS: true
23+
- uses: rohith/publish-nuget@c12b8546b67672ee38ac87bea491ac94a587f7cc # 2.5.5
24+
with:
25+
PROJECT_FILE_PATH: src/Exercism.Tests.xunit.v3/Exercism.Tests.xunit.v3.csproj
26+
NUGET_KEY: ${{ secrets.NUGET_API_KEY }}
27+
INCLUDE_SYMBOLS: true

Exercism.Tests.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{14AF2F5A
1111
EndProject
1212
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercism.Tests.Tests", "tests\Exercism.Tests.Tests\Exercism.Tests.Tests.csproj", "{900E6F72-8D50-466D-A6C4-DA9714F4048C}"
1313
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercism.Tests.xunit.v3", "src\Exercism.Tests.xunit.v3\Exercism.Tests.xunit.v3.csproj", "{90C6D541-8975-4176-A164-3C119CDE56C1}"
15+
EndProject
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercism.Tests.xunit.v3.Tests", "tests\Exercism.Tests.xunit.v3.Tests\Exercism.Tests.xunit.v3.Tests.csproj", "{B3A9A059-8D28-4841-9CF8-323EFBFF41C9}"
17+
EndProject
1418
Global
1519
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1620
Debug|Any CPU = Debug|Any CPU
@@ -28,9 +32,19 @@ Global
2832
{900E6F72-8D50-466D-A6C4-DA9714F4048C}.Debug|Any CPU.Build.0 = Debug|Any CPU
2933
{900E6F72-8D50-466D-A6C4-DA9714F4048C}.Release|Any CPU.ActiveCfg = Release|Any CPU
3034
{900E6F72-8D50-466D-A6C4-DA9714F4048C}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{90C6D541-8975-4176-A164-3C119CDE56C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36+
{90C6D541-8975-4176-A164-3C119CDE56C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
37+
{90C6D541-8975-4176-A164-3C119CDE56C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
38+
{90C6D541-8975-4176-A164-3C119CDE56C1}.Release|Any CPU.Build.0 = Release|Any CPU
39+
{B3A9A059-8D28-4841-9CF8-323EFBFF41C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40+
{B3A9A059-8D28-4841-9CF8-323EFBFF41C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
41+
{B3A9A059-8D28-4841-9CF8-323EFBFF41C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
42+
{B3A9A059-8D28-4841-9CF8-323EFBFF41C9}.Release|Any CPU.Build.0 = Release|Any CPU
3143
EndGlobalSection
3244
GlobalSection(NestedProjects) = preSolution
3345
{3FD7D5E5-05AC-4B9D-8062-63430962A4BE} = {2DA5F395-76DA-446D-99AC-4F56ED0AFE01}
3446
{900E6F72-8D50-466D-A6C4-DA9714F4048C} = {14AF2F5A-6AB7-480D-9790-7A00C9A72C20}
47+
{90C6D541-8975-4176-A164-3C119CDE56C1} = {2DA5F395-76DA-446D-99AC-4F56ED0AFE01}
48+
{B3A9A059-8D28-4841-9CF8-323EFBFF41C9} = {14AF2F5A-6AB7-480D-9790-7A00C9A72C20}
3549
EndGlobalSection
3650
EndGlobal

src/Directory.Build.props

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project>
2+
<PropertyGroup>
3+
<Authors>Erik Schierboom</Authors>
4+
<Company>Exercism</Company>
5+
<PackageTags>Exercism;Testing</PackageTags>
6+
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
7+
<PackageIcon>icon.png</PackageIcon>
8+
<RepositoryUrl>https://github.com/exercism/dotnet-tests</RepositoryUrl>
9+
</PropertyGroup>
10+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<RootNamespace>Exercism.Tests</RootNamespace>
8+
</PropertyGroup>
9+
10+
<PropertyGroup>
11+
<PackageId>Exercism.Tests.xunit.v3</PackageId>
12+
<Version>0.1.0-beta1</Version>
13+
<Title>Exercism Testing using xUnit v3</Title>
14+
<Description>This library adds Exercism-specific functionality related to testing solutions using xUnit v3.</Description>
15+
</PropertyGroup>
16+
17+
<ItemGroup>
18+
<None Include="images\icon.png" Pack="true" PackagePath="icon.png" />
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<PackageReference Include="xunit.v3.extensibility.core" Version="1.1.0" />
23+
</ItemGroup>
24+
25+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace Exercism.Tests;
2+
3+
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
4+
public class TaskAttribute : Attribute
5+
{
6+
public int Number { get; }
7+
8+
public TaskAttribute(int number)
9+
{
10+
if (number <= 0) throw new ArgumentOutOfRangeException(nameof(number), number, "Number must be greater than zero");
11+
12+
Number = number;
13+
}
14+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System.Globalization;
2+
using System.Reflection;
3+
using Xunit.v3;
4+
5+
namespace Exercism.Tests;
6+
7+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
8+
public class UseCultureAttribute : BeforeAfterTestAttribute
9+
{
10+
private readonly CultureInfo _culture;
11+
private readonly CultureInfo _uiCulture;
12+
13+
private CultureInfo? _originalCulture;
14+
private CultureInfo? _originalUiCulture;
15+
16+
public UseCultureAttribute()
17+
: this(CultureInfo.InvariantCulture, CultureInfo.InvariantCulture)
18+
{
19+
}
20+
21+
public UseCultureAttribute(string culture)
22+
: this(culture, culture)
23+
{
24+
}
25+
26+
public UseCultureAttribute(string culture, string uiCulture)
27+
: this(new CultureInfo(culture, false), new CultureInfo(uiCulture, false))
28+
{
29+
}
30+
31+
public UseCultureAttribute(CultureInfo culture, CultureInfo uiCulture)
32+
{
33+
_culture = culture;
34+
_uiCulture = uiCulture;
35+
}
36+
37+
public override void Before(MethodInfo methodUnderTest, IXunitTest test)
38+
{
39+
_originalCulture = CultureInfo.CurrentCulture;
40+
_originalUiCulture = CultureInfo.CurrentUICulture;
41+
42+
CultureInfo.CurrentCulture = _culture;
43+
CultureInfo.CurrentUICulture = _uiCulture;
44+
}
45+
46+
public override void After(MethodInfo methodUnderTest, IXunitTest test)
47+
{
48+
CultureInfo.CurrentCulture = _originalCulture!;
49+
CultureInfo.CurrentUICulture = _originalUiCulture!;
50+
}
51+
}
2.05 KB
Loading
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"version": 1,
3+
"dependencies": {
4+
"net6.0": {
5+
"xunit.v3.extensibility.core": {
6+
"type": "Direct",
7+
"requested": "[1.1.0, )",
8+
"resolved": "1.1.0",
9+
"contentHash": "AeQbbYN001x0c+B9pqwml6jZPovHz8O/sOp7jmrjz90rUzz/QPal12SlHLKYszR44CMnW4MsDam3RYT5pkYUxw==",
10+
"dependencies": {
11+
"xunit.v3.common": "[1.1.0]"
12+
}
13+
},
14+
"Microsoft.Bcl.AsyncInterfaces": {
15+
"type": "Transitive",
16+
"resolved": "6.0.0",
17+
"contentHash": "UcSjPsst+DfAdJGVDsu346FX0ci0ah+lw3WRtn18NUwEqRt70HaOQ7lI72vy3+1LxtqI3T5GWwV39rQSrCzAeg=="
18+
},
19+
"xunit.v3.common": {
20+
"type": "Transitive",
21+
"resolved": "1.1.0",
22+
"contentHash": "Cq55z8pC7fOkfj+3TB/YQ6OW96qWqxKiMd15CtkIl37VtV9EsiUL4B4HsR6VLJCzkk7cBiXQ1ABVIcp3TCm6HQ==",
23+
"dependencies": {
24+
"Microsoft.Bcl.AsyncInterfaces": "6.0.0"
25+
}
26+
}
27+
}
28+
}
29+
}

src/Exercism.Tests/Exercism.Tests.csproj

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@
55
<PackageId>Exercism.Tests</PackageId>
66
<Version>0.1.0-beta1</Version>
77
<Title>Exercism Testing</Title>
8-
<Description>This library adds Exercism-specific functionality related to testing solutions.</Description>
9-
<Authors>Erik Schierboom</Authors>
10-
<Company>Exercism</Company>
11-
<PackageTags>Exercism;Testing</PackageTags>
12-
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
13-
<PackageIcon>icon.png</PackageIcon>
14-
<RepositoryUrl>https://github.com/exercism/dotnet-tests</RepositoryUrl>
8+
<Description>This library adds Exercism-specific functionality related to testing solutions.</Description>
159
</PropertyGroup>
1610

1711
<ItemGroup>

tests/Exercism.Tests.Tests/UseCultureAttributeTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public void SpecifyCultureAndUiCulture()
2626
[UseCulture]
2727
public void DontSpecifyCulture()
2828
{
29-
Assert.Equal(CultureInfo.InvariantCulture, CultureInfo.CurrentCulture);
30-
Assert.Equal(CultureInfo.InvariantCulture, CultureInfo.CurrentUICulture);
29+
Assert.Equal(CultureInfo.InvariantCulture.Name, CultureInfo.CurrentCulture.Name);
30+
Assert.Equal(CultureInfo.InvariantCulture.Name, CultureInfo.CurrentUICulture.Name);
3131
}
3232

3333
[Fact]

0 commit comments

Comments
 (0)