Beispiel #1
0
        public void RateOfZeroAlwaysPurges()
        {
            int purgeCount = 0;
            var purger     = new RateLimitedPurger(new DummyPurger(() => { purgeCount++; }), 0);

            purger.Purge();
            purger.Purge();

            Assert.That(purgeCount, Is.EqualTo(2));
        }
Beispiel #2
0
        public void WaitsToPurge()
        {
            int purgeCount = 0;
            var purger     = new RateLimitedPurger(new DummyPurger(() => { purgeCount++; }), 1000);

            purger.Purge();
            Assert.That(purgeCount, Is.EqualTo(1));

            purger.Purge();
            Assert.That(purgeCount, Is.EqualTo(1));

            Thread.Sleep(1500);

            purger.Purge();
            Assert.That(purgeCount, Is.EqualTo(2));
        }
Beispiel #3
0
        public void AlwaysPurgesFirstTime()
        {
            int purgeCount = 0;
            var purger     = new RateLimitedPurger(new DummyPurger(() => { purgeCount++; }), 1000);

            purger.Purge();

            Assert.That(purgeCount, Is.EqualTo(1));
        }