internal PSCloudTask(Microsoft.Azure.Batch.CloudTask omObject) { if ((omObject == null)) { throw new System.ArgumentNullException("omObject"); } this.omObject = omObject; }
public void ADependencyOnMultipleTasksCanBeExpressedUsingAFactoryMethod_Literals() { var myTask = new Microsoft.Azure.Batch.CloudTask("mytask", "my.exe"); var yourTask = new Microsoft.Azure.Batch.CloudTask("yourtask", "your.exe"); var everybodysTask = new Microsoft.Azure.Batch.CloudTask("everybodystask", "everybodys.exe"); var taskDependencies = Microsoft.Azure.Batch.TaskDependencies.OnTasks(myTask, yourTask, everybodysTask); Assert.Equal(3, taskDependencies.TaskIds.Count); Assert.Equal(0, taskDependencies.TaskIdRanges.Count); Assert.Equal("mytask", taskDependencies.TaskIds[0]); Assert.Equal("yourtask", taskDependencies.TaskIds[1]); Assert.Equal("everybodystask", taskDependencies.TaskIds[2]); }
public async Task AddTaskCollectionNoHandlerThrows() { const string dummyJobId = "Dummy"; using BatchClient batchCli = ClientUnitTestCommon.CreateDummyClient(); //Clear the behaviors so that there is no way there is a AddTaskResultHandler defined batchCli.CustomBehaviors.Clear(); CloudTask task = new CloudTask("Foo", "Bar"); BatchClientException exception = await Assert.ThrowsAsync <BatchClientException>(() => batchCli.JobOperations.AddTaskAsync(dummyJobId, new List <CloudTask> { task })); string expectedString = string.Format(BatchErrorMessages.GeneralBehaviorMissing, typeof(AddTaskCollectionResultHandler)); Assert.Equal(expectedString, exception.Message); }
public void WhenAddingTasksWithDependenciesToAJob_TheDependenciesAreCorrectlyIncludedInTheRestProxy() { const string jobId = "id-123"; using (BatchClient client = ClientUnitTestCommon.CreateDummyClient()) { var returnFakeJob = ClientUnitTestCommon.SimulateServiceResponse <Models.JobGetOptions, AzureOperationResponse <Models.CloudJob, Models.JobGetHeaders> >(_ => new AzureOperationResponse <Models.CloudJob, Models.JobGetHeaders> { Body = new Protocol.Models.CloudJob { Id = jobId, UsesTaskDependencies = true } }); var verifyTaskDependencies = ClientUnitTestCommon.SimulateServiceResponse <Models.TaskAddParameter, Models.TaskAddOptions, AzureOperationHeaderResponse <Models.TaskAddHeaders> >((parameters, options) => { Assert.Equal((Int32.Parse(parameters.Id) - 10).ToString(), parameters.DependsOn.TaskIds.Single()); Assert.Equal(5, parameters.DependsOn.TaskIdRanges.Single().Start); Assert.Equal(15, parameters.DependsOn.TaskIdRanges.Single().End); return(new AzureOperationHeaderResponse <Models.TaskAddHeaders>() { Response = new HttpResponseMessage(HttpStatusCode.Accepted) }); }); var job = client.JobOperations.GetJob(jobId, additionalBehaviors: returnFakeJob); for (int j = 0; j < 5; j++) { var taskWithDependencies = new Microsoft.Azure.Batch.CloudTask((10 + j).ToString(), "cmd /c hostname") { DependsOn = new Microsoft.Azure.Batch.TaskDependencies(new[] { j.ToString() }, new[] { new Microsoft.Azure.Batch.TaskIdRange(5, 15) }), }; job.AddTask(taskWithDependencies, additionalBehaviors: verifyTaskDependencies); // assertions happen in the callback } } }
public PSCloudTask(string id, string commandline) { this.omObject = new Microsoft.Azure.Batch.CloudTask(id, commandline); }
internal AddTaskResult(CloudTask task, int retryCount, Protocol.Models.TaskAddResult addTaskResult) : this(addTaskResult) { this.task = task; this.retryCount = retryCount; }