Skip to content

Commit 4810455

Browse files
authored
Merge pull request #464 from nblumhardt/remove-fluent-assertions
Remove `FluentAssertions`
2 parents ac19795 + 38961b7 commit 4810455

File tree

3 files changed

+23
-32
lines changed

3 files changed

+23
-32
lines changed

test/Serilog.Settings.Configuration.Tests/PublishSingleFileTests.cs

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,99 +2,90 @@
22
using System.Text;
33
using CliWrap;
44
using CliWrap.Exceptions;
5-
using FluentAssertions;
6-
using FluentAssertions.Execution;
75
using Serilog.Settings.Configuration.Tests.Support;
86
using Xunit.Abstractions;
97

108
namespace Serilog.Settings.Configuration.Tests;
119

1210
[Trait("Category", "Integration")]
13-
public sealed class PublishSingleFileTests : IDisposable, IClassFixture<TestApp>
11+
public sealed class PublishSingleFileTests : IClassFixture<TestApp>
1412
{
1513
readonly ITestOutputHelper _outputHelper;
1614
readonly TestApp _testApp;
17-
readonly AssertionScope _scope;
1815

1916
public PublishSingleFileTests(ITestOutputHelper outputHelper, TestApp testApp)
2017
{
2118
_outputHelper = outputHelper;
2219
_testApp = testApp;
23-
_scope = new AssertionScope();
24-
}
25-
26-
public void Dispose()
27-
{
28-
_scope.Dispose();
2920
}
3021

3122
[Theory]
3223
[ClassData(typeof(PublishModeTheoryData))]
3324
public async Task RunTestApp_NoUsingAndNoAssembly(PublishMode publishMode)
3425
{
3526
var (isSingleFile, stdOut, stdErr) = await RunTestAppAsync(publishMode);
36-
stdOut.Should().Be(isSingleFile ? "Expected exception" : "(Main thread) [Information] Expected success");
37-
stdErr.Should().BeEmpty();
27+
Assert.Equal(stdOut, isSingleFile ? "Expected exception" : "(Main thread) [Information] Expected success");
28+
Assert.Empty(stdErr);
3829
}
3930

4031
[Theory]
4132
[ClassData(typeof(PublishModeTheoryData))]
4233
public async Task RunTestApp_UsingConsole(PublishMode publishMode)
4334
{
4435
var (isSingleFile, stdOut, stdErr) = await RunTestAppAsync(publishMode, "--using-console");
45-
stdOut.Should().Be(isSingleFile ? "() [Information] Expected success" : "(Main thread) [Information] Expected success");
36+
Assert.Equal(stdOut, isSingleFile ? "() [Information] Expected success" : "(Main thread) [Information] Expected success");
4637
if (isSingleFile)
47-
stdErr.Should().Contain("Unable to find a method called WithThreadName");
38+
Assert.Contains("Unable to find a method called WithThreadName", stdErr);
4839
else
49-
stdErr.Should().BeEmpty();
40+
Assert.Empty(stdErr);
5041
}
5142

5243
[Theory]
5344
[ClassData(typeof(PublishModeTheoryData))]
5445
public async Task RunTestApp_UsingThread(PublishMode publishMode)
5546
{
5647
var (isSingleFile, stdOut, stdErr) = await RunTestAppAsync(publishMode, "--using-thread");
57-
stdOut.Should().Be(isSingleFile ? "" : "(Main thread) [Information] Expected success");
48+
Assert.Equal(stdOut, isSingleFile ? "" : "(Main thread) [Information] Expected success");
5849
if (isSingleFile)
59-
stdErr.Should().Contain("Unable to find a method called Console");
50+
Assert.Contains("Unable to find a method called Console", stdErr);
6051
else
61-
stdErr.Should().BeEmpty();
52+
Assert.Empty(stdErr);
6253
}
6354

6455
[Theory]
6556
[ClassData(typeof(PublishModeTheoryData))]
6657
public async Task RunTestApp_AssemblyThread(PublishMode publishMode)
6758
{
6859
var (_, stdOut, stdErr) = await RunTestAppAsync(publishMode, "--assembly-thread");
69-
stdOut.Should().BeEmpty();
70-
stdErr.Should().Contain("Unable to find a method called Console");
60+
Assert.Empty(stdOut);
61+
Assert.Contains("Unable to find a method called Console", stdErr);
7162
}
7263

7364
[Theory]
7465
[ClassData(typeof(PublishModeTheoryData))]
7566
public async Task RunTestApp_AssemblyConsole(PublishMode publishMode)
7667
{
7768
var (_, stdOut, stdErr) = await RunTestAppAsync(publishMode, "--assembly-console");
78-
stdOut.Should().Be("() [Information] Expected success");
79-
stdErr.Should().Contain("Unable to find a method called WithThreadName");
69+
Assert.Equal("() [Information] Expected success", stdOut);
70+
Assert.Contains("Unable to find a method called WithThreadName", stdErr);
8071
}
8172

8273
[Theory]
8374
[ClassData(typeof(PublishModeAndStrategyTheoryData))]
8475
public async Task RunTestApp_ConsoleAndThread(PublishMode publishMode, string strategy)
8576
{
8677
var (_, stdOut, stdErr) = await RunTestAppAsync(publishMode, $"--{strategy}-console", $"--{strategy}-thread");
87-
stdOut.Should().Be("(Main thread) [Information] Expected success");
88-
stdErr.Should().BeEmpty();
78+
Assert.Equal("(Main thread) [Information] Expected success", stdOut);
79+
Assert.Empty(stdErr);
8980
}
9081

9182
[Theory]
9283
[ClassData(typeof(PublishModeTheoryData))]
9384
public async Task RunTestApp_ConfigureMinimumLevelOnly(PublishMode publishMode)
9485
{
9586
var (_, stdOut, stdErr) = await RunTestAppAsync(publishMode, "--minimum-level-only");
96-
stdOut.Should().Be("(Main thread) [Information] Expected success");
97-
stdErr.Should().BeEmpty();
87+
Assert.Equal("(Main thread) [Information] Expected success", stdOut);
88+
Assert.Empty(stdErr);
9889
}
9990

10091
async Task<(bool IsSingleFile, string StdOut, string StdErr)> RunTestAppAsync(PublishMode publishMode, params string[] args)

test/Serilog.Settings.Configuration.Tests/Serilog.Settings.Configuration.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
<ItemGroup>
2222
<PackageReference Include="CliWrap" Version="3.10.0" />
23-
<PackageReference Include="FluentAssertions" Version="8.8.0" />
2423
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.0" />
2524
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
2625
<PackageReference Include="NuGet.Frameworks" Version="7.0.0" />

test/Serilog.Settings.Configuration.Tests/Support/TestApp.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Text;
44
using CliWrap;
55
using CliWrap.Exceptions;
6-
using FluentAssertions;
76
using Polly;
87
using Xunit.Abstractions;
98
using Xunit.Sdk;
@@ -108,16 +107,18 @@ async Task PublishAsync(PublishMode publishMode)
108107

109108
var executableFileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "TestApp.exe" : "TestApp";
110109
var executableFile = new FileInfo(Path.Combine(outputDirectory.FullName, executableFileName));
111-
executableFile.Exists.Should().BeTrue();
110+
Assert.True(executableFile.Exists);
112111
var dlls = executableFile.Directory!.EnumerateFiles("*.dll");
113112
if (publishMode == PublishMode.Standard)
114113
{
115-
dlls.Should().NotBeEmpty(because: $"the test app was _not_ published as single-file ({publishMode})");
114+
// the test app was _not_ published as single-file
115+
Assert.NotEmpty(dlls);
116116
}
117117
else
118118
{
119-
dlls.Should().BeEmpty(because: $"the test app was published as single-file ({publishMode})");
120-
executableFile.Directory.EnumerateFiles().Should().ContainSingle().Which.FullName.Should().Be(executableFile.FullName);
119+
// the test app was published as single-file
120+
Assert.Empty(dlls);
121+
Assert.Single(executableFile.Directory.EnumerateFiles(), f => f.FullName == executableFile.FullName);
121122
}
122123

123124
_executables[publishMode] = executableFile;

0 commit comments

Comments
 (0)