< Summary

Class:Microsoft.Azure.Batch.AsyncListComputeNodesEnumerator
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\AsyncListComputeNodes.cs
Covered lines:27
Uncovered lines:0
Coverable lines:27
Total lines:86
Line coverage:100% (27 of 27)
Covered branches:8
Total branches:8
Branch coverage:100% (8 of 8)

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\AsyncListComputeNodes.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 AsyncListComputeNodesEnumerator : PagedEnumeratorBase<ComputeNode>
 12    {
 13        private readonly PoolOperations _parentPoolOps;
 14        private readonly string _poolId;
 15        private readonly BehaviorManager _behaviorMgr;
 16        private readonly DetailLevel _detailLevel;
 17
 18        #region // constructors
 19
 320        internal AsyncListComputeNodesEnumerator(
 321                PoolOperations parentPoolOps,
 322                string poolId,
 323                BehaviorManager behaviorMgr,
 324                DetailLevel detailLevel)
 25        {
 326            _parentPoolOps = parentPoolOps;
 327            _poolId = poolId;
 328            _behaviorMgr = behaviorMgr;
 329            _detailLevel = detailLevel;
 330        }
 31
 32        #endregion // constructors
 33
 34        public override ComputeNode Current  // for IPagedEnumerator<T> and IEnumerator<T>
 35        {
 36            get
 37            {
 38                // start with the current object off of base
 139                object curObj = base._currentBatch[base._currentIndex];
 40
 41                // it must be a protocol object from previous call
 142                Models.ComputeNode protocolObj = curObj as Models.ComputeNode;
 43
 44                Debug.Assert(null != protocolObj);
 45
 46                // wrap protocol object
 147                ComputeNode wrapped = new ComputeNode(_parentPoolOps.ParentBatchClient, _poolId, protocolObj, _behaviorM
 48
 149                return wrapped;
 50            }
 51        }
 52
 53        /// <summary>
 54        /// fetch another batch of objects from the server
 55        /// </summary>
 56        protected async override System.Threading.Tasks.Task GetNextBatchFromServerAsync(SkipTokenHandler skipHandler, C
 57        {
 58            do
 59            {
 60                // start the protocol layer call
 461                var asyncTask = _parentPoolOps.ParentBatchClient.ProtocolLayer.ListComputeNodes(
 462                    _poolId,
 463                    skipHandler.SkipToken,
 464                    _behaviorMgr,
 465                    _detailLevel,
 466                    cancellationToken);
 67
 68                // extract the response
 469                var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false);
 70
 71                // remember any skiptoken returned.  This also sets the bool
 372                skipHandler.SkipToken = response.Body.NextPageLink;
 73
 74                // remember the protocol tasks returned
 375                base._currentBatch = null;
 76
 377                if (null != response.Body.GetEnumerator())
 78                {
 379                    base._currentBatch = response.Body.ToArray();
 80                }
 81            }
 82            // it is possible for there to be no results so we keep trying
 383            while (skipHandler.ThereIsMoreData && ((null == _currentBatch) || _currentBatch.Length <= 0));
 284        }
 85    }
 86}