public void GetScripts_when_given_set_name_should_return_SQL_scripts_in_seed_folder_first_then_set_script_sorted_by_name() { // arrange string path = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); using (DisposableDirectory.Create(path)) { _configManager.AppSettings[AppSettingKeys.SeedFolder] = path; // seed root scripts FileHelper.Touch(Path.Combine(path, "1_script_one.sql")); FileHelper.Touch(Path.Combine(path, "2_script_two.sql")); FileHelper.Touch(Path.Combine(path, "10_script_ten.sql")); // set scripts var setPath = Path.Combine(path, "myset"); Directory.CreateDirectory(setPath); FileHelper.Touch(Path.Combine(setPath, "1_set_one.sql")); FileHelper.Touch(Path.Combine(setPath, "2_set_two.sql")); FileHelper.Touch(Path.Combine(setPath, "10_set_ten.sql")); // act IEnumerable <string> files = _subject.GetScripts("myset"); // assert Assert.AreEqual("1_script_one", Path.GetFileNameWithoutExtension(files.First())); Assert.AreEqual("10_script_ten", Path.GetFileNameWithoutExtension(files.Skip(2).First())); Assert.AreEqual("1_set_one", Path.GetFileNameWithoutExtension(files.Skip(3).First())); Assert.AreEqual("10_set_ten", Path.GetFileNameWithoutExtension(files.Last())); } }
public void GetScripts_should_return_all_SQL_scripts_in_seed_folder() { // arrange string path = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); using (DisposableDirectory.Create(path)) { _configManager.AppSettings[AppSettingKeys.SeedFolder] = path; FileHelper.Touch(Path.Combine(path, "1_script_one.sql")); FileHelper.Touch(Path.Combine(path, "2_script_two.sql")); // act IEnumerable <string> files = _subject.GetScripts(null); // assert const int expectedCount = 2; Assert.AreEqual(expectedCount, files.Count()); } }