示例#1
0
        public Migrator(ITransformationProvider provider, bool trace, ILogger logger, params Assembly[] assemblies)
        {
            this.provider = provider;
            Logger = logger;

            migrationLoader = new MigrationLoader(provider, trace, assemblies);
            migrationLoader.CheckForDuplicatedVersion();
        }
        public void CanCompileAssemblies()
        {
            ScriptEngine engine = new ScriptEngine();

            // This should let it work on windows or mono/unix I hope
            string dataPath = Path.Combine("..", Path.Combine("..", @"src\ECM7.Migrator.Tests\Data"));

            Assembly asm = engine.Compile(dataPath);
            Assert.IsNotNull(asm);

            MigrationLoader loader = new MigrationLoader(null, false, asm);
            Assert.AreEqual(2, loader.LastVersion);

            Assert.AreEqual(2, MigrationLoader.GetMigrationInfoList(asm).Count);
        }
        private void SetUpCurrentVersion(int version, bool assertRollbackIsCalled)
        {
            DynamicMock providerMock = new DynamicMock(typeof(ITransformationProvider));

            providerMock.SetReturnValue("get_CurrentVersion", version);
            providerMock.SetReturnValue("get_Logger", new Logger(false));
            if (assertRollbackIsCalled)
                providerMock.Expect("Rollback");
            else
                providerMock.ExpectNoCall("Rollback");

            migrationLoader = new MigrationLoader((ITransformationProvider)providerMock.MockInstance, true);
            migrationLoader.MigrationsTypes.Add(new MigrationInfo(typeof(MigratorTest.FirstMigration)));
            migrationLoader.MigrationsTypes.Add(new MigrationInfo(typeof(MigratorTest.SecondMigration)));
            migrationLoader.MigrationsTypes.Add(new MigrationInfo(typeof(MigratorTest.ThirdMigration)));
            migrationLoader.MigrationsTypes.Add(new MigrationInfo(typeof(MigratorTest.ForthMigration)));
            migrationLoader.MigrationsTypes.Add(new MigrationInfo(typeof(MigratorTest.BadMigration)));
            migrationLoader.MigrationsTypes.Add(new MigrationInfo(typeof(MigratorTest.SixthMigration)));
            migrationLoader.MigrationsTypes.Add(new MigrationInfo(typeof(MigratorTest.NonIgnoredMigration)));
        }