public void RefreshPolicy_AsyncHandleException_UncaughtException_RetryFail() { var swt = new Switch(); RefreshPolicy policy = RefreshPolicy.HandleExceptionAsync <ArgumentOutOfRangeException>(swt.SwitchOnAsync); Assert.ThrowsAsync <ArgumentNullException>(() => policy.ExcecuteAsync(swt.ThrowArgumentNullIfNotOnAsync)); }
public void RefreshPolicy_AsyncHandleException_SynchronousAction_NoException() { var swt = new Switch(); RefreshPolicy policy = RefreshPolicy.HandleExceptionAsync <Exception>(swt.SwitchOnAsync); policy.Excecute(swt.ThrowIfNotOnVoid); }
public CloudTableRefreshClient(IClientMaintainer <CloudTableClient> clientProvider) : base( clientProvider, RefreshPolicy.HandleException <StorageException>( x => x.RequestInformation?.HttpStatusCode == (int)HttpStatusCode.Forbidden, clientProvider.RefreshClient)) { }
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); }
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); }
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); }
/// <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)) { }