本文整理汇总了C#中MigrationConventions类的典型用法代码示例。如果您正苦于以下问题:C# MigrationConventions类的具体用法?C# MigrationConventions怎么用?C# MigrationConventions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MigrationConventions类属于命名空间,在下文中一共展示了MigrationConventions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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();
}
示例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);
}
}
示例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>();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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>();
}
示例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>();
}
示例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();
});
}
示例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();
}