< Summary

Class:Azure.ResourceManager.Compute.VirtualMachineSizesOperations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\VirtualMachineSizesOperations.cs
Covered lines:22
Uncovered lines:8
Coverable lines:30
Total lines:96
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%
ListAsync(...)-63.64%50%
<ListAsync()-62.5%100%
List(...)-63.64%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\VirtualMachineSizesOperations.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.Compute.Models;
 15
 16namespace Azure.ResourceManager.Compute
 17{
 18    /// <summary> The VirtualMachineSizes service client. </summary>
 19    public partial class VirtualMachineSizesOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 423        internal VirtualMachineSizesRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of VirtualMachineSizesOperations for mocking. </summary>
 39625        protected VirtualMachineSizesOperations()
 26        {
 39627        }
 28        /// <summary> Initializes a new instance of VirtualMachineSizesOperations. </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"> Subscription credentials which uniquely identify Microsoft Azure subscription.
 32        /// <param name="endpoint"> server parameter. </param>
 39633        internal VirtualMachineSizesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscr
 34        {
 39635            RestClient = new VirtualMachineSizesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 39636            _clientDiagnostics = clientDiagnostics;
 39637            _pipeline = pipeline;
 39638        }
 39
 40        /// <summary> This API is deprecated. Use [Resources Skus](https://docs.microsoft.com/en-us/rest/api/compute/res
 41        /// <param name="location"> The location upon which virtual-machine-sizes is queried. </param>
 42        /// <param name="cancellationToken"> The cancellation token to use. </param>
 43        public virtual AsyncPageable<VirtualMachineSize> ListAsync(string location, CancellationToken cancellationToken 
 44        {
 245            if (location == null)
 46            {
 047                throw new ArgumentNullException(nameof(location));
 48            }
 49
 50            async Task<Page<VirtualMachineSize>> FirstPageFunc(int? pageSizeHint)
 51            {
 252                using var scope = _clientDiagnostics.CreateScope("VirtualMachineSizesOperations.List");
 253                scope.Start();
 54                try
 55                {
 256                    var response = await RestClient.ListAsync(location, cancellationToken).ConfigureAwait(false);
 257                    return Page.FromValues(response.Value.Value, null, response.GetRawResponse());
 58                }
 059                catch (Exception e)
 60                {
 061                    scope.Failed(e);
 062                    throw;
 63                }
 264            }
 265            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null);
 66        }
 67
 68        /// <summary> This API is deprecated. Use [Resources Skus](https://docs.microsoft.com/en-us/rest/api/compute/res
 69        /// <param name="location"> The location upon which virtual-machine-sizes is queried. </param>
 70        /// <param name="cancellationToken"> The cancellation token to use. </param>
 71        public virtual Pageable<VirtualMachineSize> List(string location, CancellationToken cancellationToken = default)
 72        {
 273            if (location == null)
 74            {
 075                throw new ArgumentNullException(nameof(location));
 76            }
 77
 78            Page<VirtualMachineSize> FirstPageFunc(int? pageSizeHint)
 79            {
 280                using var scope = _clientDiagnostics.CreateScope("VirtualMachineSizesOperations.List");
 281                scope.Start();
 82                try
 83                {
 284                    var response = RestClient.List(location, cancellationToken);
 285                    return Page.FromValues(response.Value.Value, null, response.GetRawResponse());
 86                }
 087                catch (Exception e)
 88                {
 089                    scope.Failed(e);
 090                    throw;
 91                }
 292            }
 293            return PageableHelpers.CreateEnumerable(FirstPageFunc, null);
 94        }
 95    }
 96}