-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
131 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,13 @@ | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using ADatabaseFixture; | ||
using ADatabaseFixture.GalacticWasteManagement; | ||
using GalacticWasteManagement; | ||
using GalacticWasteManagement.Scripts; | ||
using GalacticWasteManagement.Scripts.EmbeddedScripts; | ||
using GalacticWasteManagement.Scripts.ScriptProviders; | ||
using ADatabaseFixture; | ||
using Microsoft.Data.SqlClient; | ||
using Xunit; | ||
|
||
namespace DataDude.Tests.Core | ||
{ | ||
public class DatabaseFixture : DatabaseFixtureBase, IAsyncLifetime | ||
public class DatabaseFixture() : DatabaseFixtureBase( | ||
new SqlServerDatabaseAdapter(ConnectionFactory), | ||
new FixtureMigrator()), IAsyncLifetime | ||
{ | ||
public DatabaseFixture() | ||
: base( | ||
new SqlServerDatabaseAdapter(), | ||
GalacticWasteManagementMigrator.Create(new DefaultProjectSettings())) | ||
{ | ||
} | ||
|
||
private class DefaultProjectSettings : ProjectSettings | ||
{ | ||
public DefaultProjectSettings() | ||
: base( | ||
new DefaultMigrationVersioning(), | ||
new GalacticWasteManagement.SqlServer.MsSql150ScriptParser(), | ||
new List<IScriptProvider> | ||
{ | ||
new BuiltInScriptsScriptProvider(), | ||
new EmbeddedScriptProvider(Assembly.GetAssembly(typeof(DatabaseFixture)), "Core.Scripts"), | ||
}) | ||
{ | ||
} | ||
} | ||
public static SqlConnection ConnectionFactory(string connectionString) => new(connectionString); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using ADatabaseMigrator.Hashing; | ||
using ADatabaseMigrator.Journaling; | ||
using ADatabaseMigrator.ScriptLoading.EmbeddedResources; | ||
using ADatabaseMigrator; | ||
using ADatabaseMigrator.ScriptLoading.EmbeddedResources.Versioning; | ||
using System.Data.Common; | ||
using Microsoft.Data.SqlClient; | ||
using System.Threading.Tasks; | ||
using System.Threading; | ||
using ADatabaseMigrator.SqlServer; | ||
|
||
namespace DataDude.Tests.Core | ||
{ | ||
public class FixtureMigrator : ADatabaseFixture.IMigrator | ||
{ | ||
public const string VersioningTable = MigrationScriptJournalManager.JournalTableName; | ||
|
||
public async Task MigrateUp(string connectionString, CancellationToken? cancellationToken) | ||
{ | ||
using var connection = new SqlConnection(connectionString); | ||
connection.Open(); | ||
await new Migrator( | ||
scriptLoader: new EmbeddedResourceScriptLoader(new MD5ScriptHasher(), config => config | ||
.UsingAssemblyFromType<FixtureMigrator>() | ||
.AddNamespaces<VersionFromPathVersionLoader>(MigrationScriptRunType.RunOnce, "Core.Scripts.Migrations")), | ||
journalManager: new MigrationScriptJournalManager(connection), | ||
scriptRunner: new SqlServerMigrationScriptRunner(connection)) | ||
.Migrate(cancellationToken); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.