Ejemplo n.º 1
0
        public void ResetComputeNodeRequestTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;

            cmdlet.PoolId        = "testPool";
            cmdlet.Id            = "computeNode1";
            cmdlet.ReimageOption = ComputeNodeReimageOption.Terminate;

            ComputeNodeReimageOption?requestReimageOption = null;

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

                request.ServiceRequestFunc = (cancellationToken) =>
                {
                    // Grab the reimage option from the outgoing request.
                    requestReimageOption = request.TypedParameters.ComputeNodeReimageOption;

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

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

            cmdlet.ExecuteCmdlet();

            // Verify that the reimage option was properly set on the outgoing request
            Assert.Equal(cmdlet.ReimageOption, requestReimageOption);
        }
        public void ResetComputeNodeRequestTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
            cmdlet.BatchContext = context;

            cmdlet.PoolId = "testPool";
            cmdlet.Id = "computeNode1";
            cmdlet.ReimageOption = ComputeNodeReimageOption.Terminate;

            ComputeNodeReimageOption? requestReimageOption = null;

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

                request.ServiceRequestFunc = (cancellationToken) =>
                {
                    // Grab the reimage option from the outgoing request.
                    requestReimageOption = request.TypedParameters.ComputeNodeReimageOption;

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

            cmdlet.ExecuteCmdlet();

            // Verify that the reimage option was properly set on the outgoing request
            Assert.Equal(cmdlet.ReimageOption, requestReimageOption);
        }