コード例 #1
0
        public async Task WhenRateLimitIs1_AndBatchSizeIs1_AndBatchIsProcessedIn10Seconds_ThenDelayFor50Seconds()
        {
            var batchSize = 1;
            var behaviour = _behaviourBuilder.WithRateLimitPerMinute(1).Build();
            var batchProcessedIn10Seconds = BatchProcessedInSeconds(behaviour, batchSize, 10);

            using (var cancellationTokenSource = new CancellationTokenSource())
            {
                await behaviour.Invoke(context => context.Action(),
                                       new BatchContext { Action = batchProcessedIn10Seconds, TokenSource = cancellationTokenSource });
            }

            await _throttler.Received(1).Delay(Arg.Is <long>(50000));
        }