public void Migrate_NoDiagnosticsAndThrows_Rollsback()
        {
            _steps[string.Empty][0].DatabaseMigration = _migration1;
            _steps[string.Empty][1].DatabaseMigration = _migration2;
            using (_mocks.Record())
            {
                Expect.Call(_transactionProvider.Begin()).Return(_transaction);
                _migration1.Up();
                _schemaStateManager.SetMigrationVersionApplied(1, null);
                _transaction.Commit();
                Expect.Call(_transactionProvider.Begin()).Return(_transaction);
                _migration2.Up();
                LastCall.Throw(new ArgumentException());
                _transaction.Rollback();
            }
            bool caught = false;

            try
            {
                _target.Migrate(_steps);
            }
            catch (ArgumentException)
            {
                caught = true;
            }
            Assert.IsTrue(caught);
            _mocks.VerifyAll();
        }
Пример #2
0
 public void Apply()
 {
     if (_reverting)
     {
         _databaseMigration.Down();
     }
     else
     {
         _databaseMigration.Up();
     }
 }