< Summary

Class:Azure.ResourceManager.Compute.Operations
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Operations.cs
Covered lines:20
Uncovered lines:6
Coverable lines:26
Total lines:83
Line coverage:76.9% (20 of 26)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_RestClient()-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
<ListAsync()-62.5%100%
ListAsync(...)-100%100%
List(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Operations.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  service client. </summary>
 19    public partial class Operations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 423        internal RestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of Operations for mocking. </summary>
 39625        protected Operations()
 26        {
 39627        }
 28        /// <summary> Initializes a new instance of Operations. </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="endpoint"> server parameter. </param>
 39632        internal Operations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null)
 33        {
 39634            RestClient = new RestOperations(clientDiagnostics, pipeline, endpoint);
 39635            _clientDiagnostics = clientDiagnostics;
 39636            _pipeline = pipeline;
 39637        }
 38
 39        /// <summary> Gets a list of compute operations. </summary>
 40        /// <param name="cancellationToken"> The cancellation token to use. </param>
 41        public virtual AsyncPageable<ComputeOperationValue> ListAsync(CancellationToken cancellationToken = default)
 42        {
 43            async Task<Page<ComputeOperationValue>> FirstPageFunc(int? pageSizeHint)
 44            {
 245                using var scope = _clientDiagnostics.CreateScope("Operations.List");
 246                scope.Start();
 47                try
 48                {
 249                    var response = await RestClient.ListAsync(cancellationToken).ConfigureAwait(false);
 250                    return Page.FromValues(response.Value.Value, null, response.GetRawResponse());
 51                }
 052                catch (Exception e)
 53                {
 054                    scope.Failed(e);
 055                    throw;
 56                }
 257            }
 258            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null);
 59        }
 60
 61        /// <summary> Gets a list of compute operations. </summary>
 62        /// <param name="cancellationToken"> The cancellation token to use. </param>
 63        public virtual Pageable<ComputeOperationValue> List(CancellationToken cancellationToken = default)
 64        {
 65            Page<ComputeOperationValue> FirstPageFunc(int? pageSizeHint)
 66            {
 267                using var scope = _clientDiagnostics.CreateScope("Operations.List");
 268                scope.Start();
 69                try
 70                {
 271                    var response = RestClient.List(cancellationToken);
 272                    return Page.FromValues(response.Value.Value, null, response.GetRawResponse());
 73                }
 074                catch (Exception e)
 75                {
 076                    scope.Failed(e);
 077                    throw;
 78                }
 279            }
 280            return PageableHelpers.CreateEnumerable(FirstPageFunc, null);
 81        }
 82    }
 83}