< Summary

Class:Microsoft.Azure.Batch.ComputeNodeFile
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\ComputeNodeFile.cs
Covered lines:17
Uncovered lines:24
Coverable lines:41
Total lines:109
Line coverage:41.4% (17 of 41)
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\ComputeNodeFile.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
 4using System.Collections.Generic;
 5using System.IO;
 6using Task = System.Threading.Tasks.Task;
 7using Models = Microsoft.Azure.Batch.Protocol.Models;
 8using System.Threading;
 9using Microsoft.Rest.Azure;
 10
 11namespace Microsoft.Azure.Batch
 12{
 13    internal class ComputeNodeFile : NodeFile
 14    {
 15        private readonly PoolOperations _poolOperations;
 16        private readonly string _poolId;
 17        private readonly string _computeNodeId;
 18
 19#region  // constructors
 20
 21        internal ComputeNodeFile(
 22            PoolOperations poolOperations,
 23            string poolId,
 24            string computeNodeId,
 25            Models.NodeFile boundToThis,
 426            IEnumerable<BatchClientBehavior> inheritTheseBehaviors) : base(boundToThis, inheritTheseBehaviors)
 27        {
 428            _poolOperations = poolOperations;
 429            _poolId = poolId;
 430            _computeNodeId = computeNodeId;
 431        }
 32#endregion
 33
 34#region // NodeFile
 35
 36        public override async System.Threading.Tasks.Task CopyToStreamAsync(
 37            Stream stream,
 38            GetFileRequestByteRange byteRange = null,
 39            IEnumerable<BatchClientBehavior> additionalBehaviors = null,
 40            CancellationToken cancellationToken = default(CancellationToken))
 41        {
 42            // craft the behavior manager for this call
 343            BehaviorManager bhMgr = new BehaviorManager(base.CustomBehaviors, additionalBehaviors);
 44
 345            System.Threading.Tasks.Task<AzureOperationResponse<Models.NodeFile, Models.FileGetFromComputeNodeHeaders>> a
 346                this._poolOperations.ParentBatchClient.ProtocolLayer.GetNodeFileByNode(
 347                    _poolId,
 348                    _computeNodeId,
 349                    base.Path,
 350                    stream,
 351                    byteRange,
 352                    bhMgr,
 353                    cancellationToken);
 54
 355            await asyncTask.ConfigureAwait(continueOnCapturedContext: false);
 356        }
 57
 58        public override async System.Threading.Tasks.Task DeleteAsync(bool? recursive = null, IEnumerable<BatchClientBeh
 59        {
 60            // craft the behavior manager for this call
 061            BehaviorManager bhMgr = new BehaviorManager(base.CustomBehaviors, additionalBehaviors);
 62
 063            var asyncTask = _poolOperations.ParentBatchClient.ProtocolLayer.DeleteNodeFileByNode(
 064                _poolId,
 065                _computeNodeId,
 066                base.Path,
 067                recursive,
 068                bhMgr,
 069                cancellationToken);
 70
 071            await asyncTask.ConfigureAwait(continueOnCapturedContext: false);
 072        }
 73
 74#endregion
 75
 76#region IRefreshable
 77
 78        public override async System.Threading.Tasks.Task RefreshAsync(
 79            DetailLevel detailLevel = null,
 80            IEnumerable<BatchClientBehavior> additionalBehaviors = null,
 81            CancellationToken cancellationToken = default(CancellationToken))
 82        {
 83            // create the behavior managaer
 084            BehaviorManager bhMgr = new BehaviorManager(base.CustomBehaviors, additionalBehaviors, detailLevel);
 85
 086            System.Threading.Tasks.Task<AzureOperationResponse<Models.NodeFile, Models.FileGetPropertiesFromComputeNodeH
 087                this._poolOperations.ParentBatchClient.ProtocolLayer.GetNodeFilePropertiesByNode(
 088                    _poolId,
 089                    _computeNodeId,
 090                    base.Path,
 091                    bhMgr,
 092                    cancellationToken);
 93
 094            AzureOperationResponse<Models.NodeFile, Models.FileGetPropertiesFromComputeNodeHeaders> response = await asy
 95
 96            // immediately available to all threads
 097            System.Threading.Interlocked.Exchange(ref base.fileItemBox, new FileItemBox(response.Body));
 098        }
 99
 100        public override void Refresh(DetailLevel detailLevel = null, IEnumerable<BatchClientBehavior> additionalBehavior
 101        {
 0102            Task asyncTask = RefreshAsync(detailLevel, additionalBehaviors);
 0103            asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors);
 0104        }
 105
 106#endregion
 107
 108    }
 109}