public void ReadsExponentialBackoffRetryStrategyValuesFromConfiguration()
    {
        IConfigurationSection?    section = this.retryManagerOptions?.RetryStrategy?.GetSection("Exponential Backoff Non Default");
        ExponentialBackoffOptions data    = section.Get <ExponentialBackoffOptions>();

        Assert.AreEqual("Exponential Backoff Non Default", section?.Key);
        Assert.AreEqual(new TimeSpan(0, 0, 1), data.MinBackOff);
        Assert.AreEqual(new TimeSpan(0, 0, 2), data.MaxBackOff);
        Assert.AreEqual(TimeSpan.FromMilliseconds(300), data.DeltaBackOff);
        Assert.AreEqual(4, data.RetryCount);
        Assert.AreEqual(false, data.FastFirstRetry);
    }
Exemple #2
0
        /// <summary>
        /// Converts <see cref="Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.ExponentialBackoffOptions"/> instance to <see cref="Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.ExponentialBackoff"/> retry strategy.
        /// </summary>
        /// <param name="options">The <see cref="Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.ExponentialBackoffOptions"/> instance to convert.</param>
        /// <param name="name">The name of the retry strategy.</param>
        /// <returns>The converted <see cref="Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.ExponentialBackoff"/> retry strategy.</returns>
        public static ExponentialBackoff Strategy(this ExponentialBackoffOptions options, string name)
        {
            Guard.ArgumentNotNull(options, nameof(options));

            return(new ExponentialBackoff(name, options.RetryCount, options.MinBackOff, options.MaxBackOff, options.DeltaBackOff, options.FastFirstRetry));
        }