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
@@ -0,0 +1,36 @@
using System;
using FluentMigrator;
using NUnit.Framework;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Test.Framework
{
[Category("DbMigrationTest")]
[Category("DbTest")]
public abstract class MigrationTest<TMigration> : DbTest where TMigration : MigrationBase
{
protected override TestDatabase WithTestDb(Action<MigrationBase> beforeMigration)
{
var factory = Mocker.Resolve<DbFactory>();
var database = factory.Create(MigrationType, m =>
{
if (m.GetType() == typeof(TMigration))
{
beforeMigration(m);
}
});
var testDb = new TestDatabase(database);
Mocker.SetConstant(database);
return testDb;
}
[SetUp]
public override void SetupDb()
{
SetupContainer();
}
}
}