public CommandLineOperationBuilder(StepConfiguration step, string command) { _step = step; _task = new CommandLineTask(command); _step.AddOperation("command line task", opCfg => { opCfg.AddTask(_task); }); }
/// <summary> /// Creates a PowerShell object. /// </summary> protected override void ProcessRecord() { TaskBase t; switch (Type) { case TaskType.BatchFile: if (ForceBatchFileTaskType) { #pragma warning disable CS0618 // Type or member is obsolete t = new BatchFileTask(Path); #pragma warning restore CS0618 // Type or member is obsolete } else { t = new CommandLineTask(Path); } t.Arguments = Arguments; t.Name = Name; break; case TaskType.Executable: t = new ExecutableTask(Path); t.Arguments = Arguments; t.Name = Name; break; case TaskType.External: t = new ExternalTask(Name); t.Arguments = Arguments; break; case TaskType.PowerShell: t = new PowerShellTask(Path); t.Arguments = Arguments; t.Name = Name; break; case TaskType.TAEFDll: t = new TAEFTest(Path); t.Arguments = Arguments; t.Name = Name; break; case TaskType.UWP: t = new UWPTask(Path); t.Arguments = Arguments; t.Name = Name; break; default: throw new FactoryOrchestratorException(Resources.InvalidTaskRunTypeException); } this.WriteObject(t); }
private TaskBase CreateTestFromFlyout(TaskType testType) { activeTaskIsNowBg = false; if (activeTask == null) { activeTaskIndex = -1; switch (testType) { case TaskType.ConsoleExe: activeTask = new ExecutableTask(TaskPathBox.Text); break; case TaskType.UWP: activeTask = new UWPTask(AppComboBox.SelectedItem.ToString()); break; case TaskType.External: activeTask = new ExternalTask(TaskPathBox.Text); break; case TaskType.TAEFDll: activeTask = new TAEFTest(TaskPathBox.Text); break; case TaskType.BatchFile: if (supportsCommandLineTask) { activeTask = new CommandLineTask(TaskPathBox.Text); } else { #pragma warning disable CS0618 // Type or member is obsolete activeTask = new BatchFileTask(TaskPathBox.Text); #pragma warning restore CS0618 // Type or member is obsolete } break; case TaskType.PowerShell: activeTask = new PowerShellTask(TaskPathBox.Text); break; } } if (!String.IsNullOrWhiteSpace(TestNameBox.Text)) { activeTask.Name = TestNameBox.Text; } if (!string.IsNullOrWhiteSpace(TimeoutBox.Text)) { try { activeTask.TimeoutSeconds = Int32.Parse(TimeoutBox.Text, CultureInfo.CurrentCulture); } catch (Exception) { activeTask.TimeoutSeconds = -1; } } else { activeTask.TimeoutSeconds = -1; } if (!string.IsNullOrWhiteSpace(RetryBox.Text)) { try { activeTask.MaxNumberOfRetries = UInt32.Parse(RetryBox.Text, CultureInfo.CurrentCulture); } catch (Exception) { activeTask.MaxNumberOfRetries = 0; } } else { activeTask.MaxNumberOfRetries = 0; } switch (testType) { case TaskType.ConsoleExe: case TaskType.BatchFile: case TaskType.PowerShell: case TaskType.TAEFDll: case TaskType.External: var task = activeTask as TaskBase; task.Path = TaskPathBox.Text; task.Arguments = ArgumentsBox.Text; break; case TaskType.UWP: var uwpTask = activeTask as UWPTask; uwpTask.Path = AppComboBox.SelectedItem.ToString(); uwpTask.Arguments = ArgumentsBox.Text; uwpTask.AutoPassedIfLaunched = (bool)AutoPassCheck.IsChecked; uwpTask.TerminateOnCompleted = (bool)TerminateOnCompleteCheck.IsChecked; break; } switch (testType) { case TaskType.ConsoleExe: case TaskType.BatchFile: case TaskType.PowerShell: var task = activeTask as ExecutableTask; task.BackgroundTask = (bool)BgTaskBox.IsChecked; if (task.BackgroundTask) { activeTaskIsNowBg = true; } break; default: break; } activeTask.AbortTaskListOnFailed = (bool)AbortOnFailBox.IsChecked; activeTask.RunInContainer = (bool)ContainerBox.IsChecked; return(activeTask); }