Ejemplo n.º 1
0
 public void NullActionIsNotAllowedForSetInterval()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         Debouncer.SetInterval(null, 10);
     });
 }
Ejemplo n.º 2
0
        public void SetIntervalExecutesTheGivenActionAtAGivenInterval()
        {
            // target function
            var    counter = 0;
            Action inc     = () => counter++;

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

            Thread.Sleep(50);
            Assert.IsTrue(counter > 1);
        }
Ejemplo n.º 3
0
        public void SetIntervalCanBeCancelled()
        {
            // target function
            var    counter = 0;
            Action inc     = () => counter++;

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

            Assert.AreEqual(0, counter);

            Thread.Sleep(50);
            Assert.IsTrue(counter > 1);
            timer.Dispose();

            var lastCounter = counter;

            Thread.Sleep(50);
            Assert.AreEqual(lastCounter, counter);
        }
Ejemplo n.º 4
0
 public void NullActionIsNotAllowedForSetInterval()
 {
     Debouncer.SetInterval(null, 10);
 }