public void RemoveVersionTableShouldBehaveAsExpected() { var runnerContext = new Mock <IRunnerContext>(); var processor = new Mock <IMigrationProcessor>(); var runner = new Mock <IMigrationRunner>(); runner.SetupGet(r => r.Processor).Returns(processor.Object); runner.SetupGet(r => r.RunnerContext).Returns(runnerContext.Object); var conventions = new MigrationRunnerConventions(); var asm = Assembly.GetExecutingAssembly(); var loader = new VersionLoader(runner.Object, asm, ConventionSets.NoSchemaName, conventions, runnerContext.Object); processor.Setup(p => p.Process(It.Is <DeleteTableExpression>(expression => expression.SchemaName == loader.VersionTableMetaData.SchemaName && expression.TableName == loader.VersionTableMetaData.TableName))) .Verifiable(); processor.Setup(p => p.Process(It.Is <DeleteSchemaExpression>(expression => expression.SchemaName == loader.VersionTableMetaData.SchemaName))) .Verifiable(); loader.RemoveVersionTable(); processor.VerifyAll(); }
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(); }
public async Task <MVersionCollection> GetAllVersionsAsync() { Versions = await VersionLoader.GetVersionMetadatasAsync() .ConfigureAwait(false); return(Versions); }
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(); }
public void UpdateVersionShouldExecuteInsertDataExpression() { var runnerContext = new Mock <IRunnerContext>(); var processor = new Mock <IMigrationProcessor>(); var runner = new Mock <IMigrationRunner>(); runner.SetupGet(r => r.Processor).Returns(processor.Object); runner.SetupGet(r => r.RunnerContext).Returns(runnerContext.Object); var conventions = new MigrationRunnerConventions(); var asm = Assembly.GetExecutingAssembly(); var loader = new VersionLoader(runner.Object, asm, ConventionSets.NoSchemaName, conventions, runnerContext.Object); processor.Setup(p => p.Process(It.Is <InsertDataExpression>(expression => expression.SchemaName == loader.VersionTableMetaData.SchemaName && expression.TableName == loader.VersionTableMetaData.TableName && expression.Rows.Any( definition => definition.Any( pair => pair.Key == loader.VersionTableMetaData.ColumnName && pair.Value.Equals(1L)))))) .Verifiable(); loader.UpdateVersionInfo(1); processor.VerifyAll(); }
void OnLocalVersionLoadFinish(VersionLoader loader) { localVersionLoader.OnLoadFinishHandler -= OnLocalVersionLoadFinish; bool same = localVersionLoader.version.Equals(serverVersionLoader.version); if (OnCheckVersionFinish != null) { OnCheckVersionFinish(same); } }
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>(); }
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>(); }
public void CanLoadDefaultVersionTableMetaData() { var runnerContext = new Mock <IRunnerContext>(); var runner = new Mock <IMigrationRunner>(); runner.SetupGet(r => r.Processor.Options).Returns(new ProcessorOptions()); runner.SetupGet(r => r.RunnerContext).Returns(runnerContext.Object); var conventions = new MigrationRunnerConventions(); var asm = "s".GetType().Assembly; var loader = new VersionLoader(runner.Object, asm, ConventionSets.NoSchemaName, conventions, runnerContext.Object); var versionTableMetaData = loader.GetVersionTableMetaData(); versionTableMetaData.ShouldBeOfType <DefaultVersionTableMetaData>(); }
public void VersionSchemaMigrationOnlyRunOnceEvenIfExistenceChecksReturnFalse() { var conventions = new MigrationConventions(); var processor = new Mock <IMigrationProcessor>(); var runner = new Mock <IMigrationRunner>(); var asm = Assembly.GetExecutingAssembly(); runner.SetupGet(r => r.Processor).Returns(processor.Object); processor.Setup(p => p.SchemaExists(It.IsAny <string>())).Returns(false); var loader = new VersionLoader(runner.Object, asm, conventions); loader.LoadVersionInfo(); runner.Verify(r => r.Up(loader.VersionSchemaMigration), Times.Once()); }
public void VersionDescriptionMigrationOnlyRunOnceEvenIfExistenceChecksReturnFalse() { var conventions = new MigrationConventions(); var processor = new Mock <IMigrationProcessor>(); var runner = new Mock <IMigrationRunner>(); var asm = Assembly.GetExecutingAssembly(); runner.SetupGet(r => r.Processor).Returns(processor.Object); processor.Setup(p => p.ColumnExists(new TestVersionTableMetaData().SchemaName, TestVersionTableMetaData.TABLENAME, "AppliedOn")).Returns(false); var loader = new VersionLoader(runner.Object, asm, conventions); loader.LoadVersionInfo(); runner.Verify(r => r.Up(loader.VersionDescriptionMigration), Times.Once()); }
public void VersionUniqueMigrationOnlyRunOnceEvenIfExistenceChecksReturnFalse() { var runnerContext = new Mock <IRunnerContext>(); var conventions = new MigrationRunnerConventions(); var processor = new Mock <IMigrationProcessor>(); var runner = new Mock <IMigrationRunner>(); var asm = Assembly.GetExecutingAssembly(); runner.SetupGet(r => r.Processor).Returns(processor.Object); runner.SetupGet(r => r.RunnerContext).Returns(runnerContext.Object); processor.Setup(p => p.ColumnExists(new TestVersionTableMetaData().SchemaName, TestVersionTableMetaData.TABLE_NAME, TestVersionTableMetaData.APPLIED_ON_COLUMN_NAME)).Returns(false); var loader = new VersionLoader(runner.Object, asm, ConventionSets.NoSchemaName, conventions, runnerContext.Object); loader.LoadVersionInfo(); runner.Verify(r => r.Up(loader.VersionUniqueMigration), Times.Once()); }
public void CanSetupApplicationContext() { var applicationContext = "Test context"; var runnerContext = new Mock <IRunnerContext>(); runnerContext.SetupGet(r => r.ApplicationContext).Returns(applicationContext); var runner = new Mock <IMigrationRunner>(); runner.SetupGet(r => r.Processor.Options).Returns(new ProcessorOptions()); runner.SetupGet(r => r.RunnerContext).Returns(runnerContext.Object); var conventions = new MigrationRunnerConventions(); var asm = Assembly.GetExecutingAssembly(); var loader = new VersionLoader(runner.Object, asm, ConventionSets.NoSchemaName, conventions, runnerContext.Object); var versionTableMetaData = loader.GetVersionTableMetaData(); versionTableMetaData.ApplicationContext.ShouldBe(applicationContext); }
public void RemoveVersionTableShouldNotRemoveSchemaIfItDidNotOwnTheSchema() { 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); ((TestVersionTableMetaData)loader.VersionTableMetaData).OwnsSchema = false; processor.Setup(p => p.Process(It.Is <DeleteTableExpression>(expression => expression.SchemaName == loader.VersionTableMetaData.SchemaName && expression.TableName == loader.VersionTableMetaData.TableName))) .Verifiable(); loader.RemoveVersionTable(); processor.Verify(p => p.Process(It.IsAny <DeleteSchemaExpression>()), Times.Never()); }
public new void MigrateUp(long targetVersion, bool useAutomaticTransactionManagement) { VersionLoader.LoadVersionInfo(); var validationVersionLoader = VersionLoader as ValidatingVersionLoader; if (validationVersionLoader == null) { throw new ArgumentException( string.Format("Class of type {0} is required, {1} given", typeof(ValidatingVersionLoader).FullName, VersionLoader.GetType().FullName ) ); } var storedMigrationInfos = validationVersionLoader.StoredMigrationInfos; var availableMigrations = MigrationLoader.LoadMigrations().ToList().ToDictionary(x => x.Key, x => x.Value); FilterAndValidateMigrations(storedMigrationInfos, availableMigrations); ValidateEnvironmentAttributeUsage(availableMigrations); base.MigrateUp(targetVersion, useAutomaticTransactionManagement); }
public void CheskForNotAppliedMigrations() { this.Initialize(); try { var versionLoader = new VersionLoader(this.Runner, this.Runner.MigrationAssemblies, ((MigrationRunner)this.Runner).Conventions); versionLoader.LoadVersionInfo(); var migrationsToRun = (from m in this.Runner.MigrationLoader.LoadMigrations() where !versionLoader.VersionInfo.HasAppliedMigration(m.Key) select m).ToList(); if (migrationsToRun.Any()) { var text = $"Необходимо выполнить миграции:{Environment.NewLine}"; text = migrationsToRun.Aggregate(text, (current, keyValuePair) => current + $"{keyValuePair.Value.GetName()}{Environment.NewLine}"); throw new Exception(text); } } finally { this.Runner.Processor.Dispose(); } }
void OnServerVersionLoadFinish(VersionLoader loader) { serverVersionLoader.OnLoadFinishHandler -= OnServerVersionLoadFinish; StartLocalVersionLoad(); }
void OnServerVersionLoadFinish(VersionLoader loader) { serverVersionLoader.OnLoadFinishHandler -= OnServerVersionLoadFinish; StartDownloadBunle(); }
void OnServerVersionLoadFinish(VersionLoader loader) { serverVersionLoader.OnLoadFinishHandler -= OnServerVersionLoadFinish; StartLocalVersionLoad (); }
void OnServerVersionLoadFinish(VersionLoader loader) { serverVersionLoader.OnLoadFinishHandler -= OnServerVersionLoadFinish; StartDownloadBunle (); }
public MVersionCollection GetAllVersions() { Versions = VersionLoader.GetVersionMetadatas(); return(Versions); }