Exemplo n.º 1
0
                public async Task Will_Retry_Up_To_Retry_Limit_And_Pause_Between_Each_Attempt()
                {
                    const int MaxRetries       = 3;
                    const int ExpectedAttempts = MaxRetries + 1;

                    var blockProcessingException = new RpcClientTimeoutException("fake exception");
                    int timesThrown = 0;

                    MockProcessingStrategy
                    .SetupGet(s => s.MaxRetries).Returns(MaxRetries);

                    MockBlockProcessor
                    .Setup(p => p.ProcessBlockAsync(0))
                    .Callback <long>((blkNum) => timesThrown++)
                    .Throws(blockProcessingException);

                    for (var retryNum = 0; retryNum < MaxRetries; retryNum++)
                    {
                        MockProcessingStrategy
                        .Setup(s => s.PauseFollowingAnError(retryNum))
                        .Returns(Task.CompletedTask);
                    }

                    await Processor.ExecuteAsync(0, 0);

                    Assert.Equal(ExpectedAttempts, timesThrown);
                    MockProcessingStrategy.VerifyAll();
                }
Exemplo n.º 2
0
                public async Task Last_Block_Processsed_Is_Only_Used_If_Greater_Than_Minimum_Block_Number()
                {
                    const long LastBlockProcessed   = 11;
                    const long MinimumStartingBlock = 20;
                    const long EndingBlock          = MinimumStartingBlock;

                    MockProcessingStrategy.SetupGet(s => s.MinimumBlockNumber).Returns(MinimumStartingBlock);

                    MockProcessingStrategy
                    .Setup(s => s.GetLastBlockProcessedAsync())
                    .ReturnsAsync(LastBlockProcessed);

                    MockBlockProcessor
                    .Setup(p => p.ProcessBlockAsync(MinimumStartingBlock))
                    .Returns(Task.CompletedTask);

                    await Processor.ExecuteAsync(startBlock : null, endBlock : EndingBlock);

                    MockProcessingStrategy.VerifyAll();
                    MockBlockProcessor.VerifyAll();
                }