< Summary

Class:Microsoft.Azure.Batch.ApplicationOperations
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\ApplicationOperations.cs
Covered lines:29
Uncovered lines:2
Coverable lines:31
Total lines:142
Line coverage:93.5% (29 of 31)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-0%100%
.ctor(...)-100%100%
get_ParentBatchClient()-100%100%
get_CustomBehaviors()-100%100%
ListApplicationSummaries(...)-100%100%
GetApplicationSummaryAsync()-100%100%
GetApplicationSummary(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\ApplicationOperations.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
 4using System;
 5using System.Collections;
 6using System.Collections.Generic;
 7using System.Collections.ObjectModel;
 8using System.Linq;
 9using System.Threading;
 10using System.Threading.Tasks;
 11
 12using Microsoft.Azure.Batch.Protocol.Models;
 13
 14namespace Microsoft.Azure.Batch
 15{
 16    /// <summary>
 17    /// Performs application-related operations on an Azure Batch account.
 18    /// </summary>
 19    public class ApplicationOperations : IInheritedBehaviors
 20    {
 21        private readonly BatchClient _parentBatchClient;
 22
 23#region // constructors
 24
 025        private ApplicationOperations()
 26        {
 027        }
 28
 529        internal ApplicationOperations(BatchClient parentBatchClient, IEnumerable<BatchClientBehavior> inheritedBehavior
 30        {
 531            _parentBatchClient = parentBatchClient;
 32
 33            // set up the behavior inheritance
 534            InheritUtil.InheritClientBehaviorsAndSetPublicProperty(this, inheritedBehaviors);
 535        }
 36
 37#endregion
 38
 39#region // internal/private
 40
 41        /// <summary>
 42        /// allows child objects to access the protocol wrapper and secrets to make verb calls
 43        /// </summary>
 44        internal BatchClient ParentBatchClient
 45        {
 846            get { return _parentBatchClient; }
 47        }
 48
 49#endregion // internal/private
 50
 51
 52#region IInheritedBehaviors
 53
 54        /// <summary>
 55        /// Gets or sets a list of behaviors that modify or customize requests to the Batch service
 56        /// made via this <see cref="ApplicationOperations"/>.
 57        /// </summary>
 58        /// <remarks>
 59        /// <para>These behaviors are inherited by child objects.</para>
 60        /// <para>Modifications are applied in the order of the collection. The last write wins.</para>
 61        /// </remarks>
 1162        public IList<BatchClientBehavior> CustomBehaviors { get; set; }
 63
 64#endregion IInheritedBehaviors
 65
 66#region // ApplicationOperations
 67
 68        /// <summary>
 69        /// Enumerates the <see cref="ApplicationSummary">applications</see> in the Batch account.
 70        /// </summary>
 71        /// <param name="detailLevel">A <see cref="DetailLevel"/> used for filtering the list and for controlling which 
 72        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 73        /// <returns>An <see cref="IPagedEnumerable{ApplicationSummary}"/> that can be used to enumerate applications as
 74        /// <remarks>This method returns immediately; the applications are retrieved from the Batch service only when th
 75        /// Retrieval is non-atomic; applications are retrieved in pages during enumeration of the collection.</remarks>
 76        public IPagedEnumerable<ApplicationSummary> ListApplicationSummaries(DetailLevel detailLevel = null, IEnumerable
 77        {
 78            // craft the behavior manager for this call
 379            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors);
 80
 381            PagedEnumerable<ApplicationSummary> enumerable = new PagedEnumerable<ApplicationSummary>(
 382                // the lambda will be the enumerator factory
 383                () =>
 384                    {
 385                        // here is the actual strongly typed enumerator
 786                        AsyncApplicationSummariesEnumerator typedEnumerator = new AsyncApplicationSummariesEnumerator(th
 387
 388                        // here is the base
 389                        PagedEnumeratorBase<ApplicationSummary> enumeratorBase = typedEnumerator;
 390
 791                        return enumeratorBase;
 392                    });
 93
 394            return enumerable;
 95        }
 96
 97        /// <summary>
 98        /// Gets information about the specified application.
 99        /// </summary>
 100        /// <param name="applicationId">The id of the application to get.</param>
 101        /// <param name="detailLevel">A <see cref="DetailLevel"/> used for controlling which properties are retrieved fr
 102        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 103        /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch
 104        /// <returns>An <see cref="ApplicationSummary"/> containing information about the specified application.</return
 105        /// <remarks>The get application operation runs asynchronously.</remarks>
 106        public async System.Threading.Tasks.Task<ApplicationSummary> GetApplicationSummaryAsync(string applicationId, De
 107        {
 108            // create the behavior manager
 2109            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors, detailLevel);
 110
 111            // start call to server
 2112            var asyncTask = this.ParentBatchClient.ProtocolLayer.GetApplicationSummary(applicationId, bhMgr, cancellatio
 113
 2114            var response = await asyncTask.ConfigureAwait(continueOnCapturedContext: false);
 115
 116            // construct object model ApplicationSummary
 2117            ApplicationSummary applicationSummary = new ApplicationSummary(response.Body);
 118
 2119            return applicationSummary;
 2120        }
 121
 122        /// <summary>
 123        /// Gets information about the specified application.
 124        /// </summary>
 125        /// <param name="applicationId">The id of the application to get.</param>
 126        /// <param name="detailLevel">A <see cref="DetailLevel"/> used for controlling which properties are retrieved fr
 127        /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli
 128        /// <returns>An <see cref="ApplicationSummary"/> containing information about the specified application.</return
 129        /// <remarks>This is a blocking operation. For a non-blocking equivalent, see <see cref="GetApplicationSummaryAs
 130        public ApplicationSummary GetApplicationSummary(string applicationId, DetailLevel detailLevel = null, IEnumerabl
 131        {
 1132            Task<ApplicationSummary> asyncTask = GetApplicationSummaryAsync(applicationId, detailLevel, additionalBehavi
 1133            ApplicationSummary applicationSummary = asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, addition
 134
 1135            return applicationSummary;
 136        }
 137
 138        #endregion
 139
 140
 141    }
 142}