public void GetBatchPoolODataTest()
        {
            // Setup cmdlet to get a single pool
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;
            cmdlet.Id           = "testPool";
            cmdlet.Select       = "id,state";
            cmdlet.Expand       = "stats";

            string requestSelect = null;
            string requestExpand = null;

            // Fetch the OData clauses off the request. The OData clauses are applied after user provided RequestInterceptors, so a ResponseInterceptor is used.
            CloudPoolGetResponse getResponse         = BatchTestHelpers.CreateCloudPoolGetResponse(cmdlet.Id);
            RequestInterceptor   requestInterceptor  = BatchTestHelpers.CreateFakeServiceResponseInterceptor <CloudPoolGetParameters, CloudPoolGetResponse>(getResponse);
            ResponseInterceptor  responseInterceptor = new ResponseInterceptor((response, request) =>
            {
                requestSelect = request.Parameters.DetailLevel.SelectClause;
                requestExpand = request.Parameters.DetailLevel.ExpandClause;

                return(Task.FromResult(response));
            });

            cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>()
            {
                requestInterceptor, responseInterceptor
            };

            cmdlet.ExecuteCmdlet();

            Assert.Equal(cmdlet.Select, requestSelect);
            Assert.Equal(cmdlet.Expand, requestExpand);
        }
        public void GetBatchPoolTest()
        {
            // Setup cmdlet to get a pool by id
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;
            cmdlet.Id           = "testPool";
            cmdlet.Filter       = null;

            // Build a CloudPool instead of querying the service on a Get CloudPool call
            CloudPoolGetResponse response    = BatchTestHelpers.CreateCloudPoolGetResponse(cmdlet.Id);
            RequestInterceptor   interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor <CloudPoolGetParameters, CloudPoolGetResponse>(response);

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

            // Setup the cmdlet to write pipeline output to a list that can be examined later
            List <PSCloudPool> pipeline = new List <PSCloudPool>();

            commandRuntimeMock.Setup(r => r.WriteObject(It.IsAny <PSCloudPool>())).Callback <object>(p => pipeline.Add((PSCloudPool)p));

            cmdlet.ExecuteCmdlet();

            // Verify that the cmdlet wrote the pool returned from the OM to the pipeline
            Assert.Equal(1, pipeline.Count);
            Assert.Equal(cmdlet.Id, pipeline[0].Id);
        }