From 8c818fee994dbc2c943a5cdb0edb0e315eb6d490 Mon Sep 17 00:00:00 2001 From: Chebotov Nikolay Date: Tue, 31 Aug 2021 12:23:30 +0300 Subject: [PATCH] fix(StorageBaseTest): Fix dropping created databases --- .../MiniProfiler.Tests/Storage/SqlServerStorageTests.cs | 2 +- tests/MiniProfiler.Tests/Storage/StorageBaseTest.cs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/MiniProfiler.Tests/Storage/SqlServerStorageTests.cs b/tests/MiniProfiler.Tests/Storage/SqlServerStorageTests.cs index 4ca9a7fdb..42632d567 100644 --- a/tests/MiniProfiler.Tests/Storage/SqlServerStorageTests.cs +++ b/tests/MiniProfiler.Tests/Storage/SqlServerStorageTests.cs @@ -40,7 +40,7 @@ public void Dispose() { if (!ShouldSkip) { - Storage.DropSchema(); + Storage?.DropSchema(true); } } } diff --git a/tests/MiniProfiler.Tests/Storage/StorageBaseTest.cs b/tests/MiniProfiler.Tests/Storage/StorageBaseTest.cs index 350932304..3830c911d 100644 --- a/tests/MiniProfiler.Tests/Storage/StorageBaseTest.cs +++ b/tests/MiniProfiler.Tests/Storage/StorageBaseTest.cs @@ -225,15 +225,16 @@ public static void CreateSchema(this IAsyncStorage storage) /// Drops the tables for this storage provider. /// /// The storage to drop schema for. - public static void DropSchema(this IAsyncStorage storage) + /// Drop tables with schema name. + public static void DropSchema(this IAsyncStorage storage, bool withSchema = false) { if (storage is DatabaseStorageBase dbs && storage is IDatabaseStorageConnectable dbsc) { using (var conn = dbsc.GetConnection()) { - conn.Execute("Drop Table " + dbs.MiniProfilerClientTimingsTable); - conn.Execute("Drop Table " + dbs.MiniProfilerTimingsTable); - conn.Execute("Drop Table " + dbs.MiniProfilersTable); + conn.Execute($"Drop Table {(withSchema ? $"{dbs.SchemaName}" : string.Empty)}{dbs.MiniProfilerClientTimingsTable}"); + conn.Execute($"Drop Table {(withSchema ? $"{dbs.SchemaName}" : string.Empty)}{dbs.MiniProfilerTimingsTable}"); + conn.Execute($"Drop Table {(withSchema ? $"{dbs.SchemaName}" : string.Empty)}{dbs.MiniProfilersTable}"); } } }