From 38961b7ebfd04f7fe50ec6571abe53cd33795425 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Wed, 26 Nov 2025 15:55:50 +1000 Subject: [PATCH] Remove FluentAssertions --- .../PublishSingleFileTests.cs | 43 ++++++++----------- ...erilog.Settings.Configuration.Tests.csproj | 1 - .../Support/TestApp.cs | 11 ++--- 3 files changed, 23 insertions(+), 32 deletions(-) diff --git a/test/Serilog.Settings.Configuration.Tests/PublishSingleFileTests.cs b/test/Serilog.Settings.Configuration.Tests/PublishSingleFileTests.cs index c2f5d33..b2c9cd0 100644 --- a/test/Serilog.Settings.Configuration.Tests/PublishSingleFileTests.cs +++ b/test/Serilog.Settings.Configuration.Tests/PublishSingleFileTests.cs @@ -2,30 +2,21 @@ using System.Text; using CliWrap; using CliWrap.Exceptions; -using FluentAssertions; -using FluentAssertions.Execution; using Serilog.Settings.Configuration.Tests.Support; using Xunit.Abstractions; namespace Serilog.Settings.Configuration.Tests; [Trait("Category", "Integration")] -public sealed class PublishSingleFileTests : IDisposable, IClassFixture +public sealed class PublishSingleFileTests : IClassFixture { readonly ITestOutputHelper _outputHelper; readonly TestApp _testApp; - readonly AssertionScope _scope; public PublishSingleFileTests(ITestOutputHelper outputHelper, TestApp testApp) { _outputHelper = outputHelper; _testApp = testApp; - _scope = new AssertionScope(); - } - - public void Dispose() - { - _scope.Dispose(); } [Theory] @@ -33,8 +24,8 @@ public void Dispose() public async Task RunTestApp_NoUsingAndNoAssembly(PublishMode publishMode) { var (isSingleFile, stdOut, stdErr) = await RunTestAppAsync(publishMode); - stdOut.Should().Be(isSingleFile ? "Expected exception" : "(Main thread) [Information] Expected success"); - stdErr.Should().BeEmpty(); + Assert.Equal(stdOut, isSingleFile ? "Expected exception" : "(Main thread) [Information] Expected success"); + Assert.Empty(stdErr); } [Theory] @@ -42,11 +33,11 @@ public async Task RunTestApp_NoUsingAndNoAssembly(PublishMode publishMode) public async Task RunTestApp_UsingConsole(PublishMode publishMode) { var (isSingleFile, stdOut, stdErr) = await RunTestAppAsync(publishMode, "--using-console"); - stdOut.Should().Be(isSingleFile ? "() [Information] Expected success" : "(Main thread) [Information] Expected success"); + Assert.Equal(stdOut, isSingleFile ? "() [Information] Expected success" : "(Main thread) [Information] Expected success"); if (isSingleFile) - stdErr.Should().Contain("Unable to find a method called WithThreadName"); + Assert.Contains("Unable to find a method called WithThreadName", stdErr); else - stdErr.Should().BeEmpty(); + Assert.Empty(stdErr); } [Theory] @@ -54,11 +45,11 @@ public async Task RunTestApp_UsingConsole(PublishMode publishMode) public async Task RunTestApp_UsingThread(PublishMode publishMode) { var (isSingleFile, stdOut, stdErr) = await RunTestAppAsync(publishMode, "--using-thread"); - stdOut.Should().Be(isSingleFile ? "" : "(Main thread) [Information] Expected success"); + Assert.Equal(stdOut, isSingleFile ? "" : "(Main thread) [Information] Expected success"); if (isSingleFile) - stdErr.Should().Contain("Unable to find a method called Console"); + Assert.Contains("Unable to find a method called Console", stdErr); else - stdErr.Should().BeEmpty(); + Assert.Empty(stdErr); } [Theory] @@ -66,8 +57,8 @@ public async Task RunTestApp_UsingThread(PublishMode publishMode) public async Task RunTestApp_AssemblyThread(PublishMode publishMode) { var (_, stdOut, stdErr) = await RunTestAppAsync(publishMode, "--assembly-thread"); - stdOut.Should().BeEmpty(); - stdErr.Should().Contain("Unable to find a method called Console"); + Assert.Empty(stdOut); + Assert.Contains("Unable to find a method called Console", stdErr); } [Theory] @@ -75,8 +66,8 @@ public async Task RunTestApp_AssemblyThread(PublishMode publishMode) public async Task RunTestApp_AssemblyConsole(PublishMode publishMode) { var (_, stdOut, stdErr) = await RunTestAppAsync(publishMode, "--assembly-console"); - stdOut.Should().Be("() [Information] Expected success"); - stdErr.Should().Contain("Unable to find a method called WithThreadName"); + Assert.Equal("() [Information] Expected success", stdOut); + Assert.Contains("Unable to find a method called WithThreadName", stdErr); } [Theory] @@ -84,8 +75,8 @@ public async Task RunTestApp_AssemblyConsole(PublishMode publishMode) public async Task RunTestApp_ConsoleAndThread(PublishMode publishMode, string strategy) { var (_, stdOut, stdErr) = await RunTestAppAsync(publishMode, $"--{strategy}-console", $"--{strategy}-thread"); - stdOut.Should().Be("(Main thread) [Information] Expected success"); - stdErr.Should().BeEmpty(); + Assert.Equal("(Main thread) [Information] Expected success", stdOut); + Assert.Empty(stdErr); } [Theory] @@ -93,8 +84,8 @@ public async Task RunTestApp_ConsoleAndThread(PublishMode publishMode, string st public async Task RunTestApp_ConfigureMinimumLevelOnly(PublishMode publishMode) { var (_, stdOut, stdErr) = await RunTestAppAsync(publishMode, "--minimum-level-only"); - stdOut.Should().Be("(Main thread) [Information] Expected success"); - stdErr.Should().BeEmpty(); + Assert.Equal("(Main thread) [Information] Expected success", stdOut); + Assert.Empty(stdErr); } async Task<(bool IsSingleFile, string StdOut, string StdErr)> RunTestAppAsync(PublishMode publishMode, params string[] args) diff --git a/test/Serilog.Settings.Configuration.Tests/Serilog.Settings.Configuration.Tests.csproj b/test/Serilog.Settings.Configuration.Tests/Serilog.Settings.Configuration.Tests.csproj index 548a207..d70d65c 100644 --- a/test/Serilog.Settings.Configuration.Tests/Serilog.Settings.Configuration.Tests.csproj +++ b/test/Serilog.Settings.Configuration.Tests/Serilog.Settings.Configuration.Tests.csproj @@ -20,7 +20,6 @@ - diff --git a/test/Serilog.Settings.Configuration.Tests/Support/TestApp.cs b/test/Serilog.Settings.Configuration.Tests/Support/TestApp.cs index 7cf4183..69a01d3 100644 --- a/test/Serilog.Settings.Configuration.Tests/Support/TestApp.cs +++ b/test/Serilog.Settings.Configuration.Tests/Support/TestApp.cs @@ -3,7 +3,6 @@ using System.Text; using CliWrap; using CliWrap.Exceptions; -using FluentAssertions; using Polly; using Xunit.Abstractions; using Xunit.Sdk; @@ -108,16 +107,18 @@ async Task PublishAsync(PublishMode publishMode) var executableFileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "TestApp.exe" : "TestApp"; var executableFile = new FileInfo(Path.Combine(outputDirectory.FullName, executableFileName)); - executableFile.Exists.Should().BeTrue(); + Assert.True(executableFile.Exists); var dlls = executableFile.Directory!.EnumerateFiles("*.dll"); if (publishMode == PublishMode.Standard) { - dlls.Should().NotBeEmpty(because: $"the test app was _not_ published as single-file ({publishMode})"); + // the test app was _not_ published as single-file + Assert.NotEmpty(dlls); } else { - dlls.Should().BeEmpty(because: $"the test app was published as single-file ({publishMode})"); - executableFile.Directory.EnumerateFiles().Should().ContainSingle().Which.FullName.Should().Be(executableFile.FullName); + // the test app was published as single-file + Assert.Empty(dlls); + Assert.Single(executableFile.Directory.EnumerateFiles(), f => f.FullName == executableFile.FullName); } _executables[publishMode] = executableFile;