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); }
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); }
public void NullActionIsNotAllowedForSetTimeout() { Debouncer.SetTimeout(null, 10); }
public void NullActionIsNotAllowedForSetTimeout() { Assert.Throws <ArgumentNullException>(() => Debouncer.SetTimeout(null, 10)); }