示例#1
0
        public void RefreshPolicy_AsyncHandleException_UncaughtException_RetryFail()
        {
            var           swt    = new Switch();
            RefreshPolicy policy = RefreshPolicy.HandleExceptionAsync <ArgumentOutOfRangeException>(swt.SwitchOnAsync);

            Assert.ThrowsAsync <ArgumentNullException>(() => policy.ExcecuteAsync(swt.ThrowArgumentNullIfNotOnAsync));
        }
示例#2
0
        public void RefreshPolicy_AsyncHandleException_SynchronousAction_NoException()
        {
            var           swt    = new Switch();
            RefreshPolicy policy = RefreshPolicy.HandleExceptionAsync <Exception>(swt.SwitchOnAsync);

            policy.Excecute(swt.ThrowIfNotOnVoid);
        }
示例#3
0
 public CloudTableRefreshClient(IClientMaintainer <CloudTableClient> clientProvider)
     : base(
         clientProvider,
         RefreshPolicy.HandleException <StorageException>(
             x => x.RequestInformation?.HttpStatusCode == (int)HttpStatusCode.Forbidden,
             clientProvider.RefreshClient))
 {
 }
示例#4
0
        public void RefreshPolicy_AsyncHandleException_SynchronousFunc_RetrySuccess()
        {
            var           swt     = new Switch();
            RefreshPolicy policy  = RefreshPolicy.HandleExceptionAsync <Exception>(swt.SwitchOnAsync);
            bool          success = policy.Excecute(swt.ThrowIfNotOn);

            Assert.True(success);
        }
示例#5
0
        public async void RefreshPolicy_AsyncHandleExceptionWithPredicate_AsynchronousFunc_RetrySuccess()
        {
            var           swt     = new Switch();
            RefreshPolicy policy  = RefreshPolicy.HandleExceptionAsync <Exception>(x => x.Message == Message, swt.SwitchOnAsync);
            bool          success = await policy.ExcecuteAsync(swt.ThrowIfNotOnAsync).ConfigureAwait(false);

            Assert.True(success);
        }
示例#6
0
 public async void RefreshPolicy_AsyncHandleExceptionWithPredicate_AsynchronousAction_RetrySuccess()
 {
     var           swt    = new Switch();
     RefreshPolicy policy = RefreshPolicy.HandleExceptionAsync <Exception>(x => x.Message == Message, swt.SwitchOnAsync);
     await policy.ExcecuteAsync(swt.ThrowArgumentExceptionIfNotOnAsync).ConfigureAwait(false);
 }
示例#7
0
 /// <summary>
 /// Initializes a new instance of <see cref="DocumentRefreshClient"/>
 /// This will refersh on HttpStatusCode 401(Unauthorized)
 /// </summary>
 /// <param name="clientProvider"></param>
 public DocumentRefreshClient(IClientMaintainer <DocumentClient> clientProvider)
     : base(clientProvider, RefreshPolicy.HandleException <DocumentClientException>(
                x => x.StatusCode == HttpStatusCode.Unauthorized, clientProvider.RefreshClient))
 {
 }