public void NewBatchVMUserParametersTest() { // Setup cmdlet without the required parameters BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys(); cmdlet.BatchContext = context; Assert.Throws <ArgumentNullException>(() => cmdlet.ExecuteCmdlet()); cmdlet.PoolName = "testPool"; cmdlet.VMName = "vm1"; cmdlet.Name = "testUser"; // Don't go to the service on an AddTVMUser call YieldInjectionInterceptor interceptor = new YieldInjectionInterceptor((opContext, request) => { if (request is AddTVMUserRequest) { AddTVMUserResponse response = new AddTVMUserResponse(); Task <object> task = Task <object> .Factory.StartNew(() => { return(response); }); return(task); } return(null); }); cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>() { interceptor }; // Verify no exceptions when required parameters are set cmdlet.ExecuteCmdlet(); }
public void NewBatchVMUserParametersTest() { // Setup cmdlet without the required parameters BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys(); cmdlet.BatchContext = context; Assert.Throws<ArgumentNullException>(() => cmdlet.ExecuteCmdlet()); cmdlet.PoolName = "testPool"; cmdlet.VMName = "vm1"; cmdlet.Name = "testUser"; // Don't go to the service on an AddTVMUser call YieldInjectionInterceptor interceptor = new YieldInjectionInterceptor((opContext, request) => { if (request is AddTVMUserRequest) { AddTVMUserResponse response = new AddTVMUserResponse(); Task<object> task = Task<object>.Factory.StartNew(() => { return response; }); return task; } return null; }); cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor }; // Verify no exceptions when required parameters are set cmdlet.ExecuteCmdlet(); }