< Summary

Class:Microsoft.Azure.Batch.Conventions.Files.Utilities.CloudBlobContainerUtils
Assembly:Microsoft.Azure.Batch.Conventions.Files
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch.Conventions.Files\src\Utilities\CloudBlobContainerUtils.cs
Covered lines:2
Uncovered lines:16
Coverable lines:18
Total lines:65
Line coverage:11.1% (2 of 18)
Covered branches:1
Total branches:8
Branch coverage:12.5% (1 of 8)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
GetContainerReference(...)-66.67%50%
GetContainerReference(...)-0%0%
ListBlobs()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch.Conventions.Files\src\Utilities\CloudBlobContainerUtils.cs

#LineLine coverage
 1// Copyright (c) Microsoft and contributors.  All rights reserved.
 2//
 3// Licensed under the Apache License, Version 2.0 (the "License");
 4// you may not use this file except in compliance with the License.
 5// You may obtain a copy of the License at
 6// http://www.apache.org/licenses/LICENSE-2.0
 7//
 8// Unless required by applicable law or agreed to in writing, software
 9// distributed under the License is distributed on an "AS IS" BASIS,
 10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 11//
 12// See the License for the specific language governing permissions and
 13// limitations under the License.
 14
 15using Microsoft.WindowsAzure.Storage;
 16using Microsoft.WindowsAzure.Storage.Blob;
 17using System;
 18using System.Collections.Generic;
 19
 20namespace Microsoft.Azure.Batch.Conventions.Files.Utilities
 21{
 22    internal static class CloudBlobContainerUtils
 23    {
 24        internal static CloudBlobContainer GetContainerReference(Uri jobOutputContainerUri)
 25        {
 3526            if (jobOutputContainerUri == null)
 27            {
 028                throw new ArgumentNullException(nameof(jobOutputContainerUri));
 29            }
 30
 3531            return new CloudBlobContainer(jobOutputContainerUri);
 32        }
 33
 34        internal static CloudBlobContainer GetContainerReference(CloudStorageAccount storageAccount, string jobId)
 35        {
 036            if (storageAccount == null)
 37            {
 038                throw new ArgumentNullException(nameof(storageAccount));
 39            }
 40
 041            Validate.IsNotNullOrEmpty(jobId, nameof(jobId));
 42
 043            var jobOutputContainerName = ContainerNameUtils.GetSafeContainerName(jobId);
 044            return storageAccount.CreateCloudBlobClient().GetContainerReference(jobOutputContainerName);
 45        }
 46
 47        internal static IEnumerable<IListBlobItem> ListBlobs(this CloudBlobContainer container, string prefix, bool useF
 48        {
 049            BlobContinuationToken continuationToken = null;
 50            do
 51            {
 052                BlobResultSegment segment = container
 053                    .ListBlobsSegmentedAsync(prefix, useFlatBlobListing, BlobListingDetails.None, null, continuationToke
 054                    .GetAwaiter()
 055                    .GetResult();
 056                foreach (var result in segment.Results)
 57                {
 058                    yield return result;
 59                }
 060                continuationToken = segment.ContinuationToken;
 061            } while (continuationToken != null);
 62
 063        }
 64    }
 65}