< Summary

Class:Azure.Storage.Files.Shares.Models.ShareFileDownloadInfo
Assembly:Azure.Storage.Files.Shares
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Files.Shares\src\Models\ShareFileDownloadInfo.cs
Covered lines:11
Uncovered lines:1
Coverable lines:12
Total lines:143
Line coverage:91.6% (11 of 12)
Covered branches:1
Total branches:2
Branch coverage:50% (1 of 2)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_ContentLength()-100%100%
get_Content()-100%100%
get_ContentType()-100%100%
get_ContentHash()-0%100%
get_Details()-100%100%
.ctor(...)-100%100%
Dispose()-100%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Files.Shares\src\Models\ShareFileDownloadInfo.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.IO;
 7using System.Text;
 8using Azure.Storage.Shared;
 9
 10#pragma warning disable SA1402  // File may only contain a single type
 11
 12namespace Azure.Storage.Files.Shares.Models
 13{
 14    /// <summary>
 15    /// The properties and content returned from downloading a file
 16    /// </summary>
 17    public partial class ShareFileDownloadInfo : IDisposable, IDownloadedContent
 18    {
 19        /// <summary>
 20        /// Internal flattened property representation
 21        /// </summary>
 22        internal FlattenedStorageFileProperties _flattened;
 23
 24        /// <summary>
 25        /// The number of bytes present in the response body.
 26        /// </summary>
 227        public long ContentLength => _flattened.ContentLength;
 28
 29        /// <summary>
 30        /// Content
 31        /// </summary>
 5732        public Stream Content => _flattened.Content;
 33
 34        /// <summary>
 35        /// The content type specified for the file. The default content type is 'application/octet-stream'
 36        /// </summary>
 237        public string ContentType => _flattened.ContentType;
 38
 39        /// <summary>
 40        /// If the file has an MD5 hash and this operation is to read the full content, this response header is returned
 41        /// </summary>
 42#pragma warning disable CA1819 // Properties should not return arrays
 043        public byte[] ContentHash => _flattened.ContentHash;
 44#pragma warning restore CA1819 // Properties should not return arrays
 45
 46        /// <summary>
 47        /// Details returned when downloading a file
 48        /// </summary>
 9949        public ShareFileDownloadDetails Details { get; private set; }
 50
 51        /// <summary>
 52        /// Creates a new StorageFileDownloadInfo backed by FlattenedStorageFileProperties
 53        /// </summary>
 54        /// <param name="flattened">The FlattenedStorageFileProperties returned with the request</param>
 6155        internal ShareFileDownloadInfo(FlattenedStorageFileProperties flattened)
 56        {
 6157            _flattened = flattened;
 6158            Details = new ShareFileDownloadDetails(flattened);
 6159        }
 60
 61        /// <summary>
 62        /// Disposes the StorageFileDownloadInfo by calling Dispose on the underlying Content stream.
 63        /// </summary>
 64        public void Dispose()
 65        {
 166            Content?.Dispose();
 167            GC.SuppressFinalize(this);
 168        }
 69    }
 70    /// <summary>
 71    /// FilesModelFactory provides utilities for mocking.
 72    /// </summary>
 73    public static partial class FilesModelFactory
 74    {
 75        /// <summary>
 76        /// Creates a new StorageFileDownloadInfo instance for mocking.
 77        /// </summary>
 78        public static ShareFileDownloadInfo StorageFileDownloadInfo(
 79            System.DateTimeOffset lastModified = default,
 80            System.Collections.Generic.IEnumerable<string> contentLanguage = default,
 81            string acceptRanges = default,
 82            System.DateTimeOffset copyCompletionTime = default,
 83            string copyStatusDescription = default,
 84            string contentDisposition = default,
 85            string copyProgress = default,
 86            System.Uri copySource = default,
 87            Azure.Storage.Files.Shares.Models.CopyStatus copyStatus = default,
 88            byte[] fileContentHash = default,
 89            bool isServerEncrypted = default,
 90            string cacheControl = default,
 91            string fileAttributes = default,
 92            System.Collections.Generic.IEnumerable<string> contentEncoding = default,
 93            System.DateTimeOffset fileCreationTime = default,
 94            byte[] contentHash = default,
 95            System.DateTimeOffset fileLastWriteTime = default,
 96            ETag eTag = default,
 97            System.DateTimeOffset fileChangeTime = default,
 98            string contentRange = default,
 99            string filePermissionKey = default,
 100            string contentType = default,
 101            string fileId = default,
 102            long contentLength = default,
 103            string fileParentId = default,
 104            System.Collections.Generic.IDictionary<string, string> metadata = default,
 105            System.IO.Stream content = default,
 106            string copyId = default)
 107        {
 108            return new ShareFileDownloadInfo(
 109                new FlattenedStorageFileProperties()
 110                {
 111                    LastModified = lastModified,
 112                    ContentLanguage = contentLanguage,
 113                    AcceptRanges = acceptRanges,
 114                    CopyCompletionTime = copyCompletionTime,
 115                    CopyStatusDescription = copyStatusDescription,
 116                    ContentDisposition = contentDisposition,
 117                    CopyProgress = copyProgress,
 118                    CopySource = copySource,
 119                    CopyStatus = copyStatus,
 120                    FileContentHash = fileContentHash,
 121                    IsServerEncrypted = isServerEncrypted,
 122                    CacheControl = cacheControl,
 123                    FileAttributes = fileAttributes,
 124                    ContentEncoding = contentEncoding,
 125                    FileCreationTime = fileCreationTime,
 126                    ContentHash = contentHash,
 127                    FileLastWriteTime = fileLastWriteTime,
 128                    ETag = eTag,
 129                    FileChangeTime = fileChangeTime,
 130                    ContentRange = contentRange,
 131                    FilePermissionKey = filePermissionKey,
 132                    ContentType = contentType,
 133                    FileId = fileId,
 134                    ContentLength = contentLength,
 135                    FileParentId = fileParentId,
 136                    Metadata = metadata,
 137                    Content = content,
 138                    CopyId = copyId,
 139                }
 140            );
 141        }
 142    }
 143}