Пример #1
0
        protected override void ExecuteCmdletImpl()
        {
            GetTaskCountsOptions options = new GetTaskCountsOptions(this.BatchContext, this.JobId, this.Job, this.AdditionalBehaviors);

            PSTaskSlotCounts taskSlotCount = BatchClient.GetTaskSlotCounts(options);

            WriteObject(taskSlotCount);
        }
Пример #2
0
        public void GetBatchTaskSlotCountTest()
        {
            // Setup cmdlet to get task slot count by job id
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;
            cmdlet.JobId        = "job-1";

            const int requiredSlots = 2;
            const int active        = 3;
            const int running       = 5;
            const int succeeded     = 2;
            const int failed        = 1;

            // Build a TaskCountsResult instead of querying the service
            AzureOperationResponse <ProxyModels.TaskCountsResult, ProxyModels.JobGetTaskCountsHeaders> response =
                BatchTestHelpers.CreateTaskCountsGetResponse(requiredSlots, active, running, succeeded, failed);

            RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor <
                ProxyModels.JobGetTaskCountsOptions,
                AzureOperationResponse <ProxyModels.TaskCountsResult, ProxyModels.JobGetTaskCountsHeaders> >(response);

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

            // Setup the cmdlet to write pipeline output to a list that can be examined later
            PSTaskSlotCounts slotCount = null;

            commandRuntimeMock
            .Setup(r => r.WriteObject(It.IsAny <PSTaskSlotCounts>()))
            .Callback <object>(p => {
                slotCount = (PSTaskSlotCounts)p;
            });

            cmdlet.ExecuteCmdlet();

            Assert.Equal(6, slotCount.Active);
            Assert.Equal(10, slotCount.Running);
            Assert.Equal(6, slotCount.Completed);
            Assert.Equal(4, slotCount.Succeeded);
            Assert.Equal(2, slotCount.Failed);
        }