public void NewBatchJobParametersTest() { // Setup cmdlet without the required parameters BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys(); cmdlet.BatchContext = context; Assert.Throws<ArgumentNullException>(() => cmdlet.ExecuteCmdlet()); cmdlet.Id = "testJob"; // Don't go to the service on an Add CloudJob call RequestInterceptor interceptor = new RequestInterceptor((baseRequest) => { BatchRequest<CloudJobAddParameters, CloudJobAddResponse> request = (BatchRequest<CloudJobAddParameters, CloudJobAddResponse>)baseRequest; request.ServiceRequestFunc = (cancellationToken) => { CloudJobAddResponse response = new CloudJobAddResponse(); Task<CloudJobAddResponse> task = Task.FromResult(response); return task; }; }); cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor }; // Verify no exceptions when required parameters are set cmdlet.ExecuteCmdlet(); }
public void NewBatchJobParametersTest() { // Setup cmdlet without the required parameters BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys(); cmdlet.BatchContext = context; Assert.Throws <ArgumentNullException>(() => cmdlet.ExecuteCmdlet()); cmdlet.Id = "testJob"; // Don't go to the service on an Add CloudJob call RequestInterceptor interceptor = new RequestInterceptor((baseRequest) => { BatchRequest <CloudJobAddParameters, CloudJobAddResponse> request = (BatchRequest <CloudJobAddParameters, CloudJobAddResponse>)baseRequest; request.ServiceRequestFunc = (cancellationToken) => { CloudJobAddResponse response = new CloudJobAddResponse(); Task <CloudJobAddResponse> task = Task.FromResult(response); return(task); }; }); cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>() { interceptor }; // Verify no exceptions when required parameters are set cmdlet.ExecuteCmdlet(); }