< Summary

Class:Microsoft.Azure.Batch.AsyncListJobPrepReleaseTaskStatusEnumerator
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\AsyncListJobPrepReleaseTaskStatus.cs
Covered lines:24
Uncovered lines:4
Coverable lines:28
Total lines:88
Line coverage:85.7% (24 of 28)
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\AsyncListJobPrepReleaseTaskStatus.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 AsyncListJobPrepReleaseTaskStatusEnumerator : PagedEnumeratorBase<JobPreparationAndReleaseTaskExecuti
 12    {
 13        private readonly JobOperations _parentJobOperations;
 14        private readonly BehaviorManager _behaviorMgr;
 15        private readonly string _jobId;
 16        private readonly DetailLevel _detailLevel;
 17
 18
 19#region // constructors
 20
 221        internal AsyncListJobPrepReleaseTaskStatusEnumerator(
 222                JobOperations parentJobOperations,
 223                string jobId,
 224                BehaviorManager behaviorMgr,
 225                DetailLevel detailLevel)
 26        {
 227            _parentJobOperations = parentJobOperations;
 228            _jobId = jobId;
 229            _behaviorMgr = behaviorMgr;
 230            _detailLevel = detailLevel;
 231        }
 32
 33#endregion // constructors
 34
 35        public override JobPreparationAndReleaseTaskExecutionInformation Current  // for IPagedEnumerator<T> and IEnumer
 36        {
 37            get
 38            {
 39                // start with the current object off of base
 040                object curObj = base._currentBatch[base._currentIndex];
 41
 42                // it must be a protocol object from previous call
 043                Models.JobPreparationAndReleaseTaskExecutionInformation protocolObj = curObj as Models.JobPreparationAnd
 44
 45                Debug.Assert(null != protocolObj);
 46
 47                // wrap protocol object
 048                JobPreparationAndReleaseTaskExecutionInformation wrapped = new JobPreparationAndReleaseTaskExecutionInfo
 49
 050                return wrapped;
 51            }
 52        }
 53
 54        /// <summary>
 55        /// fetch another batch of objects from the server
 56        /// </summary>
 57        protected async override System.Threading.Tasks.Task GetNextBatchFromServerAsync(SkipTokenHandler skipHandler, C
 58        {
 59            do
 60            {
 61                // start the protocol layer call
 362                var asyncTask =
 363                    _parentJobOperations.ParentBatchClient.ProtocolLayer.ListJobPreparationAndReleaseTaskStatus(
 364                        _jobId,
 365                        skipHandler.SkipToken,
 366                        _behaviorMgr,
 367                        _detailLevel,
 368                        cancellationToken);
 69
 70                // extract the response
 371                var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false);
 72
 73                // remember any skiptoken returned.  This also sets the bool
 274                skipHandler.SkipToken = response.Body.NextPageLink;
 75
 76                // remember the protocol tasks returned
 277                base._currentBatch = null;
 78
 279                if (null != response.Body.GetEnumerator())
 80                {
 281                    base._currentBatch = response.Body.ToArray();
 82                }
 83            }
 84            // it is possible for there to be no results so we keep trying
 285            while (skipHandler.ThereIsMoreData && ((null == _currentBatch) || _currentBatch.Length <= 0));
 186        }
 87    }
 88}