< Summary

Class:Azure.Core.TestFramework.TestRetryHelper
Assembly:Azure.Core.TestFramework
File(s):C:\Git\azure-sdk-for-net\sdk\core\Azure.Core.TestFramework\src\TestRetryHelper.cs
Covered lines:0
Uncovered lines:10
Coverable lines:10
Total lines:39
Line coverage:0% (0 of 10)
Covered branches:0
Total branches:8
Branch coverage:0% (0 of 8)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
RetryAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\core\Azure.Core.TestFramework\src\TestRetryHelper.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.Threading.Tasks;
 7
 8namespace Azure.Core.TestFramework
 9{
 10    public static class TestRetryHelper
 11    {
 12        public static async Task<T> RetryAsync<T>(Func<Task<T>> operation, int maxIterations = 20, TimeSpan delay = defa
 13        {
 014            if (delay == default)
 15            {
 016                delay = TimeSpan.FromSeconds(5);
 17            }
 18
 019            List<Exception> exceptions = null;
 20
 021            for (int i = 0; i < maxIterations; i++)
 22            {
 23                try
 24                {
 025                    return await operation().ConfigureAwait(false);
 26                }
 27                catch (Exception e)
 28                {
 029                    exceptions ??= new List<Exception>();
 030                    exceptions.Add(e);
 31
 032                    await Task.Delay(delay);
 33                }
 34            }
 35
 036            throw new AggregateException(exceptions);
 037        }
 38    }
 39}

Methods/Properties

RetryAsync()