コード例 #1
0
        public void InvokeFailure_RetryForbidden()
        {
            var instance     = new RetryProxySubject();
            var retryTest    = new CanNotRetryProxySubjectException();
            var retryOptions = new RetryOptions(5, TimeSpan.FromSeconds(5));
            var retryProxy   = RetryProxy.Create <IRetryProxySubject>(instance, retryOptions, retryTest);

            try
            {
                var result = retryProxy.Fail();
            }
            catch (RetryException ex)
            {
                Assert.IsTrue(ex.InnerException is ProxySubjectException);
                Assert.AreEqual(1, ex.Attempts);
                Assert.AreEqual(ex.Attempts, ex.Exceptions.Count);
                throw;
            }
        }
コード例 #2
0
        public async Task InvokeFailure_RetryForbiddenAsync()
        {
            var instance     = new RetryProxySubject();
            var retryTest    = new CanNotRetryProxySubjectException();
            var retryOptions = new RetryOptions(5, TimeSpan.FromSeconds(5));
            var retryProxy   = RetryProxy.Create <IRetryProxySubject>(instance, retryOptions, retryTest);

            //Assert.ThrowsException<RetryNotAllowedException>()
            try
            {
                var result = await retryProxy.FailAsync();
            }
            catch (RetryException ex)
            {
                Assert.IsTrue(ex.InnerException is ProxySubjectException);
                Assert.AreEqual(1, ex.Attempts);
                Assert.AreEqual(ex.Attempts, ex.Exceptions.Count);
                throw;
            }
        }