Skip to content

Commit 763095b

Browse files
committed
Simplify tests
1 parent 4401690 commit 763095b

File tree

5 files changed

+14
-88
lines changed

5 files changed

+14
-88
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ jobs:
6767
name: nuget
6868
path: ${{ env.NuGetDirectory }}
6969
- uses: actions/setup-dotnet@v4
70-
with:
71-
dotnet-version: |
72-
9.0.x
73-
8.0.x
7470
- run: dotnet --info
7571
- run: dotnet test tests/Meziantou.DotNet.CodingStandard.Tests/Meziantou.DotNet.CodingStandard.Tests.csproj --logger "trx;LogFileName=test_results.trx" --results-directory test_results
7672
- uses: actions/upload-artifact@v4

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
33
"rollForward": "major",
4-
"version": "8.0.402"
4+
"version": "9.0.100"
55
}
66
}

tests/Meziantou.DotNet.CodingStandard.Tests/CodingStandardTests.cs

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,11 @@
44
using System.Xml.Linq;
55
using Meziantou.Framework;
66
using Xunit.Abstractions;
7-
using static System.Net.Mime.MediaTypeNames;
87

98
namespace Meziantou.DotNet.CodingStandard.Tests;
109

11-
public abstract class CodingStandardTests(PackageFixture fixture, ITestOutputHelper testOutputHelper, string dotnetChannel) : IClassFixture<PackageFixture>
10+
public sealed class CodingStandardTests(PackageFixture fixture, ITestOutputHelper testOutputHelper) : IClassFixture<PackageFixture>
1211
{
13-
private async Task<string> CreateGlobalJsonContent()
14-
{
15-
var version = await DotnetVersions.GetLatestVersionAsync(dotnetChannel);
16-
return $$"""
17-
{
18-
"sdk": {
19-
"version": "{{version}}"
20-
}
21-
}
22-
""";
23-
}
24-
2512
[Fact]
2613
public async Task BannedSymbolsAreReported()
2714
{
@@ -310,9 +297,17 @@ public ProjectBuilder AddCsprojFile((string Name, string Value)[] properties = n
310297

311298
public async Task<BuildResult> BuildAndGetOutput(string[] buildArguments = null)
312299
{
313-
string dotnetVersion = await _test.CreateGlobalJsonContent();
314-
_testOutputHelper.WriteLine("Global.json version:\n" + dotnetVersion);
315-
_directory.CreateTextFile("global.json", dotnetVersion);
300+
var globaljsonPsi = new ProcessStartInfo("dotnet", "new global.json")
301+
{
302+
WorkingDirectory = _directory.FullPath,
303+
UseShellExecute = false,
304+
RedirectStandardOutput = true,
305+
306+
RedirectStandardError = true,
307+
};
308+
var result = await globaljsonPsi.RunAsTaskAsync();
309+
_testOutputHelper.WriteLine("Process exit code: " + result.ExitCode);
310+
_testOutputHelper.WriteLine(result.Output.ToString());
316311

317312
var psi = new ProcessStartInfo("dotnet")
318313
{
@@ -334,7 +329,7 @@ public async Task<BuildResult> BuildAndGetOutput(string[] buildArguments = null)
334329
psi.Environment.Remove("CI");
335330
psi.Environment.Remove("GITHUB_ACTIONS");
336331

337-
var result = await psi.RunAsTaskAsync();
332+
result = await psi.RunAsTaskAsync();
338333
_testOutputHelper.WriteLine("Process exit code: " + result.ExitCode);
339334
_testOutputHelper.WriteLine(result.Output.ToString());
340335

@@ -400,13 +395,4 @@ public override string ToString()
400395
return Text;
401396
}
402397
}
403-
}
404-
405-
public sealed class CodingStandardTestsNet8_0(PackageFixture fixture, ITestOutputHelper testOutputHelper) : CodingStandardTests(fixture, testOutputHelper, "8.0")
406-
{
407-
408-
}
409-
410-
public sealed class CodingStandardTestsNet9_0(PackageFixture fixture, ITestOutputHelper testOutputHelper) : CodingStandardTests(fixture, testOutputHelper, "9.0")
411-
{
412398
}

tests/Meziantou.DotNet.CodingStandard.Tests/DotnetVersions.cs

Lines changed: 0 additions & 55 deletions
This file was deleted.

tests/Meziantou.DotNet.CodingStandard.Tests/Meziantou.DotNet.CodingStandard.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
<PackageReference Include="Meziantou.Framework" Version="3.0.41" />
1313
<PackageReference Include="Meziantou.Framework.TemporaryDirectory" Version="1.0.9" />
1414
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
15-
<PackageReference Include="NuGet.Versioning" Version="6.11.1" />
1615
<PackageReference Include="xunit" Version="2.9.2" />
1716
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
1817
<PrivateAssets>all</PrivateAssets>

0 commit comments

Comments
 (0)