< Summary

Class:Microsoft.Azure.Batch.AsyncApplicationSummariesEnumerator
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\AsyncApplicationSummariesEnumerator.cs
Covered lines:24
Uncovered lines:2
Coverable lines:26
Total lines:83
Line coverage:92.3% (24 of 26)
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%
GetNextBatchFromServerAsync()-100%100%
get_Current()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\AsyncApplicationSummariesEnumerator.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 AsyncApplicationSummariesEnumerator : PagedEnumeratorBase<ApplicationSummary>
 12    {
 13        private readonly ApplicationOperations _parentApplicationOperations;
 14
 15        private readonly BehaviorManager _behaviorMgr;
 16        private readonly DetailLevel _detailLevel;
 17
 18#region // constructors
 19
 020        private AsyncApplicationSummariesEnumerator()
 21        {
 022        }
 23
 424        internal AsyncApplicationSummariesEnumerator(
 425                ApplicationOperations parentApplicationOperations,
 426                BehaviorManager behaviorMgr,
 427                DetailLevel detailLevel)
 28        {
 429            _parentApplicationOperations = parentApplicationOperations;
 430            _behaviorMgr = behaviorMgr;
 431            _detailLevel = detailLevel;
 432        }
 33
 34#endregion // constructors
 35
 36        protected override async System.Threading.Tasks.Task GetNextBatchFromServerAsync(SkipTokenHandler skipHandler, C
 37        {
 38            do
 39            {
 40                // start the protocol layer call
 41
 642                var asyncTask = this._parentApplicationOperations.ParentBatchClient.ProtocolLayer.ListApplicationSummari
 643                    skipHandler.SkipToken,
 644                    _behaviorMgr,
 645                    _detailLevel,
 646                    cancellationToken);
 47
 648                var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false);
 49
 650                skipHandler.SkipToken = response.Body.NextPageLink;
 51
 52                // remember the protocol tasks returned
 653                base._currentBatch = null;
 54
 655                if (null != response.Body)
 56                {
 657                    base._currentBatch = response.Body.ToArray();
 58                }
 59            }
 60            // it is possible for there to be no results so we keep trying
 661            while (skipHandler.ThereIsMoreData && ((null == _currentBatch) || _currentBatch.Length <= 0));
 662        }
 63
 64        public override ApplicationSummary Current  // for IPagedEnumerator<T> and IEnumerator<T>
 65        {
 66            get
 67            {
 68                // start with the current object off of base
 1069                object curObj = base._currentBatch[base._currentIndex];
 70
 71                // it must be a protocol object from previous call
 1072                Models.ApplicationSummary protocolObj = curObj as Models.ApplicationSummary;
 73
 74                Debug.Assert(null != protocolObj);
 75
 76                // wrap protocol object
 1077                ApplicationSummary wrapped = new ApplicationSummary(protocolObj);
 78
 1079                return wrapped;
 80            }
 81        }
 82    }
 83}