1
0
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:
Keivan Beigi
2014-12-02 12:08:37 -08:00
committed by Mark McDowall
parent c7ed76f6d3
commit be81bf322a
5 changed files with 112 additions and 11 deletions
+17 -9
View File
@@ -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]