Exemplo n.º 1
0
        public void Create_SlidingWindow()
        {
            var options   = new SlidingWindowRateLimiterOptions(1, QueueProcessingOrder.OldestFirst, 10, TimeSpan.FromSeconds(33), 3, true);
            var partition = RateLimitPartition.CreateSlidingWindowLimiter(1, key => options);

            var limiter = partition.Factory(1);
            var slidingWindowLimiter = Assert.IsType <SlidingWindowRateLimiter>(limiter);

            Assert.Equal(options.PermitLimit, slidingWindowLimiter.GetAvailablePermits());
            Assert.Equal(TimeSpan.FromSeconds(11), slidingWindowLimiter.ReplenishmentPeriod);
            Assert.False(slidingWindowLimiter.IsAutoReplenishing);
        }