Exemple #1
0
        private void Callback6(Notification notification)
        {
            List <String> result = notification.data as List <String>;

            result.Add("Callback6");

            notifications.Post(this, "name2", result);
        }
Exemple #2
0
        public void TestPost2()
        {
            TimerManager timerManager = new TimerManager();

            List <String> result = new List <String>();

            notifications = new NotificationCenter(timerManager);
            notifications.Register("name1", Callback1);
            notifications.Register("name2", Callback2);
            notifications.Register("name3", Callback3);

            notifications.Post(this, "name1", result);
            notifications.Post(this, "name1", result);
            notifications.Post(this, "name1", result);

            Check(result);
            Assert.AreEqual(timerManager.Count(), 3);

            timerManager.Update(0.016f);

            Check(result, "Callback1", "Callback1", "Callback1");
            Assert.AreEqual(timerManager.Count(), 0);
        }
        public void TestDestroy()
        {
            TimerManager timerManager = new TimerManager();

            List<String> result = new List<String>();

            notifications = new NotificationCenter(timerManager);
            notifications.Register("name1", Callback1);
            notifications.Register("name2", Callback2);
            notifications.Register("name3", Callback3);

            notifications.Post(this, "name1", result);
            notifications.Post(this, "name2", result);
            notifications.Post(this, "name3", result);

            Check(result);
            Assert.AreEqual(timerManager.Count(), 3);

            notifications.Destroy();
            Assert.AreEqual(timerManager.Count(), 0);

            timerManager.Update(0.016f);
            Check(result);
        }