public void ShouldNotRetryAnyOtherExceptionAction() { var action = new Mock <Func <Task <string> > >(); action.Setup(a => a()).Throws <Exception>(); var executer = new LinearRetryRequestExecuter(3, 0); executer.Awaiting(e => e.ExecuteAsync(action.Object)).Should().Throw <Exception>(); action.Verify(a => a(), Times.Exactly(1)); }
public void ShouldInvokeCallbackAction() { var executer = new LinearRetryRequestExecuter(5, 0); var action = new Mock <Func <Task <string> > >(); action.Setup(a => a()).Throws <TaskCanceledException>(); var invokedTimes = 0; executer.Awaiting(e => e.ExecuteAsync(action.Object, (exp) => invokedTimes++)).Should().Throw <TaskCanceledException>(); invokedTimes.Should().Be(4); }
public void ShouldUseThrottler() { var throttler = new Mock <IRequestExecutionThrottler>(); var executer = new LinearRetryRequestExecuter(5, 0, throttler.Object); var action = new Mock <Func <Task <string> > >(); action.Setup(a => a()).Throws <TaskCanceledException>(); executer.Awaiting(e => e.ExecuteAsync(action.Object)).Should().Throw <Exception>(); throttler.Verify(t => t.ReserveAsync(), Times.Exactly(5)); throttler.Verify(t => t.Release(), Times.Exactly(5)); }