public void SetPoolOSVersionParametersTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
            cmdlet.BatchContext = context;
            cmdlet.Id = null;

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

            cmdlet.Id = "testPool";

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

            cmdlet.TargetOSVersion = "targetOS";

            // Don't go to the service on an Upgrage OS call
            RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
            {
                BatchRequest<CloudPoolUpgradeOSParameters, CloudPoolUpgradeOSResponse> request =
                (BatchRequest<CloudPoolUpgradeOSParameters, CloudPoolUpgradeOSResponse>)baseRequest;

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

            // Verify no exceptions when required parameter is set
            cmdlet.ExecuteCmdlet();
        }
        public void SetPoolOSVersionRequestTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;

            string targetOS        = "targetOS";
            string requestTargetOS = null;

            cmdlet.Id = "testPool";
            cmdlet.TargetOSVersion = targetOS;

            // Don't go to the service on an Upgrade OS call
            RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
            {
                BatchRequest <CloudPoolUpgradeOSParameters, CloudPoolUpgradeOSResponse> request =
                    (BatchRequest <CloudPoolUpgradeOSParameters, CloudPoolUpgradeOSResponse>)baseRequest;

                // Grab the target OS version off the outgoing request
                requestTargetOS = request.TypedParameters.TargetOSVersion;

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

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

            cmdlet.ExecuteCmdlet();

            // Verify that the target OS was properly set on the outgoing request
            Assert.Equal(targetOS, requestTargetOS);
        }
        public void SetPoolOSVersionRequestTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
            cmdlet.BatchContext = context;

            string targetOS = "targetOS";
            string requestTargetOS = null;

            cmdlet.Id = "testPool";
            cmdlet.TargetOSVersion = targetOS;

            // Don't go to the service on an Upgrade OS call
            RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
            {
                BatchRequest<CloudPoolUpgradeOSParameters, CloudPoolUpgradeOSResponse> request =
                (BatchRequest<CloudPoolUpgradeOSParameters, CloudPoolUpgradeOSResponse>)baseRequest;

                // Grab the target OS version off the outgoing request
                requestTargetOS = request.TypedParameters.TargetOSVersion;

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

            cmdlet.ExecuteCmdlet();

            // Verify that the target OS was properly set on the outgoing request
            Assert.Equal(targetOS, requestTargetOS);
        }