< Summary

Class:Microsoft.Azure.Batch.TaskFile
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\TaskFile.cs
Covered lines:17
Uncovered lines:18
Coverable lines:35
Total lines:105
Line coverage:48.5% (17 of 35)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
CopyToStreamAsync()-100%100%
DeleteAsync()-0%100%
RefreshAsync()-0%100%
Refresh(...)-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\TaskFile.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for license information.
 3
 4namespace Microsoft.Azure.Batch
 5{
 6    using System;
 7    using System.Collections.Generic;
 8    using System.Text;
 9    using System.IO;
 10    using System.Threading.Tasks;
 11    using System.Threading;
 12    using Models = Microsoft.Azure.Batch.Protocol.Models;
 13    using Microsoft.Rest.Azure;
 14
 15    internal class TaskFile : NodeFile
 16    {
 17        private readonly JobOperations _jobOperations;
 18        private readonly string _jobId;
 19        private readonly string _taskId;
 20
 21#region  // constructors
 22
 23        internal TaskFile(
 24            JobOperations jobOperations,
 25            string jobId,
 26            string taskId,
 27            Models.NodeFile boundToThis,
 428            IEnumerable<BatchClientBehavior> inheritTheseBehaviors) : base(boundToThis, inheritTheseBehaviors)
 29        {
 430            _jobOperations = jobOperations;
 431            _jobId = jobId;
 432            _taskId = taskId;
 433        }
 34
 35#endregion
 36
 37#region // NodeFile
 38
 39        public override async System.Threading.Tasks.Task CopyToStreamAsync(
 40            Stream stream,
 41            GetFileRequestByteRange byteRange = null,
 42            IEnumerable<BatchClientBehavior> additionalBehaviors = null,
 43            CancellationToken cancellationToken = default(CancellationToken))
 44        {
 45            // craft the behavior manager for this call
 346            BehaviorManager bhMgr = new BehaviorManager(base.CustomBehaviors, additionalBehaviors);
 47
 348            System.Threading.Tasks.Task<AzureOperationResponse<Models.NodeFile, Models.FileGetFromTaskHeaders>> asyncTas
 349                this._jobOperations.ParentBatchClient.ProtocolLayer.GetNodeFileByTask(
 350                    _jobId,
 351                    _taskId,
 352                    base.Path,
 353                    stream,
 354                    byteRange,
 355                    bhMgr,
 356                    cancellationToken);
 57
 358            await asyncTask.ConfigureAwait(continueOnCapturedContext: false);
 359        }
 60
 61        public override async System.Threading.Tasks.Task DeleteAsync(bool? recursive = null, IEnumerable<BatchClientBeh
 62        {
 63            // craft the behavior manager for this call
 064            BehaviorManager bhMgr = new BehaviorManager(base.CustomBehaviors, additionalBehaviors);
 65
 066            var asyncTask = this._jobOperations.ParentBatchClient.ProtocolLayer.DeleteNodeFileByTask(_jobId, _taskId, ba
 67
 068            await asyncTask.ConfigureAwait(continueOnCapturedContext: false);
 069        }
 70
 71#endregion // NodeFile
 72
 73#region IRefreshable
 74
 75        public override async System.Threading.Tasks.Task RefreshAsync(DetailLevel detailLevel = null, IEnumerable<Batch
 76        {
 77            // create the behavior managaer
 078            BehaviorManager bhMgr = new BehaviorManager(base.CustomBehaviors, additionalBehaviors, detailLevel);
 79
 080            System.Threading.Tasks.Task<AzureOperationResponse<Models.NodeFile, Models.FileGetPropertiesFromTaskHeaders>
 081                this._jobOperations.ParentBatchClient.ProtocolLayer.GetNodeFilePropertiesByTask(
 082                    _jobId,
 083                    _taskId,
 084                    this.Path,
 085                    bhMgr,
 086                    cancellationToken);
 87
 088            AzureOperationResponse<Models.NodeFile, Models.FileGetPropertiesFromTaskHeaders> response = await asyncTask.
 89
 90            // immediately available to all threads
 091            System.Threading.Interlocked.Exchange(ref base.fileItemBox, new FileItemBox(response.Body));
 092        }
 93
 94        public override void Refresh(DetailLevel detailLevel = null, IEnumerable<BatchClientBehavior> additionalBehavior
 95        {
 096            Task asyncTask = RefreshAsync(detailLevel, additionalBehaviors);
 097            asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors);
 098        }
 99
 100#endregion IRefreshable
 101
 102    }
 103}
 104
 105