public void GetBatchComputeNodeExtensionODataTest() { string extensionName = "testExtension"; string publisher = "testPublisher"; string type = "testType"; // Setup cmdlet to get a compute node by id BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys(); cmdlet.BatchContext = context; cmdlet.PoolId = "testPool"; cmdlet.ComputeNodeId = "testComputeNode"; cmdlet.Name = extensionName; cmdlet.Select = "ExtensionName,Publisher"; VMExtension extension = new VMExtension(extensionName, publisher, type); // Fetch the OData clauses off the request. The OData clauses are applied after user provided RequestInterceptors, so a ResponseInterceptor is used. AzureOperationResponse <ProxyModels.NodeVMExtension, ProxyModels.ComputeNodeExtensionGetHeaders> getResponse = BatchTestHelpers.CreateComputeNodeExtensionGetResponse(extension); RequestInterceptor requestInterceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor < ProxyModels.ComputeNodeExtensionGetOptions, AzureOperationResponse <ProxyModels.NodeVMExtension, ProxyModels.ComputeNodeExtensionGetHeaders> >(getResponse); string requestSelect = null; ResponseInterceptor responseInterceptor = new ResponseInterceptor((response, request) => { ProxyModels.ComputeNodeExtensionGetOptions options = (ProxyModels.ComputeNodeExtensionGetOptions)request.Options; requestSelect = options.Select; return(Task.FromResult(response)); }); cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>() { requestInterceptor, responseInterceptor }; cmdlet.ExecuteCmdlet(); Assert.Equal(cmdlet.Select, requestSelect); }
public void GetBatchComputeNodeExtensionTest() { string extensionName = "testExtension"; string publisher = "testPublisher"; string type = "testType"; // Setup cmdlet to get a compute node by id BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys(); cmdlet.BatchContext = context; cmdlet.PoolId = "testPool"; cmdlet.ComputeNodeId = "testComputeNode"; cmdlet.Name = extensionName; VMExtension extension = new VMExtension(extensionName, publisher, type); // Build an extension instead of querying the service on a Get ComputeNodeExtension call AzureOperationResponse <ProxyModels.NodeVMExtension, ProxyModels.ComputeNodeExtensionGetHeaders> response = BatchTestHelpers.CreateComputeNodeExtensionGetResponse(extension); RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor < ProxyModels.ComputeNodeExtensionGetOptions, AzureOperationResponse <ProxyModels.NodeVMExtension, ProxyModels.ComputeNodeExtensionGetHeaders> >(response); cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>() { interceptor }; // Setup the cmdlet to write pipeline output to a list that can be examined later List <PSNodeVMExtension> pipeline = new List <PSNodeVMExtension>(); commandRuntimeMock.Setup(r => r.WriteObject(It.IsAny <PSNodeVMExtension>())).Callback <object>(c => pipeline.Add((PSNodeVMExtension)c)); cmdlet.ExecuteCmdlet(); // Verify that the cmdlet wrote the compute node returned from the OM to the pipeline Assert.Single(pipeline); PSVMExtension pipelineExtension = pipeline[0].VmExtension; Assert.NotNull(pipelineExtension); Assert.Equal("testExtension", pipelineExtension.Name); Assert.Equal("testPublisher", pipelineExtension.Publisher); Assert.Equal("testType", pipelineExtension.Type); }