public void RemoveBatchJobScheduleParametersTest() { // Setup cmdlet without the required parameters BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys(); cmdlet.BatchContext = context; // Setup cmdlet to skip confirmation popup cmdlet.Force = true; commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny<string>(), It.IsAny<string>())).Returns(true); Assert.Throws<ArgumentNullException>(() => cmdlet.ExecuteCmdlet()); cmdlet.Id = "testJobSchedule"; // Don't go to the service on a Delete CloudJobSchedule call RequestInterceptor interceptor = new RequestInterceptor((baseRequest) => { BatchRequest<CloudJobScheduleDeleteParameters, CloudJobScheduleDeleteResponse> request = (BatchRequest<CloudJobScheduleDeleteParameters, CloudJobScheduleDeleteResponse>)baseRequest; request.ServiceRequestFunc = (cancellationToken) => { CloudJobScheduleDeleteResponse response = new CloudJobScheduleDeleteResponse(); Task<CloudJobScheduleDeleteResponse> task = Task.FromResult(response); return task; }; }); cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor }; // Verify no exceptions when required parameters are set cmdlet.ExecuteCmdlet(); }
public void RemoveBatchJobScheduleParametersTest() { // Setup cmdlet without the required parameters BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys(); cmdlet.BatchContext = context; // Setup cmdlet to skip confirmation popup cmdlet.Force = true; commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny <string>(), It.IsAny <string>())).Returns(true); Assert.Throws <ArgumentNullException>(() => cmdlet.ExecuteCmdlet()); cmdlet.Id = "testJobSchedule"; // Don't go to the service on a Delete CloudJobSchedule call RequestInterceptor interceptor = new RequestInterceptor((baseRequest) => { BatchRequest <CloudJobScheduleDeleteParameters, CloudJobScheduleDeleteResponse> request = (BatchRequest <CloudJobScheduleDeleteParameters, CloudJobScheduleDeleteResponse>)baseRequest; request.ServiceRequestFunc = (cancellationToken) => { CloudJobScheduleDeleteResponse response = new CloudJobScheduleDeleteResponse(); Task <CloudJobScheduleDeleteResponse> task = Task.FromResult(response); return(task); }; }); cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>() { interceptor }; // Verify no exceptions when required parameters are set cmdlet.ExecuteCmdlet(); }