コード例 #1
0
        public void Get_RetryPolicy_Exponential()
        {
            // Arrange
            // Act
            IRetryPolicy policy = Settings.GetRetryPolicy("Exponential", TimeSpan.FromSeconds(3), 3);

            // Assert
            Assert.AreEqual(policy.GetType(), typeof(ExponentialRetry));
        }
コード例 #2
0
        public void Get_RetryPolicy_NoRetry()
        {
            // Arrange
            // Act
            IRetryPolicy policy = Settings.GetRetryPolicy("NoRetry", TimeSpan.Zero, 0);

            // Assert
            Assert.AreEqual(policy.GetType(), typeof(NoRetry));
        }
コード例 #3
0
        public void Get_RetryPolicy_Linear()
        {
            // Arrange
            // Act
            IRetryPolicy policy = Settings.GetRetryPolicy("Linear", TimeSpan.FromSeconds(30), 3);

            // Assert
            Assert.AreEqual(policy.GetType(), typeof(LinearRetry));
        }
コード例 #4
0
        private static PolicyInfo GetRetryPolicyInfo(IRetryPolicy policy)
        {
            var retryPolicyType = policy.GetType();

            if (retryPolicyType == typeof(RetryPolicyExtensions.WrappedExtendedRetryPolicy))
            {
                var typedPolicy = (RetryPolicyExtensions.WrappedExtendedRetryPolicy)policy;
                return(RetryPolicyInfoProvider.GetRetryPolicyInfo(typedPolicy.Policy));
            }

            RetryPolicyInfoProvider.RetryPolicyOptionsProviders.TryGetValue(retryPolicyType, out var retryPolicyOptionsProvider);
            return(new PolicyInfo
            {
                Namespace = retryPolicyType.Namespace,
                Type = retryPolicyType.Name,
                Options = retryPolicyOptionsProvider?.Invoke(policy)
            });
        }