/// <summary> /// Initializes a new instance of the <see cref="DurableCommitDispatcher"/> class. /// </summary> /// <param name="eventStoreClient">An event store client.</param> /// <param name="checkpointRepository">A checkpoint repository. Each instane of a <see cref="DurableCommitDispatcher"/> /// should have their own instance of a <see cref="ICheckpointRepository"/>.</param> /// <param name="dispatchCommit">A handler to dispatch the commit to.</param> /// <param name="retryPolicy">A retry policy when a <see cref="TransientException"/> occurs. /// If none specified TransientException.None is used.</param> /// <exception cref="System.ArgumentNullException"> /// eventStoreClient /// or /// checkpointRepository /// or /// dispatchCommit /// </exception> public DurableCommitDispatcher( [NotNull] IEventStoreClient eventStoreClient, [NotNull] ICheckpointRepository checkpointRepository, [NotNull] Func <ICommit, CancellationToken, Task> dispatchCommit, TransientExceptionRetryPolicy retryPolicy = null) { Guard.EnsureNotNull(eventStoreClient, "eventStoreClient"); Guard.EnsureNotNull(checkpointRepository, "checkpointRepository"); Guard.EnsureNotNull(dispatchCommit, "dispatchCommit"); _eventStoreClient = eventStoreClient; _checkpointRepository = checkpointRepository; _dispatchCommit = dispatchCommit; _retryPolicy = retryPolicy ?? TransientExceptionRetryPolicy.None(); }
public async Task Transient_policy_none_should_not_retry() { var sut = TransientExceptionRetryPolicy.None(); int count = 0; Func <Task> act = () => sut.Retry(() => { count++; if (count == 1) { throw new TransientException(); } return(Task.FromResult(0)); }, CancellationToken.None); act.ShouldThrow <TransientException>(); count.Should().Be(1); }