public void RemoveBatchComputeNodeUserParametersTest() { // 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.PoolId = "testPool"; cmdlet.ComputeNodeId = "computeNode1"; cmdlet.Name = "testUser"; // Don't go to the service on a DeleteTVMUser call RequestInterceptor interceptor = new RequestInterceptor((baseRequest) => { BatchRequest<ComputeNodeDeleteUserParameters, ComputeNodeDeleteUserResponse> request = (BatchRequest<ComputeNodeDeleteUserParameters, ComputeNodeDeleteUserResponse>)baseRequest; request.ServiceRequestFunc = (cancellationToken) => { ComputeNodeDeleteUserResponse response = new ComputeNodeDeleteUserResponse(); Task<ComputeNodeDeleteUserResponse> task = Task.FromResult(response); return task; }; }); cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor }; // Verify no exceptions when required parameters are set cmdlet.ExecuteCmdlet(); }
public void RemoveBatchComputeNodeUserParametersTest() { // 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.PoolId = "testPool"; cmdlet.ComputeNodeId = "computeNode1"; cmdlet.Name = "testUser"; // Don't go to the service on a DeleteTVMUser call RequestInterceptor interceptor = new RequestInterceptor((baseRequest) => { BatchRequest <ComputeNodeDeleteUserParameters, ComputeNodeDeleteUserResponse> request = (BatchRequest <ComputeNodeDeleteUserParameters, ComputeNodeDeleteUserResponse>)baseRequest; request.ServiceRequestFunc = (cancellationToken) => { ComputeNodeDeleteUserResponse response = new ComputeNodeDeleteUserResponse(); Task <ComputeNodeDeleteUserResponse> task = Task.FromResult(response); return(task); }; }); cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>() { interceptor }; // Verify no exceptions when required parameters are set cmdlet.ExecuteCmdlet(); }