Re-configure current factory in NewSchemaPerFixture like in NewSchemaPerTest

This commit is contained in:
Mole
2020-10-02 14:35:24 +02:00
parent e4dd5abd3e
commit ca2ec63dd6

View File

@@ -370,24 +370,23 @@ namespace Umbraco.Tests.Integration.Testing
// Probably because the DB is blocked because it hasn't been detached // Probably because the DB is blocked because it hasn't been detached
// Also if we attach a new schema for every test isn't it just essentially // Also if we attach a new schema for every test isn't it just essentially
// the same as NewSchemaPerTest? // the same as NewSchemaPerTest?
if (db.HasSchema) if (!db.HasSchema)
{ {
// We must re-configure our current factory since attaching a new LocalDb from the pool changes connection strings // New DB + Schema
if (!databaseFactory.Configured) var newSchemaFixtureDbId = db.AttachSchema();
{
databaseFactory.Configure(db.ConnectionString, Constants.DatabaseProviders.SqlServer);
}
// re-run the runtime level check // Add teardown callback
runtimeState.DetermineRuntimeLevel(); OnFixtureTearDown(() => db.Detach(newSchemaFixtureDbId));
return;
} }
// New DB + Schema // We must re-configure our current factory since attaching a new LocalDb from the pool changes connection strings
var newSchemaFixtureDbId = db.AttachSchema(); if (!databaseFactory.Configured)
{
databaseFactory.Configure(db.ConnectionString, Constants.DatabaseProviders.SqlServer);
}
// Add teardown callback // re-run the runtime level check
OnFixtureTearDown(() => db.Detach(newSchemaFixtureDbId)); runtimeState.DetermineRuntimeLevel();
break; break;
case UmbracoTestOptions.Database.NewEmptyPerFixture: case UmbracoTestOptions.Database.NewEmptyPerFixture: