mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-23 22:25:09 -04:00
Fixed some tests.
This commit is contained in:
@@ -88,9 +88,31 @@ namespace NzbDrone.Core.Test.Framework
|
||||
protected virtual TestDatabase WithTestDb(Action<MigrationBase> beforeMigration)
|
||||
{
|
||||
var factory = Mocker.Resolve<DbFactory>();
|
||||
var database = factory.Create(MigrationType);
|
||||
var database = factory.Create(MigrationType, beforeMigration);
|
||||
Mocker.SetConstant(database);
|
||||
|
||||
switch (MigrationType)
|
||||
{
|
||||
case MigrationType.Main:
|
||||
{
|
||||
var mainDb = new MainDatabase(database);
|
||||
|
||||
Mocker.SetConstant<IMainDatabase>(mainDb);
|
||||
break;
|
||||
}
|
||||
case MigrationType.Log:
|
||||
{
|
||||
var logDb = new LogDatabase(database);
|
||||
|
||||
Mocker.SetConstant<ILogDatabase>(logDb);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw new ArgumentException("Invalid MigrationType");
|
||||
}
|
||||
}
|
||||
|
||||
var testDb = new TestDatabase(database);
|
||||
|
||||
return testDb;
|
||||
|
||||
@@ -11,20 +11,13 @@ namespace NzbDrone.Core.Test.Framework
|
||||
{
|
||||
protected override TestDatabase WithTestDb(Action<MigrationBase> beforeMigration)
|
||||
{
|
||||
var factory = Mocker.Resolve<DbFactory>();
|
||||
|
||||
var database = factory.Create(MigrationType, m =>
|
||||
return base.WithTestDb(m =>
|
||||
{
|
||||
if (m.GetType() == typeof(TMigration))
|
||||
{
|
||||
beforeMigration(m);
|
||||
}
|
||||
});
|
||||
|
||||
var testDb = new TestDatabase(database);
|
||||
Mocker.SetConstant(database);
|
||||
|
||||
return testDb;
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
|
||||
Reference in New Issue
Block a user