< Summary

Class:Azure.Storage.Files.Shares.Models.GetSharesAsyncCollection
Assembly:Azure.Storage.Files.Shares
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Files.Shares\src\Models\GetSharesAsyncCollection.cs
Covered lines:23
Uncovered lines:0
Coverable lines:23
Total lines:87
Line coverage:100% (23 of 23)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
GetNextPageAsync()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Files.Shares\src\Models\GetSharesAsyncCollection.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System.Collections.Generic;
 5using System.Linq;
 6using System.Threading;
 7using System.Threading.Tasks;
 8using Azure.Storage.Files.Shares.Models;
 9
 10#pragma warning disable SA1402  // File may only contain a single type
 11
 12namespace Azure.Storage.Files.Shares.Models
 13{
 14    internal class GetSharesAsyncCollection : StorageCollectionEnumerator<ShareItem>
 15    {
 16        private readonly ShareServiceClient _client;
 17        private readonly ShareTraits _traits;
 18        private readonly ShareStates _states;
 19        private readonly string _prefix;
 20
 1021        public GetSharesAsyncCollection(
 1022            ShareServiceClient client,
 1023            ShareTraits traits = ShareTraits.None,
 1024            ShareStates states = ShareStates.None,
 1025            string prefix = default)
 26        {
 1027            _client = client;
 1028            _traits = traits;
 1029            _states = states;
 1030            _prefix = prefix;
 1031        }
 32
 33        public override async ValueTask<Page<ShareItem>> GetNextPageAsync(
 34            string continuationToken,
 35            int? pageSizeHint,
 36            bool async,
 37            CancellationToken cancellationToken)
 38        {
 1039            Response<SharesSegment> response = await _client.GetSharesInternal(
 1040                continuationToken,
 1041                _traits,
 1042                _states,
 1043                _prefix,
 1044                pageSizeHint,
 1045                async,
 1046                cancellationToken).ConfigureAwait(false);
 47
 848            return Page<ShareItem>.FromValues(
 849                response.Value.ShareItems.ToArray(),
 850                response.Value.NextMarker,
 851                response.GetRawResponse());
 852        }
 53    }
 54}
 55
 56namespace Azure.Storage.Files.Shares
 57{
 58    /// <summary>
 59    /// File service helpers.
 60    /// </summary>
 61    internal static partial class ShareExtensions
 62    {
 63        /// <summary>
 64        /// Convert the details into ListSharesIncludeType values.
 65        /// </summary>
 66        /// <returns>ListSharesIncludeType values</returns>
 67        internal static IEnumerable<ListSharesIncludeType> AsIncludeItems(ShareTraits traits, ShareStates states)
 68        {
 69            // NOTE: Multiple strings MUST be appended in alphabetic order or signing the string for authentication fail
 70            // TODO: Remove this requirement by pushing it closer to header generation.
 71            var items = new List<ListSharesIncludeType>();
 72            if ((states & ShareStates.Deleted) == ShareStates.Deleted)
 73            {
 74                items.Add(ListSharesIncludeType.Deleted);
 75            }
 76            if ((traits & ShareTraits.Metadata) == ShareTraits.Metadata)
 77            {
 78                items.Add(ListSharesIncludeType.Metadata);
 79            }
 80            if ((states & ShareStates.Snapshots) == ShareStates.Snapshots)
 81            {
 82                items.Add(ListSharesIncludeType.Snapshots);
 83            }
 84            return items.Count > 0 ? items : null;
 85        }
 86    }
 87}

Methods/Properties

.ctor(...)
GetNextPageAsync()