< Summary

Class:Azure.ResourceManager.Storage.UsagesOperations
Assembly:Azure.ResourceManager.Storage
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\UsagesOperations.cs
Covered lines:22
Uncovered lines:8
Coverable lines:30
Total lines:97
Line coverage:73.3% (22 of 30)
Covered branches:2
Total branches:4
Branch coverage:50% (2 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_RestClient()-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
ListByLocationAsync(...)-63.64%50%
<ListByLocationAsync()-62.5%100%
ListByLocation(...)-63.64%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\UsagesOperations.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Threading;
 10using System.Threading.Tasks;
 11using Azure;
 12using Azure.Core;
 13using Azure.Core.Pipeline;
 14using Azure.ResourceManager.Storage.Models;
 15
 16namespace Azure.ResourceManager.Storage
 17{
 18    /// <summary> The Usages service client. </summary>
 19    public partial class UsagesOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 423        internal UsagesRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of UsagesOperations for mocking. </summary>
 24025        protected UsagesOperations()
 26        {
 24027        }
 28        /// <summary> Initializes a new instance of UsagesOperations. </summary>
 29        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 30        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 31        /// <param name="subscriptionId"> The ID of the target subscription. </param>
 32        /// <param name="endpoint"> server parameter. </param>
 33        /// <param name="apiVersion"> Api Version. </param>
 24034        internal UsagesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri
 35        {
 24036            RestClient = new UsagesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint, apiVersion);
 24037            _clientDiagnostics = clientDiagnostics;
 24038            _pipeline = pipeline;
 24039        }
 40
 41        /// <summary> Gets the current usage count and the limit for the resources of the location under the subscriptio
 42        /// <param name="location"> The location of the Azure Storage resource. </param>
 43        /// <param name="cancellationToken"> The cancellation token to use. </param>
 44        public virtual AsyncPageable<Usage> ListByLocationAsync(string location, CancellationToken cancellationToken = d
 45        {
 246            if (location == null)
 47            {
 048                throw new ArgumentNullException(nameof(location));
 49            }
 50
 51            async Task<Page<Usage>> FirstPageFunc(int? pageSizeHint)
 52            {
 253                using var scope = _clientDiagnostics.CreateScope("UsagesOperations.ListByLocation");
 254                scope.Start();
 55                try
 56                {
 257                    var response = await RestClient.ListByLocationAsync(location, cancellationToken).ConfigureAwait(fals
 258                    return Page.FromValues(response.Value.Value, null, response.GetRawResponse());
 59                }
 060                catch (Exception e)
 61                {
 062                    scope.Failed(e);
 063                    throw;
 64                }
 265            }
 266            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null);
 67        }
 68
 69        /// <summary> Gets the current usage count and the limit for the resources of the location under the subscriptio
 70        /// <param name="location"> The location of the Azure Storage resource. </param>
 71        /// <param name="cancellationToken"> The cancellation token to use. </param>
 72        public virtual Pageable<Usage> ListByLocation(string location, CancellationToken cancellationToken = default)
 73        {
 274            if (location == null)
 75            {
 076                throw new ArgumentNullException(nameof(location));
 77            }
 78
 79            Page<Usage> FirstPageFunc(int? pageSizeHint)
 80            {
 281                using var scope = _clientDiagnostics.CreateScope("UsagesOperations.ListByLocation");
 282                scope.Start();
 83                try
 84                {
 285                    var response = RestClient.ListByLocation(location, cancellationToken);
 286                    return Page.FromValues(response.Value.Value, null, response.GetRawResponse());
 87                }
 088                catch (Exception e)
 89                {
 090                    scope.Failed(e);
 091                    throw;
 92                }
 293            }
 294            return PageableHelpers.CreateEnumerable(FirstPageFunc, null);
 95        }
 96    }
 97}