Skip to content

Commit 381f477

Browse files
authored
Merge pull request #23 from dotTrench/feat/xunit3
Upgrade Xunit 2 to 3
2 parents 3c2ddba + 6ccfdc4 commit 381f477

File tree

6 files changed

+70
-33
lines changed

6 files changed

+70
-33
lines changed

src/ProjectDiff.Tool/ProjectDiffCommand.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ public sealed class ProjectDiffCommand : RootCommand
112112

113113
private static readonly Option<FileInfo[]> IgnoreChangedFilesOption = new("--ignore-changed-file")
114114
{
115-
116115
DefaultValueFactory = _ => [],
117116
Description =
118117
"Ignore changes in specific files. If these files are a part of the build evaluation process they will still be evaluated, however these files will be considered unchanged by the diff process"
@@ -198,7 +197,7 @@ CancellationToken cancellationToken
198197

199198
if (result.Status != ProjectDiffExecutionStatus.Success)
200199
{
201-
_console.Error.WriteLine(result.Status.ToString());
200+
await _console.Error.WriteLineAsync(result.Status.ToString());
202201
return 1;
203202
}
204203

test/ProjectDiff.Tests/Core/BranchTests.cs

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ public sealed class BranchTests
88
[Fact]
99
public async Task AddProjectInNewBranch()
1010
{
11-
using var repo = await TestRepository.SetupAsync(
12-
static async repo =>
11+
using var repo = await TestRepository.SetupAsync(static async repo =>
1312
{
1413
await repo.CreateSolutionAsync("Sample.sln", _ => { }); // Create an empty solution
1514
}
@@ -26,7 +25,12 @@ public async Task AddProjectInNewBranch()
2625

2726
var executor = new ProjectDiffExecutor(new ProjectDiffExecutorOptions());
2827

29-
var result = await executor.GetProjectDiff(new FileInfo(sln), "master", "feature");
28+
var result = await executor.GetProjectDiff(
29+
new FileInfo(sln),
30+
"master",
31+
"feature",
32+
TestContext.Current.CancellationToken
33+
);
3034

3135
Assert.Equal(ProjectDiffExecutionStatus.Success, result.Status);
3236
var diffProject = Assert.Single(result.Projects);
@@ -38,8 +42,7 @@ public async Task AddProjectInNewBranch()
3842
[Fact]
3943
public async Task RemoveProjectInNewBranch()
4044
{
41-
using var res = await TestRepository.SetupAsync(
42-
static async repo =>
45+
using var res = await TestRepository.SetupAsync(static async repo =>
4346
{
4447
var sln = await repo.CreateSolutionAsync("Sample.sln", sln => sln.AddProject("Sample/Sample.csproj"));
4548
var project = repo.CreateProject(
@@ -60,7 +63,12 @@ await repo.UpdateSolutionAsync(
6063
repo.StageAndCommitAllChanges();
6164

6265
var executor = new ProjectDiffExecutor(new ProjectDiffExecutorOptions());
63-
var result = await executor.GetProjectDiff(new FileInfo(sln), "master", "feature");
66+
var result = await executor.GetProjectDiff(
67+
new FileInfo(sln),
68+
"master",
69+
"feature",
70+
TestContext.Current.CancellationToken
71+
);
6472

6573
Assert.Equal(ProjectDiffExecutionStatus.Success, result.Status);
6674
var diffProject = Assert.Single(result.Projects);
@@ -72,8 +80,7 @@ await repo.UpdateSolutionAsync(
7280
[Fact]
7381
public async Task ModifyProjectInNewBranch()
7482
{
75-
using var res = await TestRepository.SetupAsync(
76-
static async repo =>
83+
using var res = await TestRepository.SetupAsync(static async repo =>
7784
{
7885
var sln = await repo.CreateSolutionAsync("Sample.sln", sln => sln.AddProject("Sample/Sample.csproj"));
7986
var project = repo.CreateProject(
@@ -90,7 +97,12 @@ public async Task ModifyProjectInNewBranch()
9097
await repo.WriteFileAsync("Sample/MyClass.cs", "// Some new content");
9198
repo.StageAndCommitAllChanges();
9299
var executor = new ProjectDiffExecutor(new ProjectDiffExecutorOptions());
93-
var result = await executor.GetProjectDiff(new FileInfo(sln), "master", "feature");
100+
var result = await executor.GetProjectDiff(
101+
new FileInfo(sln),
102+
"master",
103+
"feature",
104+
TestContext.Current.CancellationToken
105+
);
94106

95107
Assert.Equal(ProjectDiffExecutionStatus.Success, result.Status);
96108
var diffProject = Assert.Single(result.Projects);
@@ -101,8 +113,7 @@ public async Task ModifyProjectInNewBranch()
101113
[Fact]
102114
public async Task ModifyProjectInBaseBranch_WithNoMergeBaseOption()
103115
{
104-
using var res = await TestRepository.SetupAsync(
105-
static async repo =>
116+
using var res = await TestRepository.SetupAsync(static async repo =>
106117
{
107118
var sln = await repo.CreateSolutionAsync("Sample.sln", sln => sln.AddProject("Core/Core.csproj"));
108119
var project = repo.CreateProject(
@@ -119,7 +130,12 @@ public async Task ModifyProjectInBaseBranch_WithNoMergeBaseOption()
119130
repo.StageAndCommitAllChanges();
120131

121132
var executor = new ProjectDiffExecutor(new ProjectDiffExecutorOptions());
122-
var result = await executor.GetProjectDiff(new FileInfo(sln), "master", "feature");
133+
var result = await executor.GetProjectDiff(
134+
new FileInfo(sln),
135+
"master",
136+
"feature",
137+
TestContext.Current.CancellationToken
138+
);
123139

124140
Assert.Equal(ProjectDiffExecutionStatus.Success, result.Status);
125141
var diffProject = Assert.Single(result.Projects);
@@ -131,8 +147,7 @@ public async Task ModifyProjectInBaseBranch_WithNoMergeBaseOption()
131147
[Fact]
132148
public async Task ModifyProjectInBaseBranch_WithMergeBaseOption()
133149
{
134-
using var res = await TestRepository.SetupAsync(
135-
static async repo =>
150+
using var res = await TestRepository.SetupAsync(static async repo =>
136151
{
137152
var sln = await repo.CreateSolutionAsync("Sample.sln", sln => sln.AddProject("Core/Core.csproj"));
138153
var project = repo.CreateProject(
@@ -154,7 +169,12 @@ public async Task ModifyProjectInBaseBranch_WithMergeBaseOption()
154169
FindMergeBase = true
155170
}
156171
);
157-
var result = await executor.GetProjectDiff(new FileInfo(sln), "master", "feature");
172+
var result = await executor.GetProjectDiff(
173+
new FileInfo(sln),
174+
"master",
175+
"feature",
176+
TestContext.Current.CancellationToken
177+
);
158178

159179
Assert.Equal(ProjectDiffExecutionStatus.Success, result.Status);
160180
Assert.Empty(result.Projects);

test/ProjectDiff.Tests/Core/ErrorTests.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ public async Task InvalidBaseCommitReturnsError()
1212

1313
var executor = new ProjectDiffExecutor(new ProjectDiffExecutorOptions());
1414

15-
var result = await executor.GetProjectDiff(new FileInfo("doesnotexist.sln"), "SOME-INVALID-COMMIT-SHA");
15+
var result = await executor.GetProjectDiff(
16+
new FileInfo("doesnotexist.sln"),
17+
"SOME-INVALID-COMMIT-SHA",
18+
cancellationToken: TestContext.Current.CancellationToken
19+
);
1620

1721
Assert.Equal(ProjectDiffExecutionStatus.BaseCommitNotFound, result.Status);
1822
}
@@ -24,7 +28,12 @@ public async Task InvalidHeadCommitReturnsError()
2428

2529
var executor = new ProjectDiffExecutor(new ProjectDiffExecutorOptions());
2630

27-
var result = await executor.GetProjectDiff(new FileInfo("doesnotexist.sln"), "HEAD", "SOME-INVALID-COMMIT-SHA");
31+
var result = await executor.GetProjectDiff(
32+
new FileInfo("doesnotexist.sln"),
33+
"HEAD",
34+
"SOME-INVALID-COMMIT-SHA",
35+
TestContext.Current.CancellationToken
36+
);
2837

2938
Assert.Equal(ProjectDiffExecutionStatus.HeadCommitNotFound, result.Status);
3039
}

test/ProjectDiff.Tests/Core/IgnoreChangesTests.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ public sealed class IgnoreChangesTests
88
[Fact]
99
public async Task IgnoresModifiedFiles()
1010
{
11-
using var res = await TestRepository.SetupAsync(
12-
async r =>
11+
using var res = await TestRepository.SetupAsync(async r =>
1312
{
1413
r.CreateDirectory("Core");
1514
r.CreateProject("Core/Core.csproj");
@@ -34,7 +33,10 @@ public async Task IgnoresModifiedFiles()
3433
IgnoreChangedFiles = [new FileInfo(repo.GetPath("Core/Sample.cs"))]
3534
}
3635
);
37-
var diff = await executor.GetProjectDiff(new FileInfo(sln));
36+
var diff = await executor.GetProjectDiff(
37+
new FileInfo(sln),
38+
cancellationToken: TestContext.Current.CancellationToken
39+
);
3840
Assert.Equal(ProjectDiffExecutionStatus.Success, diff.Status);
3941

4042
Assert.Empty(diff.Projects);
@@ -45,8 +47,7 @@ public async Task IgnoresModifiedFiles()
4547
[Fact]
4648
public async Task IgnoresAddedFiles()
4749
{
48-
using var res = await TestRepository.SetupAsync(
49-
async r =>
50+
using var res = await TestRepository.SetupAsync(async r =>
5051
{
5152
r.CreateDirectory("Core");
5253
r.CreateProject("Core/Core.csproj");
@@ -70,7 +71,10 @@ public async Task IgnoresAddedFiles()
7071
}
7172
);
7273

73-
var diff = await executor.GetProjectDiff(new FileInfo(sln));
74+
var diff = await executor.GetProjectDiff(
75+
new FileInfo(sln),
76+
cancellationToken: TestContext.Current.CancellationToken
77+
);
7478
Assert.Equal(ProjectDiffExecutionStatus.Success, diff.Status);
7579

7680
Assert.Empty(diff.Projects);
@@ -84,8 +88,7 @@ public async Task IgnoresAddedFiles()
8488
[Fact]
8589
public async Task IgnoresDeletedFiles()
8690
{
87-
using var res = await TestRepository.SetupAsync(
88-
async r =>
91+
using var res = await TestRepository.SetupAsync(async r =>
8992
{
9093
r.CreateDirectory("Core");
9194
r.CreateProject("Core/Core.csproj");
@@ -107,7 +110,10 @@ public async Task IgnoresDeletedFiles()
107110
IgnoreChangedFiles = [new FileInfo(repo.GetPath("Core/Sample.cs"))]
108111
}
109112
);
110-
var diff = await executor.GetProjectDiff(new FileInfo(sln));
113+
var diff = await executor.GetProjectDiff(
114+
new FileInfo(sln),
115+
cancellationToken: TestContext.Current.CancellationToken
116+
);
111117
Assert.Equal(ProjectDiffExecutionStatus.Success, diff.Status);
112118

113119
Assert.Empty(diff.Projects);

test/ProjectDiff.Tests/Core/MultiFrameworkTests.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ public sealed class MultiFrameworkTests
88
[Fact]
99
public static async Task FileModifiedInMultiFrameworkProjectOnlyReturnsASingleProject()
1010
{
11-
using var res = await TestRepository.SetupAsync(
12-
static async r =>
11+
using var res = await TestRepository.SetupAsync(static async r =>
1312
{
1413
var sln = await r.CreateSolutionAsync("Sample.sln", sln => sln.AddProject("Sample/Sample.csproj"));
1514
r.CreateDirectory("Sample");
@@ -30,7 +29,11 @@ public static async Task FileModifiedInMultiFrameworkProjectOnlyReturnsASinglePr
3029
FindMergeBase = false
3130
}
3231
);
33-
var result = await executor.GetProjectDiff(new FileInfo(sln), "HEAD");
32+
var result = await executor.GetProjectDiff(
33+
new FileInfo(sln),
34+
"HEAD",
35+
cancellationToken: TestContext.Current.CancellationToken
36+
);
3437

3538
Assert.Equal(ProjectDiffExecutionStatus.Success, result.Status);
3639
var proj = Assert.Single(result.Projects);

test/ProjectDiff.Tests/ProjectDiff.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
1414
<PackageReference Include="System.Collections.Immutable" Version="9.0.6" />
1515
<PackageReference Include="System.IO.Pipelines" Version="9.0.6" />
16-
<PackageReference Include="Verify.Xunit" Version="30.4.0" />
17-
<PackageReference Include="xunit" Version="2.9.3"/>
16+
<PackageReference Include="Verify.XunitV3" Version="30.4.0" />
1817
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.1">
1918
<PrivateAssets>all</PrivateAssets>
2019
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2120
</PackageReference>
21+
<PackageReference Include="xunit.v3" Version="2.0.3" />
2222
</ItemGroup>
2323

2424
<ItemGroup>

0 commit comments

Comments
 (0)