Exemple #1
0
        public void SetTimeoutExecutesTheGivenActionAfterAnInterval()
        {
            // target function
            var    counter = 0;
            Action inc     = () => counter++;

            Debouncer.SetTimeout(inc, 10);
            Assert.AreEqual(0, counter);

            Thread.Sleep(50);
            Assert.AreEqual(1, counter);
        }
Exemple #2
0
        public void SetTimeoutCanBeCancelled()
        {
            // target function
            var    counter = 0;
            Action inc     = () => counter++;

            var timer = Debouncer.SetTimeout(inc, 10);

            Assert.AreEqual(0, counter);
            timer.Dispose();

            Thread.Sleep(50);
            Assert.AreEqual(0, counter);
        }
Exemple #3
0
 public void NullActionIsNotAllowedForSetTimeout()
 {
     Debouncer.SetTimeout(null, 10);
 }
Exemple #4
0
 public void NullActionIsNotAllowedForSetTimeout()
 {
     Assert.Throws <ArgumentNullException>(() => Debouncer.SetTimeout(null, 10));
 }