Esempio n. 1
0
        public void TestDoubleMinValueCanAcquireExactlyOnce()
        {
            var stopwatch = new FakeStopwatch();
            var r         = RateLimiter.Create(stopwatch, Epsilon);

            Assert.IsTrue(r.TryAcquire(), "Unable to Acquire initial permit");
            Assert.IsFalse(r.TryAcquire(), "Capable of acquiring an additional permit");
            stopwatch.SleepMillis(int.MaxValue);
            Assert.IsFalse(r.TryAcquire(), "Capable of acquiring an additional permit after sleeping");
            stopwatch.ReadEventsAndClear();
        }
Esempio n. 2
0
 private void AssertEvents(FakeStopwatch stopwatch, params string[] events)
 {
     Assert.AreEqual(string.Join(", ", events), stopwatch.ReadEventsAndClear());
 }