< Summary

Class:Microsoft.Azure.Batch.AsyncListNodeFilesByTaskEnumerator
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\AsyncListTaskFiles.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\AsyncListTaskFiles.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 AsyncListNodeFilesByTaskEnumerator : PagedEnumeratorBase<NodeFile>
 12    {
 13        private readonly JobOperations _jobOperations;
 14        private readonly string _jobId;
 15        private readonly string _taskId;
 16        private readonly bool? _recursive;
 17        private readonly BehaviorManager _behaviorMgr;
 18        private readonly DetailLevel _detailLevel;
 19
 20#region // constructors
 21
 122        internal AsyncListNodeFilesByTaskEnumerator(
 123                JobOperations jobOperations,
 124                string jobId,
 125                string taskId,
 126                bool? recursive,
 127                BehaviorManager behaviorMgr,
 128                DetailLevel detailLevel)
 29        {
 130            this._jobOperations = jobOperations;
 131            this._jobId = jobId;
 132            this._taskId = taskId;
 133            this._recursive = recursive;
 134            this._behaviorMgr = behaviorMgr;
 135            this._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 TaskFile(this._jobOperations, this._jobId, this._taskId, protoFile, _behaviorMgr.
 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 = this._jobOperations.ParentBatchClient.ProtocolLayer.ListNodeFilesByTask(
 168                    this._jobId,
 169                    this._taskId,
 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 == _currentBatch) || _currentBatch.Length <= 0));
 092        }
 93    }
 94}