/// <summary> /// Creates a test workitem for use in Scenario tests. /// </summary> public static void CreateTestWorkItem(BatchController controller, BatchAccountContext context, string workItemName, TimeSpan?recurrenceInterval) { YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor(); BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor }; BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); PSJobExecutionEnvironment jobExecutionEnvironment = new PSJobExecutionEnvironment(); jobExecutionEnvironment.PoolName = DefaultPoolName; PSWorkItemSchedule schedule = null; if (recurrenceInterval != null) { schedule = new PSWorkItemSchedule(); schedule.RecurrenceInterval = recurrenceInterval; } NewWorkItemParameters parameters = new NewWorkItemParameters(context, workItemName, behaviors) { JobExecutionEnvironment = jobExecutionEnvironment, Schedule = schedule }; client.CreateWorkItem(parameters); }
/// <summary> /// Creates a test workitem for use in Scenario tests. /// </summary> public static void CreateTestWorkItem(BatchController controller, BatchAccountContext context, string workItemName, TimeSpan? recurrenceInterval) { YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor(); BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor }; BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); PSJobExecutionEnvironment jobExecutionEnvironment = new PSJobExecutionEnvironment(); jobExecutionEnvironment.PoolName = DefaultPoolName; PSWorkItemSchedule schedule = null; if (recurrenceInterval != null) { schedule = new PSWorkItemSchedule(); schedule.RecurrenceInterval = recurrenceInterval; } NewWorkItemParameters parameters = new NewWorkItemParameters(context, workItemName, behaviors) { JobExecutionEnvironment = jobExecutionEnvironment, Schedule = schedule }; client.CreateWorkItem(parameters); }