< Summary

Class:Azure.Storage.Blobs.QuickQueryExtensions
Assembly:Azure.Storage.Blobs
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs\src\QuickQueryExtensions.cs
Covered lines:33
Uncovered lines:26
Coverable lines:59
Total lines:96
Line coverage:55.9% (33 of 59)
Covered branches:2
Total branches:18
Branch coverage:11.1% (2 of 18)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
ToQuickQuerySerialization(...)-7.14%6.25%
ToBlobDownloadInfo(...)-100%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs\src\QuickQueryExtensions.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections.Generic;
 6using System.Globalization;
 7using System.Text;
 8using Azure.Storage.Blobs.Models;
 9
 10namespace Azure.Storage.Blobs
 11{
 12    /// <summary>
 13    /// Quick Query extensions.
 14    /// </summary>
 15    internal static class QuickQueryExtensions
 16    {
 17        internal static QuerySerialization ToQuickQuerySerialization(
 18            this IBlobQueryTextOptions textConfiguration)
 19        {
 22420            if (textConfiguration == default)
 21            {
 22422                return default;
 23            }
 24
 025            QuerySerialization serialization = new QuerySerialization
 026            {
 027                Format = new QueryFormat()
 028            };
 29
 030            serialization.Format.DelimitedTextConfiguration = default;
 031            serialization.Format.JsonTextConfiguration = default;
 32
 033            if (textConfiguration.GetType() == typeof(BlobQueryCsvTextOptions))
 34            {
 035                BlobQueryCsvTextOptions cvsTextConfiguration = textConfiguration as BlobQueryCsvTextOptions;
 036                serialization.Format.Type = QueryFormatType.Delimited;
 037                serialization.Format.DelimitedTextConfiguration = new DelimitedTextConfigurationInternal
 038                {
 039                    ColumnSeparator = cvsTextConfiguration.ColumnSeparator?.ToString(CultureInfo.InvariantCulture),
 040                    FieldQuote = cvsTextConfiguration.QuotationCharacter?.ToString(CultureInfo.InvariantCulture),
 041                    RecordSeparator = cvsTextConfiguration.RecordSeparator?.ToString(CultureInfo.InvariantCulture),
 042                    EscapeChar = cvsTextConfiguration.EscapeCharacter?.ToString(CultureInfo.InvariantCulture),
 043                    HeadersPresent = cvsTextConfiguration.HasHeaders
 044                };
 45            }
 046            else if (textConfiguration.GetType() == typeof(BlobQueryJsonTextOptions))
 47            {
 048                BlobQueryJsonTextOptions jsonTextConfiguration = textConfiguration as BlobQueryJsonTextOptions;
 049                serialization.Format.Type = QueryFormatType.Json;
 050                serialization.Format.JsonTextConfiguration = new JsonTextConfigurationInternal
 051                {
 052                    RecordSeparator = jsonTextConfiguration.RecordSeparator?.ToString(CultureInfo.InvariantCulture)
 053                };
 54            }
 55            else
 56            {
 057                throw new ArgumentException(Constants.QuickQuery.Errors.InvalidTextConfigurationType);
 58            }
 59
 060            return serialization;
 61        }
 62
 63        internal static BlobDownloadInfo ToBlobDownloadInfo(this BlobQueryResult quickQueryResult)
 8864            => BlobsModelFactory.BlobDownloadInfo(
 8865                lastModified: quickQueryResult.LastModified,
 8866                blobSequenceNumber: quickQueryResult.BlobSequenceNumber,
 8867                blobType: quickQueryResult.BlobType,
 8868                contentCrc64: quickQueryResult.ContentCrc64,
 8869                contentLanguage: quickQueryResult.ContentLanguage,
 8870                copyStatusDescription: quickQueryResult.CopyStatusDescription,
 8871                copyId: quickQueryResult.CopyId,
 8872                copyProgress: quickQueryResult.CopyProgress,
 8873                copySource: quickQueryResult.CopySource != default ? new Uri(quickQueryResult.CopySource) : default,
 8874                copyStatus: quickQueryResult.CopyStatus,
 8875                contentDisposition: quickQueryResult.ContentDisposition,
 8876                leaseDuration: quickQueryResult.LeaseDuration,
 8877                cacheControl: quickQueryResult.CacheControl,
 8878                leaseState: quickQueryResult.LeaseState,
 8879                contentEncoding: quickQueryResult.ContentEncoding,
 8880                leaseStatus: quickQueryResult.LeaseStatus,
 8881                contentHash: quickQueryResult.ContentHash,
 8882                acceptRanges: quickQueryResult.AcceptRanges,
 8883                eTag: quickQueryResult.ETag,
 8884                blobCommittedBlockCount: quickQueryResult.BlobCommittedBlockCount,
 8885                contentRange: quickQueryResult.ContentRange,
 8886                isServerEncrypted: quickQueryResult.IsServerEncrypted,
 8887                contentType: quickQueryResult.ContentType,
 8888                encryptionKeySha256: quickQueryResult.EncryptionKeySha256,
 8889                encryptionScope: quickQueryResult.EncryptionScope,
 8890                contentLength: quickQueryResult.ContentLength,
 8891                blobContentHash: quickQueryResult.BlobContentMD5,
 8892                metadata: quickQueryResult.Metadata,
 8893                content: quickQueryResult.Body,
 8894                copyCompletionTime: quickQueryResult.CopyCompletionTime);
 95    }
 96}