本文整理汇总了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;未经允许,请勿转载。 |
请发表评论