public void Receive_Retry() { var timer = new FakeSequentialThreadingTimer(); var options = RetryOptions.Retry(); var mockConsumer = new Mock <IConsumer <int> >(); var timerFactory = CreateTimerFactory(timer); var calls = 0; mockConsumer.Setup(c => c.Receive(It.IsAny <IEnumerable <int> >())) .Callback(() => { calls++; if (calls == 1) { throw new RpcException(Status.DefaultSuccess); } }); using (var retryConsumer = new RpcRetryConsumer <int>( mockConsumer.Object, options, Utils.ConstantSizer <int> .GetSize, timerFactory)) { int[] intArray = { 1, 2, 3, 4 }; retryConsumer.Receive(intArray); timer.Call(); // Extra call to ensure buffer is emptied. timer.Call(); mockConsumer.Verify(c => c.Receive(intArray), Times.Exactly(2)); } }
public void Receive() { var options = RetryOptions.NoRetry(ExceptionHandling.Propagate); var mockConsumer = new Mock <IConsumer <int> >(); Func <Action, RetryOptions, ISequentialThreadingTimer> timerFactory = (callback, retryOptions) => new SequentialThreadingTimer(); using (var retryConsumer = new RpcRetryConsumer <int>( mockConsumer.Object, options, Utils.ConstantSizer <int> .GetSize, timerFactory)) { int[] intArray = { 1, 2, 3, 4 }; retryConsumer.Receive(intArray); mockConsumer.Verify(c => c.Receive(intArray), Times.Once); } }