public void ScriptProviderHelper_GetFolder_ShouldReturnOriginalFolder_IfTheFolderIsAFullyQualifiedPath()
        {
            var current = Directory.GetCurrentDirectory();
            var path    = ScriptProviderHelper.GetFolder(current, "d:\\upgrades");

            path.Should().Be("d:\\upgrades");
        }
        public void ScriptProviderHelper_GetFolder_ShouldReturnFullyQualifiedFolder_IfTheFolderIsARelativePath()
        {
            var current = Directory.GetCurrentDirectory();
            var path    = ScriptProviderHelper.GetFolder(current, "upgrades");

            path.Should().Be($"{current}\\upgrades");
        }
        public void ScriptProviderHelper_GetFolder_ShouldReturnCurrentFolder_IfTheFolderIsNullOrWhiteSpace()
        {
            var current = Directory.GetCurrentDirectory();
            var path    = ScriptProviderHelper.GetFolder(current, null);

            path.Should().Be(current);
        }
        public void ScriptProviderHelper_SelectJournal_ShouldAddAllTheScripts()
        {
            var scripts = new List <ScriptBatch>()
            {
                new ScriptBatch(ScriptProviderHelper.GetFolder(GetBasePath(), "SubFolder1"), false, false, 0, Constants.Default.Encoding),
                new ScriptBatch(ScriptProviderHelper.GetFolder(GetBasePath(), "SubFolder2"), false, false, 0, Constants.Default.Encoding),
            };

            var upgradeEngineBuilder = DeployChanges.To
                                       .SqlDatabase("testconn")
                                       .OverrideConnectionFactory(testConnectionFactory)
                                       .LogTo(Logger).Some <UpgradeEngineBuilder, Error>()
                                       .SelectScripts(scripts, NamingOptions.Default);

            upgradeEngineBuilder.MatchSome(x =>
            {
                x.Build().PerformUpgrade();
            });

            var excutedScripts = Logger.GetExecutedScripts();

            excutedScripts.Should().HaveCount(3);
            excutedScripts[0].Should().Be("003.sql");
            excutedScripts[1].Should().Be("004.sql");
            excutedScripts[2].Should().Be("005.sql");
        }
        public void ScriptProviderHelper_GetFolder_ShouldThrowAnException_IfTheBaseFolderIsNullOrWhiteSpace()
        {
            Action nullAction       = () => ScriptProviderHelper.GetFolder(null, null);
            Action whitespaceAction = () => ScriptProviderHelper.GetFolder("   ", null);

            nullAction.Should().Throw <ArgumentException>();
            whitespaceAction.Should().Throw <ArgumentException>();
        }
예제 #6
0
        public void ScriptNamingScheme_With_UseOnlyFileName_Set_ShoudUseValidScriptName()
        {
            var scripts = new List <ScriptBatch>()
            {
                new ScriptBatch(ScriptProviderHelper.GetFolder(GetBasePath(), "Naming"), false, true, 0, Constants.Default.Encoding)
            };

            var namingOptions = new NamingOptions(useOnlyFileName: true, false, null);

            var upgradeEngineBuilder = DeployChanges.To
                                       .SqlDatabase("testconn")
                                       .OverrideConnectionFactory(testConnectionFactory)
                                       .LogTo(Logger).Some <UpgradeEngineBuilder, Error>()
                                       .SelectScripts(scripts, namingOptions);

            upgradeEngineBuilder.MatchSome(x =>
            {
                x.Build().PerformUpgrade();
            });

            var executedScripts = Logger.GetExecutedScripts();

            executedScripts[0].Should().Be("001.sql");
        }