/// <summary> /// Creates a test task for use in Scenario tests. /// </summary> public static void CreateTestTask(BatchController controller, BatchAccountContext context, string jobId, string taskId, string cmdLine = "cmd /c dir /s") { BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); NewTaskParameters parameters = new NewTaskParameters(context, jobId, null, taskId) { CommandLine = cmdLine, RunElevated = true }; client.CreateTask(parameters); }
/// <summary> /// Creates a test task for use in Scenario tests. /// </summary> public static void CreateTestTask(BatchController controller, BatchAccountContext context, string workItemName, string jobName, string taskName, string cmdLine = "cmd /c dir /s") { YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor(); BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor }; BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); NewTaskParameters parameters = new NewTaskParameters(context, workItemName, jobName, null, taskName, behaviors) { CommandLine = cmdLine, RunElevated = true }; client.CreateTask(parameters); }
/// <summary> /// Creates a test task for use in Scenario tests. /// </summary> public static void CreateTestTask(BatchController controller, BatchAccountContext context, string jobId, string taskId, string cmdLine = "cmd /c dir /s", int numInstances = 0) { BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); PSMultiInstanceSettings multiInstanceSettings = null; if (numInstances > 1) { multiInstanceSettings = new PSMultiInstanceSettings("cmd /c echo coordinating", numInstances); } NewTaskParameters parameters = new NewTaskParameters(context, jobId, null, taskId) { CommandLine = cmdLine, MultiInstanceSettings = multiInstanceSettings, UserIdentity = new PSUserIdentity(new PSAutoUserSpecification(AutoUserScope.Task, numInstances <= 1 ? ElevationLevel.Admin : ElevationLevel.NonAdmin)) }; client.CreateTask(parameters); }
/// <summary> /// Creates a test task for use in Scenario tests. /// </summary> public static void CreateTestTask(BatchController controller, BatchAccountContext context, string jobId, string taskId, string cmdLine = "cmd /c dir /s", int numInstances = 0) { BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); PSMultiInstanceSettings multiInstanceSettings = null; if (numInstances > 1) { multiInstanceSettings = new PSMultiInstanceSettings(numInstances); multiInstanceSettings.CoordinationCommandLine = "cmd /c echo coordinating"; } NewTaskParameters parameters = new NewTaskParameters(context, jobId, null, taskId) { CommandLine = cmdLine, MultiInstanceSettings = multiInstanceSettings, RunElevated = numInstances <= 1 }; client.CreateTask(parameters); }
/// <summary> /// Creates a test task for use in Scenario tests. /// </summary> public static void CreateTestTask(BatchController controller, BatchAccountContext context, string jobId, string taskId, string cmdLine = "cmd /c dir /s") { RequestInterceptor interceptor = CreateHttpRecordingInterceptor(); BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor }; BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); NewTaskParameters parameters = new NewTaskParameters(context, jobId, null, taskId, behaviors) { CommandLine = cmdLine, RunElevated = true }; client.CreateTask(parameters); }