< Summary

Class:Azure.Storage.AggregatingProgressIncrementer
Assembly:Azure.Storage.Files.DataLake
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Common\src\Shared\AggregatingProgressIncrementer.cs
Covered lines:6
Uncovered lines:4
Coverable lines:10
Total lines:59
Line coverage:60% (6 of 10)
Covered branches:3
Total branches:6
Branch coverage:50% (3 of 6)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
CreateProgressIncrementingStream(...)-100%50%
.ctor(...)-100%100%
Report(...)-100%50%
Reset()-0%100%
get_None()-0%100%
get_Current()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Common\src\Shared\AggregatingProgressIncrementer.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.IO;
 6using System.Threading;
 7using System.Threading.Tasks;
 8
 9namespace Azure.Storage
 10{
 11    /// <summary>
 12    /// An accumulator for request and response data transfers.
 13    /// </summary>
 14    internal sealed class AggregatingProgressIncrementer : IProgress<long>
 15    {
 16        private long _currentValue;
 17        private readonly IProgress<long> _innerHandler;
 18
 419        public Stream CreateProgressIncrementingStream(Stream stream) => _innerHandler != null && stream != null ? new P
 20
 5621        public AggregatingProgressIncrementer(IProgress<long> innerHandler) => _innerHandler = innerHandler;
 22
 23        /// <summary>
 24        /// Increments the current value and reports it to the progress handler
 25        /// </summary>
 26        /// <param name="bytes"></param>
 27        public void Report(long bytes)
 28        {
 21629            Interlocked.Add(ref _currentValue, bytes);
 30
 21631            _innerHandler?.Report(Current);
 21632        }
 33
 34        /// <summary>
 35        /// Zeroes out the current accumulation, and reports it to the progress handler
 36        /// </summary>
 37        public void Reset()
 38        {
 039            Volatile.Write(ref _currentValue, 0);
 040            Report(0);
 041        }
 42
 43        /// <summary>
 44        /// Returns an instance that no-ops accumulation.
 45        /// </summary>
 046        public static AggregatingProgressIncrementer None { get; } = new AggregatingProgressIncrementer(default);
 47
 48        /// <summary>
 49        /// Returns a long instance representing the current progress value.
 50        /// </summary>
 51        public long Current
 52        {
 53            get
 54            {
 21655                return Volatile.Read(ref _currentValue);
 56            }
 57        }
 58    }
 59}