< Summary

Class:Microsoft.Azure.Batch.Conventions.Files.Utilities.BlobUtils
Assembly:Microsoft.Azure.Batch.Conventions.Files
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch.Conventions.Files\src\Utilities\BlobUtils.cs
Covered lines:0
Uncovered lines:7
Coverable lines:7
Total lines:45
Line coverage:0% (0 of 7)
Covered branches:0
Total branches:6
Branch coverage:0% (0 of 6)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
EnsureExistsAsync()-0%100%
StorageErrorCodeIs(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch.Conventions.Files\src\Utilities\BlobUtils.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;
 19using System.Linq;
 20using System.Text;
 21using System.Threading.Tasks;
 22
 23namespace Microsoft.Azure.Batch.Conventions.Files.Utilities
 24{
 25    internal static class BlobUtils
 26    {
 27        internal static async Task EnsureExistsAsync(this CloudAppendBlob blob)
 28        {
 29            try
 30            {
 031                await blob.CreateOrReplaceAsync(AccessCondition.GenerateIfNotExistsCondition(), null, null).ConfigureAwa
 032            }
 033            catch (StorageException ex) when (ex.StorageErrorCodeIs("BlobAlreadyExists"))
 34            {
 035            }
 036        }
 37
 38        internal static bool StorageErrorCodeIs(this StorageException ex, string errorCodeToTestFor)
 39        {
 040            var errorCode = ex?.RequestInformation?.ExtendedErrorInformation?.ErrorCode;
 41
 042            return errorCodeToTestFor.Equals(errorCode, StringComparison.OrdinalIgnoreCase);
 43        }
 44    }
 45}