示例#1
0
        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);
        }
示例#2
0
        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);
        }