public void RemoveComputeNodeRequestTest()
        {
            // Setup cmdlet to skip confirmation popup
            cmdlet.Force = true;
            commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny <string>(), It.IsAny <string>())).Returns(true);

            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;

            cmdlet.PoolId             = "testPool";
            cmdlet.Ids                = new string[] { "computeNode1", "computeNode2" };
            cmdlet.DeallocationOption = ComputeNodeDeallocationOption.Terminate;
            cmdlet.ResizeTimeout      = TimeSpan.FromMinutes(8);

            ComputeNodeDeallocationOption?requestDeallocationOption = null;
            TimeSpan?      requestResizeTimeout  = null;
            IList <string> requestComputeNodeIds = null;

            // Don't go to the service on a Remove ComputeNode call
            RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
            {
                BatchRequest <ComputeNodeRemoveParameters, ComputeNodeRemoveResponse> request =
                    (BatchRequest <ComputeNodeRemoveParameters, ComputeNodeRemoveResponse>)baseRequest;

                request.ServiceRequestFunc = (cancellationToken) =>
                {
                    // Grab the parameters from the outgoing request.
                    requestDeallocationOption = request.TypedParameters.ComputeNodeDeallocationOption;
                    requestResizeTimeout      = request.TypedParameters.ResizeTimeout;
                    requestComputeNodeIds     = request.TypedParameters.ComputeNodeIds;

                    ComputeNodeRemoveResponse response    = new ComputeNodeRemoveResponse();
                    Task <ComputeNodeRemoveResponse> task = Task.FromResult(response);
                    return(task);
                };
            });

            cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>()
            {
                interceptor
            };

            cmdlet.ExecuteCmdlet();

            // Verify that the parameters were properly set on the outgoing request
            Assert.Equal(cmdlet.DeallocationOption, requestDeallocationOption);
            Assert.Equal(cmdlet.ResizeTimeout, requestResizeTimeout);
            Assert.Equal(cmdlet.Ids.Length, requestComputeNodeIds.Count);
            foreach (string id in cmdlet.Ids)
            {
                Assert.True(requestComputeNodeIds.Contains(id));
            }
        }
        public void RemoveComputeNodeRequestTest()
        {
            // Setup cmdlet to skip confirmation popup
            cmdlet.Force = true;
            commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny<string>(), It.IsAny<string>())).Returns(true);

            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
            cmdlet.BatchContext = context;

            cmdlet.PoolId = "testPool";
            cmdlet.Ids = new string[] { "computeNode1", "computeNode2" };
            cmdlet.DeallocationOption = ComputeNodeDeallocationOption.Terminate;
            cmdlet.ResizeTimeout = TimeSpan.FromMinutes(8);

            ComputeNodeDeallocationOption? requestDeallocationOption = null;
            TimeSpan? requestResizeTimeout = null;
            IList<string> requestComputeNodeIds = null;

            // Don't go to the service on a Remove ComputeNode call
            RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
            {
                BatchRequest<ComputeNodeRemoveParameters, ComputeNodeRemoveResponse> request =
                (BatchRequest<ComputeNodeRemoveParameters, ComputeNodeRemoveResponse>)baseRequest;

                request.ServiceRequestFunc = (cancellationToken) =>
                {
                    // Grab the parameters from the outgoing request.
                    requestDeallocationOption = request.TypedParameters.ComputeNodeDeallocationOption;
                    requestResizeTimeout = request.TypedParameters.ResizeTimeout;
                    requestComputeNodeIds = request.TypedParameters.ComputeNodeIds;

                    ComputeNodeRemoveResponse response = new ComputeNodeRemoveResponse();
                    Task<ComputeNodeRemoveResponse> task = Task.FromResult(response);
                    return task;
                };
            });
            cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };

            cmdlet.ExecuteCmdlet();

            // Verify that the parameters were properly set on the outgoing request
            Assert.Equal(cmdlet.DeallocationOption, requestDeallocationOption);
            Assert.Equal(cmdlet.ResizeTimeout, requestResizeTimeout);
            Assert.Equal(cmdlet.Ids.Length, requestComputeNodeIds.Count);
            foreach (string id in cmdlet.Ids)
            {
                Assert.True(requestComputeNodeIds.Contains(id));
            }
        }