private static IEnumerable <Script> ScanForScripts(MigrationInfo migrationInfo, string migrationFolder, IScriptScanner scanner) { var environments = (migrationInfo.TargetEnvironment ?? Enumerable.Empty <string>()).ToArray(); var scripts = (scanner.Scan(migrationInfo.ScriptFolder.Whack(migrationFolder), environments) ?? Enumerable.Empty <Script>()).ToArray(); Output.Text("Found {0} '{1}' scripts.".FormatWith(scripts.Length, migrationFolder)); foreach (var script in scripts) { Output.Verbose(script.Name, 1); } return(scripts); }
public void script_files_are_returned_in_reverse_alphabetical_order() { MockFilesystem.Setup(m => m.GetFiles(It.IsAny <string>(), It.IsAny <string>())) .Returns(new[] { "RB_03_c.sql", "RB_01_a.sql", "RB_26_z.sql", "RB_05_e.sql" }); var scriptFiles = Scanner.Scan(Some.Value("folder"), Some.Value("environment")).ToList(); var expectedOrder = new[] { "RB_26_z.sql", "RB_05_e.sql", "RB_03_c.sql", "RB_01_a.sql" }; Assert.That(scriptFiles.Count, Is.EqualTo(expectedOrder.Count())); for (int i = 0; i < scriptFiles.Count(); i++) { Assert.That(scriptFiles[i].Name, Is.EqualTo(expectedOrder[i])); } }
private static IEnumerable<Script> ScanForScripts(MigrationInfo migrationInfo, string migrationFolder, IScriptScanner scanner) { var environments = (migrationInfo.TargetEnvironment ?? Enumerable.Empty<string>()).ToArray(); var scripts = (scanner.Scan(migrationInfo.ScriptFolder.Whack(migrationFolder), environments) ?? Enumerable.Empty<Script>()).ToArray(); Output.Text("Found {0} '{1}' scripts.".FormatWith(scripts.Length, migrationFolder)); foreach (var script in scripts) { Output.Verbose(script.Name, 1); } return scripts; }