public void GetScriptsFromDefaultNamespace()
        {
            string GetNamespace(string fileName)
            => $"Kros.KORM.UnitTests.SqlScripts.{fileName}.sql";

            AssemblyMigrationScriptsProvider provider = CreateDefaultProvider();
            var scripts = provider.GetScripts().ToList();

            scripts.Should().Equals(new[] {
                new ScriptInfo(provider)
                {
                    Id   = 20190228001,
                    Name = "InitDatabase",
                    Path = GetNamespace("20190228001_InitDatabase")
                },
                new ScriptInfo(provider)
                {
                    Id   = 20190301001,
                    Name = "AddPeopleTable",
                    Path = GetNamespace("20190301001_AddPeopleTable")
                },
                new ScriptInfo(provider)
                {
                    Id   = 20190301002,
                    Name = "AddProjectTable",
                    Path = GetNamespace("20190301002_AddProjectTable")
                }
            });
        }
        public void GetScriptFromDefinedAsemblyAndNamespace()
        {
            string GetNamespace(string fileName)
            => $"Kros.KORM.UnitTests.Resources.AnotherSqlScripts.{fileName}.sql";

            var provider = new AssemblyMigrationScriptsProvider(
                Assembly.GetExecutingAssembly(),
                "Kros.KORM.UnitTests.Resources.AnotherSqlScripts");
            var scripts = provider.GetScripts().ToList();

            scripts.Should().Equals(new[]
            {
                new ScriptInfo(provider)
                {
                    Id   = 20190227001,
                    Name = "InitDatabase",
                    Path = GetNamespace("20190227001_InitDatabase")
                },
                new ScriptInfo(provider)
                {
                    Id   = 20190227002,
                    Name = "AddProjectTable",
                    Path = GetNamespace("20190227002_AddProjectTable")
                },
                new ScriptInfo(provider)
                {
                    Id   = 20190227003,
                    Name = "Script_with_separator",
                    Path = GetNamespace("20190227002_Script_with_separator")
                }
            });
        }
Beispiel #3
0
        private static MigrationOptions SetupMigrationOptions(Action <MigrationOptions> setupAction)
        {
            MigrationOptions options = new MigrationOptions();

            if (setupAction != null)
            {
                setupAction.Invoke(options);
            }
            else
            {
                options.AddScriptsProvider(AssemblyMigrationScriptsProvider.GetEntryAssemblyProvider());
            }

            return(options);
        }