当前位置: 首页>>代码示例>>C#>>正文


C# Migrator.FetchMigrations方法代码示例

本文整理汇总了C#中Migrator.FetchMigrations方法的典型用法代码示例。如果您正苦于以下问题:C# Migrator.FetchMigrations方法的具体用法?C# Migrator.FetchMigrations怎么用?C# Migrator.FetchMigrations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Migrator的用法示例。


在下文中一共展示了Migrator.FetchMigrations方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VerifyPendingMigrationsAreFoundForSpecificModule

        public void VerifyPendingMigrationsAreFoundForSpecificModule()
        {
            IVersioning versioning = GetVersioning(false, false, false);

            Migrator migrator = new Migrator("", ProviderNames.SqlServer2008, new MigrationOptions { ModuleSelector = m => m == Migration2.Module });
            migrator.UseCustomVersioning(versioning);
            IMigrationBatch batch = migrator.FetchMigrations(typeof(Migration1).Assembly);

            Assert.AreEqual(1, batch.Count, string.Format(CultureInfo.CurrentCulture, "Only one migration for the module named '{0}' exists.", Migration2.Module));
        }
开发者ID:nachojammers,项目名称:MigSharp,代码行数:10,代码来源:MigratorTests.cs

示例2: VerifyPendingMigrationsAreFound

        public int VerifyPendingMigrationsAreFound(bool migration1IsContained, bool migration2IsContained, bool migration3IsContained)
        {
            IVersioning versioning = GetVersioning(migration1IsContained, migration2IsContained, migration3IsContained);

            Migrator migrator = new Migrator("", ProviderNames.SqlServer2008);
            migrator.UseCustomVersioning(versioning);
            IMigrationBatch batch = migrator.FetchMigrations(typeof(Migration1).Assembly);

            versioning.VerifyAllExpectations();
            return batch.Count;
        }
开发者ID:nachojammers,项目名称:MigSharp,代码行数:11,代码来源:MigratorTests.cs

示例3: MigratorUsesModuleSpecificTimestampProvider

        public void MigratorUsesModuleSpecificTimestampProvider()
        {
            var migrator = new Migrator("not-used", ProviderNames.SqlServer2005);
            var versioning = MockRepository.GenerateStub<IVersioning>();
            versioning.Expect(v => v.ExecutedMigrations).Return(Enumerable.Empty<IMigrationMetadata>()); // pretend, no migrations ran so far
            migrator.UseCustomVersioning(versioning);

            IMigrationBatch batch = migrator.FetchMigrations(_timestampModuleTestAssembly);

            Assert.AreEqual(4, batch.ScheduledMigrations.Count);

            IScheduledMigrationMetadata migration = batch.ScheduledMigrations.Single(m => m.ModuleName == MigrationExportAttribute.DefaultModuleName);
            Assert.AreEqual(1, migration.Timestamp);

            migration = batch.ScheduledMigrations.Single(m => m.ModuleName == "NonDefaultModuleTreatedWithDefaultTimestampProvider");
            Assert.AreEqual(23, migration.Timestamp);

            migration = batch.ScheduledMigrations.Single(m => m.ModuleName == "ModuleA");
            Assert.AreEqual(201110251455L, migration.Timestamp);

            migration = batch.ScheduledMigrations.Single(m => m.ModuleName == "ModuleB");
            Assert.AreEqual(201211171825L, migration.Timestamp);
        }
开发者ID:mediocreguy,项目名称:MigSharp,代码行数:23,代码来源:MigrationTimestampProviderTests.cs

示例4: TestCustomBootstrapping

        public void TestCustomBootstrapping()
        {
            // use a Module selection to verify that the bootstrapping is still considering *all* migrations
            _options.ModuleSelector = moduleName => moduleName == Migration2.Module;
            Migrator migrator = new Migrator(ConnectionString, ProviderName, _options);

            IBootstrapper bootstrapper = MockRepository.GenerateStrictMock<IBootstrapper>();
            bootstrapper.Expect(b => b.BeginBootstrapping(null, null)).IgnoreArguments();
            for (int i = 0; i < Migrations.Count; i++) // assume that all migrations were already performed
            {
                long timestamp = Timestamps[i];
                bootstrapper.Expect(b => b.IsContained(Arg<IMigrationMetadata>.Matches(m => m.Timestamp == timestamp))).Return(true);
            }
            bootstrapper.Expect(b => b.EndBootstrapping(null, null)).IgnoreArguments();
            migrator.UseCustomBootstrapping(bootstrapper);

            IMigrationBatch batch = migrator.FetchMigrations(typeof(Migration1).Assembly);
            CollectionAssert.IsEmpty(batch.ScheduledMigrations, "All migrations should be viewed as already run.");
            CollectionAssert.IsEmpty(batch.UnidentifiedMigrations, "There should be no unidentified migrations.");
            batch.Execute(); // should have no effect as no migrations are scheduled

            migrator.MigrateAll(typeof(Migration1).Assembly); // should have no effect as no migrations are scheduled

            // assert Migration1 table was *not* created
            DataTable table = GetTable(new Migration1().Tables[0].Name);
            Assert.IsNull(table);

            // assert Versioning table has necessary entries
            DataTable versioningTable = GetTable(_options.VersioningTableName);
            Assert.AreEqual(Migrations.Count, versioningTable.Rows.Count, "The versioning table is missing entries.");

            bootstrapper.VerifyAllExpectations();
        }
开发者ID:halad,项目名称:MigSharp,代码行数:33,代码来源:IntegrationTestsBase.cs

示例5: TestUnidentifiedMigrations

        public void TestUnidentifiedMigrations()
        {
            if (ProviderName == ProviderNames.Teradata || ProviderName == ProviderNames.TeradataOdbc ||
                ProviderName == ProviderNames.Oracle || ProviderName == ProviderNames.OracleOdbc) return; // for some reason, the ODBC data adapter updating does not work

            // migrate to 1 in order to create a versioning table
            var migrator = new Migrator(ConnectionString, ProviderName, _options);
            IMigrationBatch batch = migrator.FetchMigrationsTo(typeof(Migration1).Assembly, Timestamps[0]);
            Assert.AreEqual(0, batch.UnidentifiedMigrations.Count);
            batch.Execute();

            // insert unidentified migrations into the versioning table
            DataTable versioningTable = GetTable(_options.VersioningTableName);
            const long timestamp = 123456L;
            const string moduleName = "Test";
            const string tag = "This migration is not known to the application.";
            versioningTable.Rows.Add(timestamp, moduleName, tag);
            SaveTable(versioningTable);

            // verify if the UnidentifiedMigrations is populated correctly
            batch = migrator.FetchMigrations(typeof(Migration1).Assembly);
            Assert.AreEqual(1, batch.UnidentifiedMigrations.Count);
            Assert.AreEqual(timestamp, batch.UnidentifiedMigrations[0].Timestamp);
            Assert.AreEqual(moduleName, batch.UnidentifiedMigrations[0].ModuleName);
            Assert.AreEqual(tag, batch.UnidentifiedMigrations[0].Tag);
        }
开发者ID:halad,项目名称:MigSharp,代码行数:26,代码来源:IntegrationTestsBase.cs

示例6: TestOnlyFetchingMigrationsDoesNotCreateVersioningTable

        public void TestOnlyFetchingMigrationsDoesNotCreateVersioningTable()
        {
            _options.VersioningTableName = "My Versioning Table"; // test overriding the default versioning table name
            var migrator = new Migrator(ConnectionString, ProviderName, _options);
            IMigrationBatch batch = migrator.FetchMigrations(typeof(Migration1).Assembly);
            Assert.AreEqual(Timestamps.Count, batch.ScheduledMigrations.Count);

            DataTable versioningTable = GetTable(_options.VersioningTableName);
            Assert.IsNull(versioningTable, "Migrator.IsUpToDate should not have any side-effects. In particualar, it should *not* create a versioning table. This allows for being able to check the up-to-dateness of a db without having the privilege to create tables.");
        }
开发者ID:halad,项目名称:MigSharp,代码行数:10,代码来源:IntegrationTestsBase.cs

示例7: TestMigration1SucceededByAllOtherMigrations

        public void TestMigration1SucceededByAllOtherMigrations()
        {
            // execute Migration1
            var migrator = new Migrator(ConnectionString, ProviderName, _options);
            Assembly assemblyContainingMigrations = typeof(Migration1).Assembly;
            migrator.MigrateTo(assemblyContainingMigrations, Timestamps[0]);

            // execute all other migrations
            migrator = new Migrator(ConnectionString, ProviderName, _options);
            migrator.MigrateAll(assemblyContainingMigrations);

            // make sure there are no more migrations to run
            IMigrationBatch batch = migrator.FetchMigrations(assemblyContainingMigrations);
            Assert.AreEqual(0, batch.ScheduledMigrations.Count);

            VerifyResultsOfAllMigrations();
        }
开发者ID:halad,项目名称:MigSharp,代码行数:17,代码来源:IntegrationTestsBase.cs

示例8: MigratorUsesModuleSpecificTimestampProvider

        public void MigratorUsesModuleSpecificTimestampProvider()
        {
            var migrator = new Migrator("not-used", DbPlatform.SqlServer2005);
            var versioning = A.Fake<IVersioning>();
            A.CallTo(() => versioning.ExecutedMigrations).Returns(Enumerable.Empty<IMigrationMetadata>()); // pretend, no migrations ran so far
            migrator.UseCustomVersioning(versioning);

            IMigrationBatch batch = migrator.FetchMigrations(_timestampModuleTestAssembly);

            Assert.AreEqual(4, batch.Steps.Count);

            IMigrationStepMetadata step = batch.Steps.Single(m => m.ModuleName == MigrationExportAttribute.DefaultModuleName);
            Assert.AreEqual(1, step.Migrations.Single().Timestamp);

            step = batch.Steps.Single(m => m.ModuleName == "NonDefaultModuleTreatedWithDefaultTimestampProvider");
            Assert.AreEqual(23, step.Migrations.Single().Timestamp);

            step = batch.Steps.Single(m => m.ModuleName == "ModuleA");
            Assert.AreEqual(201110251455L, step.Migrations.Single().Timestamp);

            step = batch.Steps.Single(m => m.ModuleName == "ModuleB");
            Assert.AreEqual(201211171825L, step.Migrations.Single().Timestamp);
        }
开发者ID:dradovic,项目名称:MigSharp,代码行数:23,代码来源:MigrationTimestampProviderTests.cs


注:本文中的Migrator.FetchMigrations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。