public void GetBatchPoolStatisticsTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;

            double   avgCPUPercentage = 10;
            DateTime startTime        = DateTime.UtcNow;

            AzureOperationResponse <
                ProxyModels.PoolStatistics,
                ProxyModels.PoolGetAllLifetimeStatisticsHeaders> response =
                BatchTestHelpers.CreatePoolStatisticsResponse(avgCPUPercentage, startTime);

            RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor <
                ProxyModels.PoolGetAllLifetimeStatisticsOptions,
                AzureOperationResponse <ProxyModels.PoolStatistics, ProxyModels.PoolGetAllLifetimeStatisticsHeaders> >(responseToUse: response);

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

            // Setup the cmdlet to write pipeline output to a variable that can be examined later
            PSPoolStatistics statistics = null;

            commandRuntimeMock.Setup(r => r.WriteObject(It.IsAny <PSPoolStatistics>())).Callback <object>(c => statistics = (PSPoolStatistics)c);

            cmdlet.ExecuteCmdlet();

            Assert.NotNull(statistics);
            Assert.Equal(startTime, statistics.UsageStatistics.StartTime);
            Assert.Equal(avgCPUPercentage, statistics.ResourceStatistics.AverageCpuPercentage);
        }
예제 #2
0
        public override void ExecuteCmdlet()
        {
            PSPoolStatistics poolStatistics = BatchClient.GetAllPoolsLifetimeStatistics(this.BatchContext, this.AdditionalBehaviors);

            WriteObject(poolStatistics);
        }