diff --git a/tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/SchemaComplianceFixture.cs b/tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/SchemaComplianceFixture.cs index 5e4c02b7..1ef229e8 100644 --- a/tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/SchemaComplianceFixture.cs +++ b/tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/SchemaComplianceFixture.cs @@ -73,23 +73,19 @@ public sealed class SchemaComplianceFixture : IDisposable return SqlTestDatabaseReaper.ReapOrphans(master, TestDatabasePrefix, DateTime.UtcNow - OrphanAge).Count; } - /// Disposes the fixture and drops the test database. + /// + /// Disposes the fixture and drops the test database — via the same parameterized + /// the reaper uses, so this file carries + /// exactly one drop-DDL shape. Best-effort like the AdminUI fixture's teardown: the name is + /// self-minted so a swallowed failure only leaks a database the startup reaper reclaims + /// within 24 h. + /// public void Dispose() { var masterConnection = new SqlConnectionStringBuilder(ConnectionString) { InitialCatalog = "master" }.ConnectionString; - using var conn = new SqlConnection(masterConnection); - conn.Open(); - - using var cmd = conn.CreateCommand(); - cmd.CommandText = $@" -IF DB_ID(N'{DatabaseName}') IS NOT NULL -BEGIN - ALTER DATABASE [{DatabaseName}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; - DROP DATABASE [{DatabaseName}]; -END"; - cmd.ExecuteNonQuery(); + SqlTestDatabaseReaper.TryDropDatabase(masterConnection, DatabaseName); } }