public void GetScripts_TreatScriptNamePatternMismatchAsWarning_ReturnValidScriptsOnly() { // Arrange ScriptTaskHelper.CreateTestSettings(TempFolder, new Settings { PostScripts = new ScriptSettings { TreatScriptNamePatternMismatchAsError = false }, PreScripts = new ScriptSettings { TreatScriptNamePatternMismatchAsError = false }, ReferenceDataScripts = new ScriptSettings { TreatScriptNamePatternMismatchAsError = false } }); var preTask = ScriptTaskHelper.GetPreScriptTask(TempFolder); var postTask = ScriptTaskHelper.GetPostScriptTask(TempFolder); var refDataTask = ScriptTaskHelper.GetReferenceDataScriptTask(TempFolder); CreateSampleScripts(preTask.ScriptSettings.ScriptBaseDirectory, sampels.InvalidPrePostSamples); CreateSampleScripts(postTask.ScriptSettings.ScriptBaseDirectory, sampels.InvalidPrePostSamples); CreateSampleScripts(refDataTask.ScriptSettings.ScriptBaseDirectory, sampels.InvalidRefDataSamples); // Assert Assert.AreEqual(sampels.ValidPrePostSamplesRecursiveCount, preTask.GetScripts().Count()); Assert.AreEqual(sampels.ValidPrePostSamplesRecursiveCount, postTask.GetScripts().Count()); Assert.AreEqual(sampels.ValidRefDataSamplesRecursiveCount, refDataTask.GetScripts().Count()); }
public void GetScripts_ReferenceDataUsestDefaultSettings_ExpectAll() { // Arrange var task = ScriptTaskHelper.GetReferenceDataScriptTask(TempFolder); CreateSampleScripts(task.ScriptSettings.ScriptBaseDirectory, sampels.ValidRefDataSamples); // Act var scripts = task.GetScripts(); // Assert Assert.AreEqual(sampels.ValidRefDataSamplesRecursiveCount, scripts.Count()); }
public void GetScripts_TreatScriptNamePatternMismatchAsError_ThrowException() { // Arrange var preTask = ScriptTaskHelper.GetPreScriptTask(TempFolder); var postTask = ScriptTaskHelper.GetPreScriptTask(TempFolder); var refDataTask = ScriptTaskHelper.GetPreScriptTask(TempFolder); CreateSampleScripts(preTask.ScriptSettings.ScriptBaseDirectory, sampels.InvalidPrePostSamples); CreateSampleScripts(postTask.ScriptSettings.ScriptBaseDirectory, sampels.InvalidPrePostSamples); CreateSampleScripts(refDataTask.ScriptSettings.ScriptBaseDirectory, sampels.InvalidRefDataSamples); // Assert Assert.ThrowsException <FormatException>(() => preTask.GetScripts()); Assert.ThrowsException <FormatException>(() => postTask.GetScripts()); Assert.ThrowsException <FormatException>(() => refDataTask.GetScripts()); }
public void GetScripts_ByUnknownFilterMode_ThrowException() { // Arrange ScriptTaskHelper.CreateTestSettings(TempFolder, new Settings { PostScripts = new ScriptSettings { ExecutionFilterMode = "invalid", ExecutionFilterValue = "invalid" }, }); var postTask = ScriptTaskHelper.GetPostScriptTask(TempFolder); CreateSampleScripts(postTask.ScriptSettings.ScriptBaseDirectory, sampels.ValidPrePostSamples); // Assert Assert.ThrowsException <ArgumentException>(() => postTask.GetScripts()); }
[DataRow("20180132140010")] // invalid date public void GetScripts_ByDateWithInvalidFormat_ThrowFormatException(string fromDate) { // Arrange ScriptTaskHelper.CreateTestSettings(TempFolder, new Settings { PostScripts = new ScriptSettings { ExecutionFilterMode = "date", ExecutionFilterValue = fromDate, ScriptRecursiveSearch = true }, }); var postTask = ScriptTaskHelper.GetPostScriptTask(TempFolder); CreateSampleScripts(postTask.ScriptSettings.ScriptBaseDirectory, sampels.ValidPrePostSamples); // Assert Assert.ThrowsException <FormatException>(() => postTask.GetScripts()); }
public void GetScripts_NonRecursiveSetting_ExpectOnlyRootFolderScripts() { // Arrange ScriptTaskHelper.CreateTestSettings(TempFolder, new Settings { PostScripts = new ScriptSettings { ScriptRecursiveSearch = false } }); var task = ScriptTaskHelper.GetPostScriptTask(TempFolder); CreateSampleScripts(task.ScriptSettings.ScriptBaseDirectory, sampels.ValidPrePostSamples); // Act var scripts = task.GetScripts(); // Assert Assert.AreEqual(sampels.ValidPrePostSamplesRootCount, scripts.Count()); }
public void GetScripts_GlobalScriptNamePatternRecursive_ReturnAllScripts() { // Arrange ScriptTaskHelper.CreateTestSettings(TempFolder, new Settings { PostScripts = new ScriptSettings { ScriptNamePattern = "(.*)" }, // Global match pattern ReferenceDataScripts = new ScriptSettings { ScriptNamePattern = "(.*)" } // Global match pattern }); var postTask = ScriptTaskHelper.GetPostScriptTask(TempFolder); var refDataTask = ScriptTaskHelper.GetReferenceDataScriptTask(TempFolder); CreateSampleScripts(postTask.ScriptSettings.ScriptBaseDirectory, sampels.InvalidPrePostSamples); CreateSampleScripts(refDataTask.ScriptSettings.ScriptBaseDirectory, sampels.InvalidRefDataSamples); // Assert Assert.AreEqual(sampels.InvalidPrePostSamples.Count(), postTask.GetScripts().Count()); Assert.AreEqual(sampels.InvalidRefDataSamples.Count(), refDataTask.GetScripts().Count()); }
public void GetScripts_ByDaysNoneRecursive_ExpectScriptCountAndValidNewestScript(double days, int expectedScriptCount) { // Arrange ScriptTaskHelper.CreateTestSettings(TempFolder, new Settings { PostScripts = new ScriptSettings { ExecutionFilterMode = "days", ExecutionFilterValue = days.ToString(), ScriptRecursiveSearch = false }, }); var postTask = ScriptTaskHelper.GetPostScriptTask(TempFolder); CreateSampleScripts(postTask.ScriptSettings.ScriptBaseDirectory, sampels.ValidPrePostSamples); // Act var scripts = postTask.GetScripts(); // Assert Assert.AreEqual(expectedScriptCount, scripts.Count()); if (expectedScriptCount > 0) { Assert.AreEqual(sampels.ValidPrePostSamplesLatestRoot, scripts.Last().Name); } }