• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MigrationConventions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MigrationConventions的典型用法代码示例。如果您正苦于以下问题:C# MigrationConventions类的具体用法?C# MigrationConventions怎么用?C# MigrationConventions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MigrationConventions类属于命名空间,在下文中一共展示了MigrationConventions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: DeleteVersionShouldExecuteDeleteDataExpression

        public void DeleteVersionShouldExecuteDeleteDataExpression()
        {
            var processor = new Mock<IMigrationProcessor>();
            var runner = new Mock<IMigrationRunner>();

            runner.SetupGet(r => r.Processor).Returns(processor.Object);

            var conventions = new MigrationConventions();
            var asm = Assembly.GetExecutingAssembly();
            var loader = new VersionLoader(runner.Object, asm, conventions);

            Func<IDataDefinition, bool> predicate =
                definition =>
                {
                    if (definition is ExplicitDataDefinition)
                    {
                        IDataValue kvp = ((ExplicitDataDefinition)definition).Data.First();

                        return kvp.ColumnName == loader.VersionTableMetaData.ColumnName && kvp.Value.Equals(1L);
                    }
                    else
                    {
                        return false;
                    }
                };

            processor.Setup(p => p.Process(It.Is<DeleteDataExpression>(expression =>
                                                                       expression.SchemaName == loader.VersionTableMetaData.SchemaName
                                                                       && expression.TableName == loader.VersionTableMetaData.TableName
                                                                       && expression.Rows.All(predicate)))).Verifiable();

            loader.DeleteVersion(1);

            processor.VerifyAll();
        }
开发者ID:ibebbs,项目名称:fluentmigrator,代码行数:35,代码来源:VersionLoaderTests.cs


示例2: DeleteVersionShouldExecuteDeleteDataExpression

        public void DeleteVersionShouldExecuteDeleteDataExpression()
        {
            var processor = new Mock<IMigrationProcessor>();
            var runner = new Mock<IMigrationRunner>();

            runner.SetupGet(r => r.Processor).Returns(processor.Object);

            var conventions = new MigrationConventions();
            var asm = Assembly.GetExecutingAssembly();
            var loader = new VersionLoader(runner.Object, asm, conventions);

            processor.Setup(p => p.Process(It.Is<DeleteDataExpression>(expression =>
                                                                       expression.SchemaName == loader.VersionTableMetaData.SchemaName
                                                                       && expression.TableName == loader.VersionTableMetaData.TableName
                                                                       && expression.Rows.All(
                                                                           definition =>
                                                                           definition.All(
                                                                               pair =>
                                                                               pair.Key == loader.VersionTableMetaData.ColumnName && pair.Value.Equals(1L))))))
                .Verifiable();

            loader.DeleteVersion(1);

            processor.VerifyAll();
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:25,代码来源:VersionLoaderTests.cs


示例3: MigrationRunner

        public MigrationRunner(IAssemblyCollection assemblies, IRunnerContext runnerContext, IMigrationProcessor processor)
        {
            _migrationAssemblies = assemblies;
            _announcer = runnerContext.Announcer;
            Processor = processor;
            _stopWatch = runnerContext.StopWatch;
            RunnerContext = runnerContext;

            SilentlyFail = false;
            CaughtExceptions = null;

            Conventions = new MigrationConventions();
            if (!string.IsNullOrEmpty(runnerContext.WorkingDirectory))
                Conventions.GetWorkingDirectory = () => runnerContext.WorkingDirectory;

            _migrationScopeHandler = new MigrationScopeHandler(Processor);
            _migrationValidator = new MigrationValidator(_announcer, Conventions);
            MigrationLoader = new DefaultMigrationInformationLoader(Conventions, _migrationAssemblies, runnerContext.Namespace, runnerContext.NestedNamespaces, runnerContext.Tags);
            ProfileLoader = new ProfileLoader(runnerContext, this, Conventions);
            MaintenanceLoader = new MaintenanceLoader(_migrationAssemblies, runnerContext.Tags, Conventions);

            if (runnerContext.NoConnection){
                VersionLoader = new ConnectionlessVersionLoader(this, _migrationAssemblies, Conventions, runnerContext.StartVersion, runnerContext.Version);
            }
            else{
                VersionLoader = new VersionLoader(this, _migrationAssemblies, Conventions);
            }
        }
开发者ID:eloekset,项目名称:fluentmigrator,代码行数:28,代码来源:MigrationRunner.cs


示例4: CanLoadDefaultVersionTableMetaData

 public void CanLoadDefaultVersionTableMetaData()
 {
     var conventions = new MigrationConventions();
     var loader = new MigrationLoader(conventions);
     var asm = Assembly.GetExecutingAssembly();
     IVersionTableMetaData versionTableMetaData = loader.GetVersionTableMetaData(asm);
     versionTableMetaData.ShouldBeOfType<TestVersionTableMetaData>();
 }
开发者ID:ngbrown,项目名称:fluentmigrator,代码行数:8,代码来源:MigrationLoaderTests.cs


示例5: DefaultBehaviorIsToNotLoadNestedNamespaces

        public void DefaultBehaviorIsToNotLoadNestedNamespaces()
        {
            var conventions = new MigrationConventions();
            var asm = Assembly.GetExecutingAssembly();
            var loader = new MigrationLoader(conventions, asm, "FluentMigrator.Tests.Integration.Migrations.Nested", null, new AppliedVersions());

            loader.LoadNestedNamespaces.ShouldBe(false);
        }
开发者ID:timosaikkonen,项目名称:fluentmigrator,代码行数:8,代码来源:MigrationLoaderTests.cs


示例6: CanLoadCustomVersionTableMetaData

 public void CanLoadCustomVersionTableMetaData()
 {
     var conventions = new MigrationConventions();
     var loader = new MigrationLoader(conventions);
     var asm = GetAssemblyWithCustomVersionTableMetaData();
     IVersionTableMetaData versionTableMetaData = loader.GetVersionTableMetaData(asm);
     Assert.AreEqual(TestVersionTableMetaData.TABLENAME,versionTableMetaData.TableName);
     Assert.AreEqual(TestVersionTableMetaData.COLUMNNAME, versionTableMetaData.ColumnName);
 }
开发者ID:ngbrown,项目名称:fluentmigrator,代码行数:9,代码来源:MigrationLoaderTests.cs


示例7: ShouldApplyIndexNameConventionWhenIndexNameIsNull

        public void ShouldApplyIndexNameConventionWhenIndexNameIsNull()
        {
            var indexDefinition = new IndexDefinition();
            var conventions = new MigrationConventions { GetIndexName = definition => "IX_Table_Name" };

            indexDefinition.ApplyConventions(conventions);

            Assert.AreEqual("IX_Table_Name", indexDefinition.Name);
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:9,代码来源:IndexDefinitionTests.cs


示例8: CanFindMigrationsInNamespace

 public void CanFindMigrationsInNamespace()
 {
     var conventions = new MigrationConventions();
     var loader = new MigrationLoader(conventions);
     var asm = Assembly.GetExecutingAssembly();
     var migrationList = loader.FindMigrationsIn(asm, "FluentMigrator.Tests.Integration.Migrations.Interleaved.Pass1");
     migrationList.Select(x => x.Type).ShouldNotContain(typeof(VersionedMigration));
     migrationList.Count().ShouldBeGreaterThan(0);
 }
开发者ID:ngbrown,项目名称:fluentmigrator,代码行数:9,代码来源:MigrationLoaderTests.cs


示例9: CanUseScriptsOnAnotherDriveToWorkingDirectory

 public void CanUseScriptsOnAnotherDriveToWorkingDirectory()
 {
     var scriptOnAnotherDrive = "z" + Path.VolumeSeparatorChar + Path.DirectorySeparatorChar + testSqlScript;
     var expression = new ExecuteSqlScriptExpression { SqlScript = scriptOnAnotherDrive };
     
     var conventions = new MigrationConventions { GetWorkingDirectory = () => "c" + Path.VolumeSeparatorChar + Path.DirectorySeparatorChar + "code" };
     expression.ApplyConventions(conventions);
     
     expression.SqlScript.ShouldBe(scriptOnAnotherDrive);
 }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:10,代码来源:ExecuteSqlScriptExpressionTests.cs


示例10: Initialize

        private void Initialize()
        {
            var migrationConventions = new MigrationConventions();
            if (!string.IsNullOrEmpty(RunnerContext.WorkingDirectory))
                migrationConventions.GetWorkingDirectory = () => RunnerContext.WorkingDirectory;

            Assembly assembly = AssemblyLoaderFactory.GetAssemblyLoader(RunnerContext.Target).Load();

            Runner = new MigrationVersionRunner(migrationConventions, RunnerContext.Processor, new MigrationLoader(migrationConventions), assembly, RunnerContext.Namespace);
        }
开发者ID:shawng,项目名称:fluentmigrator,代码行数:10,代码来源:TaskExecutor.cs


示例11: Initialize

        private void Initialize()
        {
            if (!Path.IsPathRooted(RunnerContext.Target))
                RunnerContext.Target = Path.GetFullPath(RunnerContext.Target);

            var migrationConventions = new MigrationConventions();
            if (!string.IsNullOrEmpty(RunnerContext.WorkingDirectory))
                migrationConventions.GetWorkingDirectory = () => RunnerContext.WorkingDirectory;

            Assembly assembly = Assembly.LoadFile(RunnerContext.Target);
            Runner = new MigrationVersionRunner(migrationConventions, RunnerContext.Processor, new MigrationLoader(migrationConventions), assembly, RunnerContext.Namespace);
        }
开发者ID:rtw,项目名称:fluentmigrator,代码行数:12,代码来源:TaskExecutor.cs


示例12: CanLoadCustomVersionTableMetaData

        public void CanLoadCustomVersionTableMetaData()
        {
            var runner = new Mock<IMigrationRunner>();
            runner.SetupGet(r => r.Processor.Options).Returns(new TestMigrationProcessorOptions());

            var conventions = new MigrationConventions();
            var asm = Assembly.GetExecutingAssembly();
            var loader = new VersionLoader(runner.Object, asm, conventions);

            var versionTableMetaData = loader.GetVersionTableMetaData();
            versionTableMetaData.ShouldBeOfType<TestVersionTableMetaData>();
        }
开发者ID:ryaneastabrook,项目名称:fluentmigrator,代码行数:12,代码来源:VersionLoaderTests.cs


示例13: CanLoadDefaultVersionTableMetaData

        public void CanLoadDefaultVersionTableMetaData()
        {
            var runner = new Mock<IMigrationRunner>();
            runner.SetupGet(r=>r.Processor.Options).Returns(new TestMigrationProcessorOptions());

            var conventions = new MigrationConventions();
            var asm = "s".GetType().Assembly;
            var loader = new VersionLoader(runner.Object, asm, conventions);

            var versionTableMetaData = loader.GetVersionTableMetaData();
            versionTableMetaData.ShouldBeOfType<DefaultVersionTableMetaData>();
        }
开发者ID:ryaneastabrook,项目名称:fluentmigrator,代码行数:12,代码来源:VersionLoaderTests.cs


示例14: CanRunMigration

        public void CanRunMigration()
        {
            ExecuteWithSupportedProcessors(processor =>
                {
                    var conventions = new MigrationConventions();

                    var runner = new MigrationRunner(conventions, processor);

                    runner.Up(new TestCreateAndDropTableMigration());
                    processor.TableExists("TestTable").ShouldBeTrue();

                    runner.Down(new TestCreateAndDropTableMigration());
                    processor.TableExists("TestTable").ShouldBeFalse();
                });
        }
开发者ID:rtw,项目名称:fluentmigrator,代码行数:15,代码来源:MigrationRunnerTests.cs


示例15: CanApplyIndexConvention

        public void CanApplyIndexConvention()
        {
            var connection = new SqlConnection(sqlServerConnectionString);
             connection.Open();
             var processor = new SqlServerProcessor(connection, new SqlServerGenerator());

             var conventions = new MigrationConventions();
             var runner = new MigrationRunner(conventions, processor);

             runner.Up(new TestIndexNamingConvention());
             processor.TableExists("Users").ShouldBeTrue();

             runner.Down(new TestIndexNamingConvention());
             processor.TableExists("Users").ShouldBeFalse();
        }
开发者ID:rtw,项目名称:fluentmigrator,代码行数:15,代码来源:MigrationRunnerTests.cs


示例16: CanApplyIndexConvention

        public void CanApplyIndexConvention()
        {
            ExecuteWithSupportedProcessors(
                processor =>
                {
                    var conventions = new MigrationConventions();
                    var runner = new MigrationRunner(conventions, processor);

                    runner.Up(new TestIndexNamingConvention());
                    processor.TableExists("Users").ShouldBeTrue();

                    runner.Down(new TestIndexNamingConvention());
                    processor.TableExists("Users").ShouldBeFalse();
                });
        }
开发者ID:ngbrown,项目名称:fluentmigrator,代码行数:15,代码来源:MigrationRunnerTests.cs


示例17: CanRunMigration

        public void CanRunMigration()
        {
            ExecuteWithSupportedProcessors(processor =>
                {
                    var conventions = new MigrationConventions();

                    var runner = new MigrationRunner(conventions, processor, new TextWriterAnnouncer(System.Console.Out), new StopWatch());

                    runner.Up(new TestCreateAndDropTableMigration());
                    processor.TableExists("TestTable").ShouldBeTrue();

                    runner.Down(new TestCreateAndDropTableMigration());
                    processor.TableExists("TestTable").ShouldBeFalse();
                });
        }
开发者ID:paulbatum,项目名称:fluentmigrator,代码行数:15,代码来源:MigrationRunnerTests.cs


示例18: CanApplyIndexConvention

        public void CanApplyIndexConvention()
        {
            ExecuteWithSupportedProcessors(
                processor =>
                {
                    var conventions = new MigrationConventions();
                    var runner = new MigrationRunner(conventions, processor, new TextWriterAnnouncer(System.Console.Out), new StopWatch());

                    runner.Up(new TestIndexNamingConvention());
                    processor.TableExists("Users").ShouldBeTrue();

                    runner.Down(new TestIndexNamingConvention());
                    processor.TableExists("Users").ShouldBeFalse();
                });
        }
开发者ID:paulbatum,项目名称:fluentmigrator,代码行数:15,代码来源:MigrationRunnerTests.cs


示例19: CanFindMigrationsInAssembly

        public void CanFindMigrationsInAssembly()
        {
            var conventions = new MigrationConventions();
            var loader = new MigrationLoader(conventions);
            var asm = Assembly.GetExecutingAssembly();
            IEnumerable<MigrationMetadata> migrationList = loader.FindMigrationsIn(asm, string.Empty);

            //if this works, there will be at least one migration class because i've included on in this code file
            var en = migrationList.GetEnumerator();
            int count = 0;
            while (en.MoveNext())
                count++;

            count.ShouldBeGreaterThan(0);
        }
开发者ID:ngbrown,项目名称:fluentmigrator,代码行数:15,代码来源:MigrationLoaderTests.cs


示例20: CanApplyForeignKeyConvention

        public void CanApplyForeignKeyConvention()
        {
            var connection = new SqlConnection(sqlServerConnectionString);
            connection.Open();
            var processor = new SqlServerProcessor(connection, new SqlServerGenerator());

             var conventions = new MigrationConventions();
             var runner = new MigrationRunner(conventions, processor);

             runner.Up(new TestForeignKeyNamingConvention());
             processor.TableExists("Users").ShouldBeTrue();
             processor.ConstraintExists( "Users", "FK_Users_GroupId_Groups_GroupId").ShouldBeTrue();

             runner.Down(new TestForeignKeyNamingConvention());
             processor.TableExists("Users").ShouldBeFalse();
        }
开发者ID:rtw,项目名称:fluentmigrator,代码行数:16,代码来源:MigrationRunnerTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Migrator类代码示例发布时间:2022-05-24
下一篇:
C# MigrationBuilder类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap