コード例 #1
0
        public void StopPoolResizeParametersTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;
            cmdlet.Name         = null;

            Assert.Throws <ArgumentNullException>(() => cmdlet.ExecuteCmdlet());

            cmdlet.Name = "testPool";

            // Don't go to the service on a StopPoolResize call
            YieldInjectionInterceptor interceptor = new YieldInjectionInterceptor((opContext, request) =>
            {
                if (request is StopPoolResizeRequest)
                {
                    StopPoolResizeResponse response = new StopPoolResizeResponse();
                    Task <object> task = Task <object> .Factory.StartNew(() => { return(response); });
                    return(task);
                }
                return(null);
            });

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

            // Verify no exceptions when required parameter is set
            cmdlet.ExecuteCmdlet();
        }
コード例 #2
0
        public void StopPoolResizeParametersTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;
            cmdlet.Id           = null;

            Assert.Throws <ArgumentNullException>(() => cmdlet.ExecuteCmdlet());

            cmdlet.Id = "testPool";

            // Don't go to the service on a StopResize CloudPool call
            RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
            {
                BatchRequest <CloudPoolStopResizeParameters, CloudPoolStopResizeResponse> request =
                    (BatchRequest <CloudPoolStopResizeParameters, CloudPoolStopResizeResponse>)baseRequest;

                request.ServiceRequestFunc = (cancellationToken) =>
                {
                    CloudPoolStopResizeResponse response    = new CloudPoolStopResizeResponse();
                    Task <CloudPoolStopResizeResponse> task = Task.FromResult(response);
                    return(task);
                };
            });

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

            // Verify no exceptions when required parameter is set
            cmdlet.ExecuteCmdlet();
        }
コード例 #3
0
        public void StopPoolResizeParametersTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;
            cmdlet.Id           = null;

            Assert.Throws <ArgumentNullException>(() => cmdlet.ExecuteCmdlet());

            cmdlet.Id = "testPool";

            // Don't go to the service on a StopResize CloudPool call
            RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor <CloudPoolStopResizeParameters, CloudPoolStopResizeResponse>();

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

            // Verify no exceptions when required parameter is set
            cmdlet.ExecuteCmdlet();
        }