public void DefaultBehaviorIsToNotLoadNestedNamespaces() { var conventions = new MigrationConventions(); var asm = Assembly.GetExecutingAssembly(); var loader = new MigrationLoader(conventions, asm, "FluentMigrator.Tests.Integration.Migrations.Nested", null); loader.LoadNestedNamespaces.ShouldBe(false); }
public DbMigrator(MigratorOptions options) { var provider = ProviderFactory.Create(options.Provider, options.ConnectionString); _migrationLoader = new MigrationLoader(provider, options.MigrationTypes, false); _migrationLoader.CheckForDuplicatedVersion(); _provider = provider; Logger = new Logger(false, new ConsoleWriter()); _options = options; provider.Writer = _options.Commands; }
public void CanFindMigrationsInNamespace() { var conventions = new MigrationConventions(); var asm = Assembly.GetExecutingAssembly(); var loader = new MigrationLoader(conventions, asm, "FluentMigrator.Tests.Integration.Migrations.Interleaved.Pass1", null); var migrationList = loader.FindMigrations(); migrationList.Select(x => x.Type).ShouldNotContain(typeof(VersionedMigration)); migrationList.Count().ShouldBeGreaterThan(0); }
public InstallDatabase(string migrationsPath) { var migrationsDirectory = new DirectoryInfo(HostingEnvironment.MapPath(migrationsPath)); IList <Migration> migrations = new MigrationLoader() .GetDatabaseMigrations(migrationsDirectory); IInstallerLoggingService logging = new SitecoreInstallerLoggingService(); InstallationConnectionStringLocator locator = new SitecoreInstallationConnectionStringLocator(); _command = new DbInstallerCore(locator, migrations, logging); }
public void MigTest() { _migrator.MigrationsTypes.Clear(); var tp = typeof(Acc20160702154759); _migrator.MigrationsTypes.Add(tp); var ver = MigrationLoader.GetMigrationVersion(tp); //migrator.MigrateToLastVersion(); _migrator.MigrateTo(ver); Console.WriteLine(); Assert.IsTrue(1.Equals(1)); }
public void CanCompileAssemblies() { var engine = new ScriptEngine(); // This should let it work on windows or mono/unix I hope string dataPath = Path.Combine(Path.Combine("..", Path.Combine("src", "Migrator.Tests")), "Data"); Assembly asm = engine.Compile(dataPath); Assert.IsNotNull(asm); var loader = new MigrationLoader(null, asm, false, null); Assert.AreEqual(2, loader.LastVersion); Assert.AreEqual(2, loader.GetMigrationTypes(asm, null).Count); }
public void SetUp() { var providerMock = new Mock<TransformationProviderBase>(); providerMock.Setup(c => c.Logger).Returns(LogManager.GetCurrentClassLogger); _migrationLoader = new MigrationLoader(providerMock.Object, Assembly.GetExecutingAssembly()); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.FirstMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.SecondMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.ThirdMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.ForthMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.BadMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.SixthMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.NonIgnoredMigration)); }
public void DoesNotFindsMigrationsInNestedNamepsaceWhenLoadNestedNamespacesDisabled() { var conventions = new MigrationConventions(); var asm = Assembly.GetExecutingAssembly(); var loader = new MigrationLoader(conventions, asm, "FluentMigrator.Tests.Integration.Migrations.Nested", false); List <Type> expected = new List <Type> { typeof(Integration.Migrations.Nested.NotGrouped), }; var migrationList = loader.FindMigrations(); List <Type> actual = migrationList.Select(m => m.Type).ToList(); CollectionAssert.AreEquivalent(expected, actual); }
public void CanCompileAssemblies() { ScriptEngine engine = new ScriptEngine(); // This should let it work on windows or mono/unix I hope string dataPath = Path.Combine(Path.Combine("..", Path.Combine("src", "Migrator.Tests")), "Data"); Assembly asm = engine.Compile(dataPath); Assert.IsNotNull(asm); MigrationLoader loader = new MigrationLoader(null, asm, false); Assert.AreEqual(2, loader.LastVersion); Assert.AreEqual(2, MigrationLoader.GetMigrationTypes(asm).Count); }
/// <summary> /// List migrations. /// </summary> public void List() { CheckArguments(); Migrator mig = GetMigrator(); List <long> appliedMigrations = mig.AppliedMigrations; Console.WriteLine("Available migrations:"); foreach (Type t in mig.MigrationsTypes) { long v = MigrationLoader.GetMigrationVersion(t); Console.WriteLine("{0} {1} {2}", appliedMigrations.Contains(v) ? "=>" : " ", v.ToString().PadLeft(3), StringUtils.ToHumanName(t.Name) ); } }
public void CanFindMigrationsInAssembly() { var conventions = new MigrationConventions(); var asm = Assembly.GetExecutingAssembly(); var loader = new MigrationLoader(conventions, asm, "FluentMigrator.Tests.Integration.Migrations.Interleaved.Pass1", null); SortedList <long, IMigration> migrationList = loader.Migrations; //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); }
void SetUpCurrentVersion(int version, bool assertRollbackIsCalled) { var providerMock = new DynamicMock(typeof (ITransformationProvider)); providerMock.SetReturnValue("get_CurrentVersion", version); providerMock.SetReturnValue("get_Logger", new Logger(false)); if (assertRollbackIsCalled) providerMock.Expect("Rollback"); else providerMock.ExpectNoCall("Rollback"); _migrationLoader = new MigrationLoader((ITransformationProvider) providerMock.MockInstance, Assembly.GetExecutingAssembly(), true); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.FirstMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.SecondMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.ThirdMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.ForthMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.BadMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.SixthMigration)); _migrationLoader.MigrationsTypes.Add(typeof (MigratorTest.NonIgnoredMigration)); }
public void CanCompileAssemblies() { ScriptEngine engine = new ScriptEngine(); // This should let it work on windows or mono/unix I hope string dataPath = "Data"; var directory = new DirectoryInfo(dataPath); Assert.That(directory.Exists, Is.True, directory.FullName); Assembly asm = engine.Compile(dataPath); Assert.IsNotNull(asm); MigrationLoader loader = new MigrationLoader(null, asm, false); Assert.AreEqual(2, loader.LastVersion); Assert.AreEqual(2, MigrationLoader.GetMigrationTypes(asm).Count); }
private void SetUpCurrentVersion(int version, bool assertRollbackIsCalled) { var providerMock = Substitute.For <ITransformationProvider>(); providerMock.Logger.Returns(new Logger(false)); if (assertRollbackIsCalled) { providerMock.Received().Rollback(); } else { providerMock.DidNotReceive().Rollback(); } _migrationLoader = new MigrationLoader((ITransformationProvider)providerMock, Assembly.GetExecutingAssembly(), true); _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.FirstMigration)); _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.SecondMigration)); _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.ThirdMigration)); _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.ForthMigration)); _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.BadMigration)); _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.SixthMigration)); _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.NonIgnoredMigration)); }
public void DoesNotFindMigrationsThatDoNotHaveMatchingTags() { var asm = Assembly.GetExecutingAssembly(); var migrationType = typeof(TaggedMigraion); var tagsToMatch = new[] { "UK", "Production" }; var conventionsMock = new Mock <IMigrationConventions>(); conventionsMock.SetupGet(m => m.GetMetadataForMigration).Returns(DefaultMigrationConventions.GetMetadataForMigration); conventionsMock.SetupGet(m => m.TypeIsMigration).Returns(t => true); conventionsMock.SetupGet(m => m.TypeHasTags).Returns(t => migrationType == t); conventionsMock.SetupGet(m => m.TypeHasMatchingTags).Returns((type, tags) => false); var loader = new MigrationLoader(conventionsMock.Object, asm, migrationType.Namespace, tagsToMatch); var expected = new List <Type> { typeof(UntaggedMigration) }; var actual = loader.FindMigrations().Select(m => m.Type).ToList(); CollectionAssert.AreEquivalent(expected, actual); }
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); }
void SetUpCurrentVersion(int version, bool assertRollbackIsCalled) { var providerMock = new DynamicMock(typeof(ITransformationProvider)); providerMock.SetReturnValue("get_CurrentVersion", version); providerMock.SetReturnValue("get_Logger", new Logger(false)); if (assertRollbackIsCalled) { providerMock.Expect("Rollback"); } else { providerMock.ExpectNoCall("Rollback"); } _migrationLoader = new MigrationLoader((ITransformationProvider)providerMock.MockInstance, Assembly.GetExecutingAssembly(), true); _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.FirstMigration)); _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.SecondMigration)); _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.ThirdMigration)); _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.ForthMigration)); _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.BadMigration)); _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.SixthMigration)); _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.NonIgnoredMigration)); }
public override void Down() { _downCalled.Add(MigrationLoader.GetMigrationVersion(GetType())); }
public override void Up() { _upCalled.Add(MigrationLoader.GetMigrationVersion(GetType())); }