< Summary

Class:Microsoft.Azure.Batch.AsyncListJobSchedulesEnumerator
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\AsyncListJobSchedules.cs
Covered lines:20
Uncovered lines:4
Coverable lines:24
Total lines:81
Line coverage:83.3% (20 of 24)
Covered branches:8
Total branches:8
Branch coverage:100% (8 of 8)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
get_Current()-0%100%
GetNextBatchFromServerAsync()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\AsyncListJobSchedules.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for license information.
 3
 4namespace Microsoft.Azure.Batch
 5{
 6    using System.Diagnostics;
 7    using System.Linq;
 8    using System.Threading;
 9    using Models = Microsoft.Azure.Batch.Protocol.Models;
 10
 11    internal class AsyncListJobSchedulesEnumerator : PagedEnumeratorBase<CloudJobSchedule>
 12    {
 13        private readonly JobScheduleOperations _parentJobScheduleOperations;
 14        private readonly BehaviorManager _behaviorMgr;
 15        private readonly DetailLevel _detailLevel;
 16
 17#region // constructors
 18
 319        internal AsyncListJobSchedulesEnumerator(
 320                JobScheduleOperations parentJobScheduleOperations,
 321                BehaviorManager behaviorMgr,
 322                DetailLevel detailLevel)
 23        {
 324            this._parentJobScheduleOperations = parentJobScheduleOperations;
 325            this._behaviorMgr = behaviorMgr;
 326            this._detailLevel = detailLevel;
 327        }
 28
 29#endregion // constructors
 30
 31        public override CloudJobSchedule Current  // for IPagedEnumerator<T> and IEnumerator<T>
 32        {
 33            get
 34            {
 35                // start with the current object off of base
 036                object curObj = base._currentBatch[base._currentIndex];
 37
 38                // it must be a protocol object from previous call
 039                Models.CloudJobSchedule protocolObj = curObj as Models.CloudJobSchedule;
 40
 41                Debug.Assert(null != protocolObj);
 42
 43                // wrap protocol object
 044                CloudJobSchedule wrapped = new CloudJobSchedule(this._parentJobScheduleOperations.ParentBatchClient, pro
 45
 046                return wrapped;
 47            }
 48        }
 49
 50        /// <summary>
 51        /// fetch another batch of objects from the server
 52        /// </summary>
 53        protected async override System.Threading.Tasks.Task GetNextBatchFromServerAsync(SkipTokenHandler skipHandler, C
 54        {
 55            do
 56            {
 57                // start the protocol layer call
 458                var asyncTask = this._parentJobScheduleOperations.ParentBatchClient.ProtocolLayer.ListJobSchedules(
 459                    skipHandler.SkipToken,
 460                    _behaviorMgr,
 461                    _detailLevel,
 462                    cancellationToken);
 63
 464                var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false);
 65
 66                // remember any skiptoken returned.  This also sets the bool
 267                skipHandler.SkipToken = response.Body.NextPageLink;
 68
 69                // remember the protocol tasks returned
 270                base._currentBatch = null;
 71
 272                if (null != response.Body.GetEnumerator())
 73                {
 274                    base._currentBatch = response.Body.ToArray();
 75                }
 76            }
 77            // it is possible for there to be no results so we keep trying
 278            while (skipHandler.ThereIsMoreData && ((null == _currentBatch) || _currentBatch.Length <= 0));
 179        }
 80    }
 81}