Permalink
Browse files

Integration tests for autoreverse CreateConstraint

 - With and without schema
  • Loading branch information...
1 parent 09e4867 commit b3e0aa71f813dee7fd41c2338c9642b68b62d8d9 @daniellee daniellee committed Mar 10, 2013
Showing with 62 additions and 0 deletions.
  1. +62 −0 src/FluentMigrator.Tests/Integration/MigrationRunnerTests.cs
@@ -1058,6 +1058,52 @@ public void CanReverseCreateIndex()
}
[Test]
+ public void CanReverseCreateUniqueConstraint()
+ {
+ ExecuteWithSupportedProcessors(
+ processor =>
+ {
+ var runner = new MigrationRunner(Assembly.GetExecutingAssembly(), _runnerContext, processor);
+
+ runner.Up(new TestCreateAndDropTableMigration());
+
+ runner.Up(new TestCreateUniqueConstraintWithReversing());
+ processor.ConstraintExists(null, "TestTable2", "TestUnique").ShouldBeTrue();
+
+ runner.Down(new TestCreateUniqueConstraintWithReversing());
+ processor.ConstraintExists(null, "TestTable2", "TestUnique").ShouldBeFalse();
+
+ runner.Down(new TestCreateAndDropTableMigration());
+
+ }, true, new[] { typeof(SqliteProcessor) });
+ }
+
+ [Test]
+ public void CanReverseCreateUniqueConstraintWithSchema()
+ {
+ ExecuteWithSupportedProcessors(
+ processor =>
+ {
+ var runner = new MigrationRunner(Assembly.GetExecutingAssembly(), _runnerContext, processor);
+
+ runner.Up(new TestCreateSchema());
+
+ runner.Up(new TestCreateAndDropTableMigrationWithSchema());
+
+ runner.Up(new TestCreateUniqueConstraintWithSchemaWithReversing());
+ processor.ConstraintExists("TestSchema", "TestTable2", "TestUnique").ShouldBeTrue();
+
+ runner.Down(new TestCreateUniqueConstraintWithSchemaWithReversing());
+ processor.ConstraintExists("TestSchema", "TestTable2", "TestUnique").ShouldBeFalse();
+
+ runner.Down(new TestCreateAndDropTableMigrationWithSchema());
+
+ runner.Down(new TestCreateSchema());
+
+ }, true, new[] { typeof(SqliteProcessor) });
+ }
+
+ [Test]
public void CanExecuteSql()
{
ExecuteWithSupportedProcessors(
@@ -1500,6 +1546,22 @@ public override void Up()
}
}
+ internal class TestCreateUniqueConstraintWithReversing : AutoReversingMigration
+ {
+ public override void Up()
+ {
+ Create.UniqueConstraint("TestUnique").OnTable("TestTable2").Column("Name");
+ }
+ }
+
+ internal class TestCreateUniqueConstraintWithSchemaWithReversing : AutoReversingMigration
+ {
+ public override void Up()
+ {
+ Create.UniqueConstraint("TestUnique").OnTable("TestTable2").WithSchema("TestSchema").Column("Name");
+ }
+ }
+
internal class TestExecuteSql : Migration
{
public override void Up()

0 comments on commit b3e0aa7

Please sign in to comment.