private static SteamClientApiClient GetSteamClientApiClient(IContext c)
        {
            var settings        = c.Kernel.Get <IDailyLeaderboardsSettings>();
            var telemetryClient = c.Kernel.Get <TelemetryClient>();
            var log             = c.Kernel.Get <ILog>();

            var userName = settings.SteamUserName;
            var password = settings.SteamPassword.Decrypt();
            var timeout  = settings.SteamClientTimeout;

            var policy = Policy
                         .Handle <Exception>(SteamClientApiClient.IsTransient)
                         .WaitAndRetryAsync(
                3,
                ExponentialBackoff.GetSleepDurationProvider(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(2)),
                (ex, duration) =>
            {
                telemetryClient.TrackException(ex);
                if (log.IsDebugEnabled)
                {
                    log.Debug($"Retrying in {duration}...", ex);
                }
            });

            return(new SteamClientApiClient(userName, password, policy, telemetryClient)
            {
                Timeout = timeout
            });
        }
            public void ReturnsSleepDurationProvider()
            {
                // Arrange
                var minBackoff   = TimeSpan.FromSeconds(1);
                var maxBackoff   = TimeSpan.FromSeconds(10);
                var deltaBackoff = TimeSpan.FromSeconds(2);

                // Act
                var backoff = ExponentialBackoff.GetSleepDurationProvider(minBackoff, maxBackoff, deltaBackoff);

                // Assert
                Assert.IsAssignableFrom <Func <int, TimeSpan> >(backoff);
            }
            public void SleepDurationProvider_ReturnsSleepDuration()
            {
                // Arrange
                var minBackoff        = TimeSpan.FromSeconds(1);
                var maxBackoff        = TimeSpan.FromSeconds(10);
                var deltaBackoff      = TimeSpan.FromSeconds(2);
                var backoff           = ExponentialBackoff.GetSleepDurationProvider(minBackoff, maxBackoff, deltaBackoff);
                var currentRetryCount = 1;

                // Act
                var sleep = backoff(currentRetryCount);

                // Assert
                Assert.InRange(sleep, minBackoff, maxBackoff);
            }