Bert.RateLimiters.Tests.RollingWindowThrottlerTests.ShouldThrottle_WhenCalledAndConsumingAllTokensAtOnceAndThenCalledOnceMoreAfterRollingWindowEnd_WillReturnFalse C# (CSharp) Метод

ShouldThrottle_WhenCalledAndConsumingAllTokensAtOnceAndThenCalledOnceMoreAfterRollingWindowEnd_WillReturnFalse() приватный Метод

        public void ShouldThrottle_WhenCalledAndConsumingAllTokensAtOnceAndThenCalledOnceMoreAfterRollingWindowEnd_WillReturnFalse()
        {
            SystemTime.SetCurrentTimeUtc = () => referenceTime;
            var virtualNow = SystemTime.UtcNow;

            var throttler = new RollingWindowThrottler(3, TimeSpan.FromSeconds(1));
            long waitTimeMillis;
            var shouldThrottle = throttler.ShouldThrottle(3, out waitTimeMillis);
            shouldThrottle.ShouldBeFalse();

            SystemTime.SetCurrentTimeUtc = () => virtualNow.AddSeconds(1.1);
            shouldThrottle = throttler.ShouldThrottle(3, out waitTimeMillis);
            shouldThrottle.ShouldBeFalse();
            waitTimeMillis.ShouldEqual(0);
        }