public void RegisterTaskTest() { GameScheduler scheduler = new GameScheduler(); int sec = 2; scheduler.RegisterTask(TimedEvent, sec * 1000 * 1000); scheduler.RegisterTask(TimedEvent, sec * 1000 * 1000); scheduler.RegisterTask(TimedEvent, sec * 1000 * 1000); Thread.Sleep((sec + 1) * 1000); Assert.AreEqual(1, amountCalled); }
public void TestUnregisterOnMultipleListeners() { GameScheduler scheduler = new GameScheduler(); int sec = 2; scheduler.RegisterTask(TimedEvent, sec * 1000 * 1000); scheduler.RegisterTask(TimedEvent, sec * 1000 * 1000); scheduler.RegisterTask(TimedEvent, sec * 1000 * 1000); scheduler.UnregisterTask(TimedEvent); scheduler.UnregisterTask(TimedEvent); Thread.Sleep((sec * 2 + 1) * 1000); Assert.AreEqual(2, amountCalled); }