From 58edeebec9370c53e6364defcf4ff28ef2c3c5bd Mon Sep 17 00:00:00 2001 From: Mauro Servienti Date: Tue, 6 Oct 2026 10:33:24 +0200 Subject: [PATCH 1/2] Replace Verify with a minimal approval helper Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AixzAbo1zbJgxpHo7vyoSc --- .../Approver.cs | 28 ++++++++++++++++++ ...ServiceBus.IntegrationTesting.Tests.csproj | 1 - ...pi_matches_approved_snapshot.approved.txt} | 0 ...pi_matches_approved_snapshot.approved.txt} | 0 ...pi_matches_approved_snapshot.approved.txt} | 0 ...pi_matches_approved_snapshot.approved.txt} | 0 ...pi_matches_approved_snapshot.approved.txt} | 0 ...pi_matches_approved_snapshot.approved.txt} | 0 ...pi_matches_approved_snapshot.approved.txt} | 0 .../PublicApiTests.cs | 29 +++++++++---------- 10 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 src/NServiceBus.IntegrationTesting.Tests/Approver.cs rename src/NServiceBus.IntegrationTesting.Tests/{PublicApiTests.MongoDb_PublicApi_matches_approved_snapshot.verified.txt => PublicApiTests.MongoDb_PublicApi_matches_approved_snapshot.approved.txt} (100%) rename src/NServiceBus.IntegrationTesting.Tests/{PublicApiTests.MySql_PublicApi_matches_approved_snapshot.verified.txt => PublicApiTests.MySql_PublicApi_matches_approved_snapshot.approved.txt} (100%) rename src/NServiceBus.IntegrationTesting.Tests/{PublicApiTests.PostgreSql_PublicApi_matches_approved_snapshot.verified.txt => PublicApiTests.PostgreSql_PublicApi_matches_approved_snapshot.approved.txt} (100%) rename src/NServiceBus.IntegrationTesting.Tests/{PublicApiTests.PublicApi_matches_approved_snapshot.verified.txt => PublicApiTests.PublicApi_matches_approved_snapshot.approved.txt} (100%) rename src/NServiceBus.IntegrationTesting.Tests/{PublicApiTests.RabbitMQ_PublicApi_matches_approved_snapshot.verified.txt => PublicApiTests.RabbitMQ_PublicApi_matches_approved_snapshot.approved.txt} (100%) rename src/NServiceBus.IntegrationTesting.Tests/{PublicApiTests.RavenDb_PublicApi_matches_approved_snapshot.verified.txt => PublicApiTests.RavenDb_PublicApi_matches_approved_snapshot.approved.txt} (100%) rename src/NServiceBus.IntegrationTesting.Tests/{PublicApiTests.SqlServer_PublicApi_matches_approved_snapshot.verified.txt => PublicApiTests.SqlServer_PublicApi_matches_approved_snapshot.approved.txt} (100%) diff --git a/src/NServiceBus.IntegrationTesting.Tests/Approver.cs b/src/NServiceBus.IntegrationTesting.Tests/Approver.cs new file mode 100644 index 0000000..7efeafe --- /dev/null +++ b/src/NServiceBus.IntegrationTesting.Tests/Approver.cs @@ -0,0 +1,28 @@ +using System.Runtime.CompilerServices; + +namespace NServiceBus.IntegrationTesting.Tests; + +static class Approver +{ + public static void Verify(string value, [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "") + { + var directory = Path.GetDirectoryName(callerFilePath)!; + var baseName = $"{Path.GetFileNameWithoutExtension(callerFilePath)}.{callerMemberName}"; + var approvedFile = Path.Combine(directory, $"{baseName}.approved.txt"); + var receivedFile = Path.Combine(directory, $"{baseName}.received.txt"); + + var received = Normalize(value); + var approved = File.Exists(approvedFile) ? Normalize(File.ReadAllText(approvedFile)) : null; + + if (received == approved) + { + File.Delete(receivedFile); + return; + } + + File.WriteAllText(receivedFile, received); + Assert.Fail($"Received value does not match '{approvedFile}'. If the change is expected, replace the approved file with '{receivedFile}'."); + } + + static string Normalize(string value) => value.Replace("\r\n", "\n").TrimEnd(); +} diff --git a/src/NServiceBus.IntegrationTesting.Tests/NServiceBus.IntegrationTesting.Tests.csproj b/src/NServiceBus.IntegrationTesting.Tests/NServiceBus.IntegrationTesting.Tests.csproj index 18a184f..ff30027 100644 --- a/src/NServiceBus.IntegrationTesting.Tests/NServiceBus.IntegrationTesting.Tests.csproj +++ b/src/NServiceBus.IntegrationTesting.Tests/NServiceBus.IntegrationTesting.Tests.csproj @@ -15,7 +15,6 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.MongoDb_PublicApi_matches_approved_snapshot.verified.txt b/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.MongoDb_PublicApi_matches_approved_snapshot.approved.txt similarity index 100% rename from src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.MongoDb_PublicApi_matches_approved_snapshot.verified.txt rename to src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.MongoDb_PublicApi_matches_approved_snapshot.approved.txt diff --git a/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.MySql_PublicApi_matches_approved_snapshot.verified.txt b/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.MySql_PublicApi_matches_approved_snapshot.approved.txt similarity index 100% rename from src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.MySql_PublicApi_matches_approved_snapshot.verified.txt rename to src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.MySql_PublicApi_matches_approved_snapshot.approved.txt diff --git a/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.PostgreSql_PublicApi_matches_approved_snapshot.verified.txt b/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.PostgreSql_PublicApi_matches_approved_snapshot.approved.txt similarity index 100% rename from src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.PostgreSql_PublicApi_matches_approved_snapshot.verified.txt rename to src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.PostgreSql_PublicApi_matches_approved_snapshot.approved.txt diff --git a/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.PublicApi_matches_approved_snapshot.verified.txt b/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.PublicApi_matches_approved_snapshot.approved.txt similarity index 100% rename from src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.PublicApi_matches_approved_snapshot.verified.txt rename to src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.PublicApi_matches_approved_snapshot.approved.txt diff --git a/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.RabbitMQ_PublicApi_matches_approved_snapshot.verified.txt b/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.RabbitMQ_PublicApi_matches_approved_snapshot.approved.txt similarity index 100% rename from src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.RabbitMQ_PublicApi_matches_approved_snapshot.verified.txt rename to src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.RabbitMQ_PublicApi_matches_approved_snapshot.approved.txt diff --git a/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.RavenDb_PublicApi_matches_approved_snapshot.verified.txt b/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.RavenDb_PublicApi_matches_approved_snapshot.approved.txt similarity index 100% rename from src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.RavenDb_PublicApi_matches_approved_snapshot.verified.txt rename to src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.RavenDb_PublicApi_matches_approved_snapshot.approved.txt diff --git a/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.SqlServer_PublicApi_matches_approved_snapshot.verified.txt b/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.SqlServer_PublicApi_matches_approved_snapshot.approved.txt similarity index 100% rename from src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.SqlServer_PublicApi_matches_approved_snapshot.verified.txt rename to src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.SqlServer_PublicApi_matches_approved_snapshot.approved.txt diff --git a/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.cs b/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.cs index eca727f..3a4aacc 100644 --- a/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.cs +++ b/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.cs @@ -1,5 +1,4 @@ using PublicApiGenerator; -using VerifyNUnit; namespace NServiceBus.IntegrationTesting.Tests; @@ -18,51 +17,51 @@ public class PublicApiTests }; [Test] - public Task PublicApi_matches_approved_snapshot() + public void PublicApi_matches_approved_snapshot() { var publicApi = typeof(TestEnvironment).Assembly.GeneratePublicApi(Options); - return Verifier.Verify(publicApi); + Approver.Verify(publicApi); } [Test] - public Task RabbitMQ_PublicApi_matches_approved_snapshot() + public void RabbitMQ_PublicApi_matches_approved_snapshot() { var publicApi = typeof(RabbitMqContainerOptions).Assembly.GeneratePublicApi(Options); - return Verifier.Verify(publicApi); + Approver.Verify(publicApi); } [Test] - public Task PostgreSql_PublicApi_matches_approved_snapshot() + public void PostgreSql_PublicApi_matches_approved_snapshot() { var publicApi = typeof(PostgreSqlContainerOptions).Assembly.GeneratePublicApi(Options); - return Verifier.Verify(publicApi); + Approver.Verify(publicApi); } [Test] - public Task MySql_PublicApi_matches_approved_snapshot() + public void MySql_PublicApi_matches_approved_snapshot() { var publicApi = typeof(MySqlContainerOptions).Assembly.GeneratePublicApi(Options); - return Verifier.Verify(publicApi); + Approver.Verify(publicApi); } [Test] - public Task MongoDb_PublicApi_matches_approved_snapshot() + public void MongoDb_PublicApi_matches_approved_snapshot() { var publicApi = typeof(MongoDbContainerOptions).Assembly.GeneratePublicApi(Options); - return Verifier.Verify(publicApi); + Approver.Verify(publicApi); } [Test] - public Task SqlServer_PublicApi_matches_approved_snapshot() + public void SqlServer_PublicApi_matches_approved_snapshot() { var publicApi = typeof(SqlServerContainerOptions).Assembly.GeneratePublicApi(Options); - return Verifier.Verify(publicApi); + Approver.Verify(publicApi); } [Test] - public Task RavenDb_PublicApi_matches_approved_snapshot() + public void RavenDb_PublicApi_matches_approved_snapshot() { var publicApi = typeof(RavenDbContainerOptions).Assembly.GeneratePublicApi(Options); - return Verifier.Verify(publicApi); + Approver.Verify(publicApi); } } From e942998022f345809ea66bcb32997cabcf89512b Mon Sep 17 00:00:00 2001 From: Mauro Servienti Date: Tue, 6 Oct 2026 10:35:14 +0200 Subject: [PATCH 2/2] Import NUnit explicitly, previously provided by Verify.NUnit's global using Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AixzAbo1zbJgxpHo7vyoSc --- src/NServiceBus.IntegrationTesting.Tests/Approver.cs | 1 + src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/NServiceBus.IntegrationTesting.Tests/Approver.cs b/src/NServiceBus.IntegrationTesting.Tests/Approver.cs index 7efeafe..e4d579a 100644 --- a/src/NServiceBus.IntegrationTesting.Tests/Approver.cs +++ b/src/NServiceBus.IntegrationTesting.Tests/Approver.cs @@ -1,4 +1,5 @@ using System.Runtime.CompilerServices; +using NUnit.Framework; namespace NServiceBus.IntegrationTesting.Tests; diff --git a/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.cs b/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.cs index 3a4aacc..bfe9962 100644 --- a/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.cs +++ b/src/NServiceBus.IntegrationTesting.Tests/PublicApiTests.cs @@ -1,3 +1,4 @@ +using NUnit.Framework; using PublicApiGenerator; namespace NServiceBus.IntegrationTesting.Tests;