< Summary

Class:Microsoft.Azure.Batch.AsyncListNodeFilesByNodeEnumerator
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\AsyncListNodeFiles.cs
Covered lines:23
Uncovered lines:10
Coverable lines:33
Total lines:94
Line coverage:69.6% (23 of 33)
Covered branches:2
Total branches:8
Branch coverage:25% (2 of 8)

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\AsyncListNodeFiles.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 AsyncListNodeFilesByNodeEnumerator : PagedEnumeratorBase<NodeFile>
 12    {
 13        private readonly PoolOperations _parentPoolOperations;
 14        private readonly string _poolId;
 15        private readonly string _computeNodeId;
 16        private readonly bool? _recursive;
 17        private readonly BehaviorManager _behaviorMgr;
 18        private readonly DetailLevel _detailLevel;
 19
 20#region // constructors
 21
 122        internal AsyncListNodeFilesByNodeEnumerator(
 123                PoolOperations parentPoolOperations,
 124                string poolId,
 125                string computeNodeId,
 126                bool? recursive,
 127                BehaviorManager behaviorMgr,
 128                DetailLevel detailLevel)
 29        {
 130            _parentPoolOperations = parentPoolOperations;
 131            _poolId = poolId;
 132            _computeNodeId = computeNodeId;
 133            _recursive = recursive;
 134            _behaviorMgr = behaviorMgr;
 135            _detailLevel = detailLevel;
 136        }
 37
 38#endregion // constructors
 39
 40        public override NodeFile Current  // for IPagedEnumerator<T> and IEnumerator<T>
 41        {
 42            get
 43            {
 44                // start with the current object off of base
 045                object curObj = base._currentBatch[base._currentIndex];
 46
 47                // it must be a protocol object from previous call
 048                Models.NodeFile protoFile = curObj as Models.NodeFile;
 49
 50                Debug.Assert(null != protoFile);
 51
 52                // wrap protocol object
 053                NodeFile wrapped = new ComputeNodeFile(_parentPoolOperations, _poolId, _computeNodeId, protoFile, _behav
 54
 055                return wrapped;
 56            }
 57        }
 58
 59        /// <summary>
 60        /// fetch another batch of objects from the server
 61        /// </summary>
 62        protected async override System.Threading.Tasks.Task GetNextBatchFromServerAsync(SkipTokenHandler skipHandler, C
 63        {
 64            do
 65            {
 66                // start the protocol layer call
 167                var asyncTask = _parentPoolOperations.ParentBatchClient.ProtocolLayer.ListNodeFilesByNode(
 168                    _poolId,
 169                    _computeNodeId,
 170                    _recursive,
 171                    skipHandler.SkipToken,
 172                    _behaviorMgr,
 173                    _detailLevel,
 174                    cancellationToken);
 75
 76                // extract the response
 177                var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false);
 78
 79                // remember any skiptoken returned.  This also sets the bool
 080                skipHandler.SkipToken = response.Body.NextPageLink;
 81
 82                // remember the protocol tasks returned
 083                base._currentBatch = null;
 84
 085                if (null != response.Body.GetEnumerator())
 86                {
 087                    base._currentBatch = response.Body.ToArray();
 88                }
 89            }
 90            // it is possible for there to be no results so we keep trying
 091            while (skipHandler.ThereIsMoreData && ((null == base._currentBatch) || base._currentBatch.Length <= 0));
 092        }
 93    }
 94}