public void SetBatchJobParametersGetPassedToRequestTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;

            cmdlet.Job = new PSCloudJob(BatchTestHelpers.CreateFakeBoundJob(context, new CloudJob(id: "testJob")));

            // Update job
            cmdlet.Job.Constraints     = new PSJobConstraints(TimeSpan.FromHours(1), 5);
            cmdlet.Job.PoolInformation = new PSPoolInformation()
            {
                PoolId = "myPool"
            };
            cmdlet.Job.Priority = 2;
            cmdlet.Job.Metadata = new List <PSMetadataItem>()
            {
                new PSMetadataItem("meta1", "value1"),
                new PSMetadataItem("meta2", "value2")
            };

            JobUpdateParameter requestParameters = null;

            // Store the request parameters
            RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor <
                JobUpdateParameter,
                JobUpdateOptions,
                AzureOperationHeaderResponse <JobUpdateHeaders> >(requestAction: (r) =>
            {
                requestParameters = r.Parameters;
            });

            cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>()
            {
                interceptor
            };
            cmdlet.ExecuteCmdlet();

            // Verify the request parameters match the cmdlet parameters
            Assert.Equal(cmdlet.Job.Constraints.MaxTaskRetryCount, requestParameters.Constraints.MaxTaskRetryCount);
            Assert.Equal(cmdlet.Job.Constraints.MaxWallClockTime, requestParameters.Constraints.MaxWallClockTime);
            Assert.Equal(cmdlet.Job.PoolInformation.PoolId, requestParameters.PoolInfo.PoolId);
            Assert.Equal(cmdlet.Job.Priority, requestParameters.Priority);
            Assert.Equal(cmdlet.Job.Metadata.Count, requestParameters.Metadata.Count);
            Assert.Equal(cmdlet.Job.Metadata[0].Name, requestParameters.Metadata[0].Name);
            Assert.Equal(cmdlet.Job.Metadata[0].Value, requestParameters.Metadata[0].Value);
            Assert.Equal(cmdlet.Job.Metadata[1].Name, requestParameters.Metadata[1].Name);
            Assert.Equal(cmdlet.Job.Metadata[1].Value, requestParameters.Metadata[1].Value);
        }
Esempio n. 2
0
 /// <summary>
 /// Updates the properties of a job.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='jobId'>
 /// The id of the job whose properties you want to update.
 /// </param>
 /// <param name='jobUpdateParameter'>
 /// The parameters for the request.
 /// </param>
 /// <param name='jobUpdateOptions'>
 /// Additional parameters for the operation
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async System.Threading.Tasks.Task <JobUpdateHeaders> UpdateAsync(this IJobOperations operations, string jobId, JobUpdateParameter jobUpdateParameter, JobUpdateOptions jobUpdateOptions = default(JobUpdateOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     using (var _result = await operations.UpdateWithHttpMessagesAsync(jobId, jobUpdateParameter, jobUpdateOptions, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Headers);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Updates the properties of a job.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='jobId'>
 /// The id of the job whose properties you want to update.
 /// </param>
 /// <param name='jobUpdateParameter'>
 /// The parameters for the request.
 /// </param>
 /// <param name='jobUpdateOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static JobUpdateHeaders Update(this IJobOperations operations, string jobId, JobUpdateParameter jobUpdateParameter, JobUpdateOptions jobUpdateOptions = default(JobUpdateOptions))
 {
     return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IJobOperations)s).UpdateAsync(jobId, jobUpdateParameter, jobUpdateOptions), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Esempio n. 4
0
 /// <summary>
 /// Updates the properties of the specified Job.
 /// </summary>
 /// <remarks>
 /// This fully replaces all the updatable properties of the Job. For example,
 /// if the Job has constraints associated with it and if constraints is not
 /// specified with this request, then the Batch service will remove the
 /// existing constraints.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='jobId'>
 /// The ID of the Job whose properties you want to update.
 /// </param>
 /// <param name='jobUpdateParameter'>
 /// The parameters for the request.
 /// </param>
 /// <param name='jobUpdateOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static JobUpdateHeaders Update(this IJobOperations operations, string jobId, JobUpdateParameter jobUpdateParameter, JobUpdateOptions jobUpdateOptions = default(JobUpdateOptions))
 {
     return(operations.UpdateAsync(jobId, jobUpdateParameter, jobUpdateOptions).GetAwaiter().GetResult());
 }
Esempio n. 5
0
 public virtual Response Update(string jobId, JobUpdateParameter jobUpdateParameter, JobUpdateOptions jobUpdateOptions, CancellationToken cancellationToken = default)
 {
     return(RestClient.Update(jobId, jobUpdateParameter, jobUpdateOptions, cancellationToken).GetRawResponse());
 }
Esempio n. 6
0
 public virtual async Task <Response> UpdateAsync(string jobId, JobUpdateParameter jobUpdateParameter, JobUpdateOptions jobUpdateOptions, CancellationToken cancellationToken = default)
 {
     return((await RestClient.UpdateAsync(jobId, jobUpdateParameter, jobUpdateOptions, cancellationToken).ConfigureAwait(false)).GetRawResponse());
 }