mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-20 21:54:58 -04:00
Our first data migration test :D
This commit is contained in:
committed by
Mark McDowall
parent
c7ed76f6d3
commit
be81bf322a
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FluentMigrator;
|
||||
using FluentMigrator.Runner;
|
||||
using Marr.Data;
|
||||
using Moq;
|
||||
@@ -13,7 +14,6 @@ using NzbDrone.Core.Messaging.Events;
|
||||
|
||||
namespace NzbDrone.Core.Test.Framework
|
||||
{
|
||||
|
||||
public abstract class DbTest<TSubject, TModel> : DbTest
|
||||
where TSubject : class
|
||||
where TModel : ModelBase, new()
|
||||
@@ -85,7 +85,19 @@ namespace NzbDrone.Core.Test.Framework
|
||||
}
|
||||
}
|
||||
|
||||
private void WithTestDb()
|
||||
protected virtual TestDatabase WithTestDb(Action<MigrationBase> beforeMigration)
|
||||
{
|
||||
var factory = Mocker.Resolve<DbFactory>();
|
||||
var database = factory.Create(MigrationType);
|
||||
Mocker.SetConstant(database);
|
||||
|
||||
var testDb = new TestDatabase(database);
|
||||
|
||||
return testDb;
|
||||
}
|
||||
|
||||
|
||||
protected void SetupContainer()
|
||||
{
|
||||
WithTempAsAppPath();
|
||||
|
||||
@@ -94,17 +106,13 @@ namespace NzbDrone.Core.Test.Framework
|
||||
Mocker.SetConstant<IMigrationController>(Mocker.Resolve<MigrationController>());
|
||||
|
||||
MapRepository.Instance.EnableTraceLogging = true;
|
||||
|
||||
var factory = Mocker.Resolve<DbFactory>();
|
||||
var database = factory.Create(MigrationType);
|
||||
_db = new TestDatabase(database);
|
||||
Mocker.SetConstant(database);
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void SetupReadDb()
|
||||
public virtual void SetupDb()
|
||||
{
|
||||
WithTestDb();
|
||||
SetupContainer();
|
||||
_db = WithTestDb(null);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
||||
Reference in New Issue
Block a user