< Summary

Class:Microsoft.Azure.Batch.AsyncListTasksEnumerator
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\AsyncListTasks.cs
Covered lines:27
Uncovered lines:2
Coverable lines:29
Total lines:88
Line coverage:93.1% (27 of 29)
Covered branches:8
Total branches:8
Branch coverage:100% (8 of 8)

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\AsyncListTasks.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 AsyncListTasksEnumerator : PagedEnumeratorBase<CloudTask>
 12    {
 13        private readonly JobOperations _jobOperations;
 14        private readonly string _jobId;
 15        private readonly BehaviorManager _behaviorMgr;
 16        private readonly DetailLevel _detailLevel;
 17
 18#region // constructors
 019        private AsyncListTasksEnumerator()
 20        {
 021        }
 22
 623        internal AsyncListTasksEnumerator(
 624                JobOperations jobOperations,
 625                string jobId,
 626                BehaviorManager behaviorMgr,
 627                DetailLevel detailLevel)
 28        {
 629            this._jobOperations = jobOperations;
 630            this._jobId = jobId;
 631            this._behaviorMgr = behaviorMgr;
 632            this._detailLevel = detailLevel;
 633        }
 34
 35#endregion // constructors
 36
 37        public override CloudTask Current  // for IPagedEnumerator<T> and IEnumerator<T>
 38        {
 39            get
 40            {
 41                // start with the current object off of base
 742                object curObj = base._currentBatch[base._currentIndex];
 43
 44                // it must be a protocol object from previous call
 745                Models.CloudTask protoTask = curObj as Models.CloudTask;
 46
 47                Debug.Assert(null != protoTask);
 48
 49                // wrap protocol object
 750                CloudTask wrapped = new CloudTask(this._jobOperations.ParentBatchClient, this._jobId, protoTask, _behavi
 51
 752                return wrapped;
 53            }
 54        }
 55
 56        /// <summary>
 57        /// fetch another batch of objects from the server
 58        /// </summary>
 59        protected async override System.Threading.Tasks.Task GetNextBatchFromServerAsync(SkipTokenHandler skipHandler, C
 60        {
 61            do
 62            {
 63                // start the protocol layer call
 764                var asyncTask = this._jobOperations.ParentBatchClient.ProtocolLayer.ListTasks(
 765                    this._jobId,
 766                    skipHandler.SkipToken,
 767                    this._behaviorMgr,
 768                    this._detailLevel,
 769                    cancellationToken);
 70
 771                var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false);
 72
 73                // remember any skiptoken returned.  This also sets the bool
 674                skipHandler.SkipToken = response.Body.NextPageLink;
 75
 76                // remember the protocol tasks returned
 677                base._currentBatch = null;
 78
 679                if (null != response.Body.GetEnumerator())
 80                {
 681                    base._currentBatch = response.Body.ToArray();
 82                }
 83            }
 84            // it is possible for there to be no results so we keep trying
 685            while (skipHandler.ThereIsMoreData && ((null == _currentBatch) || _currentBatch.Length <= 0));
 586        }
 87    }
 88}