Exemplo n.º 1
0
        public void MultipleSubscribersAreRemoved()
        {
            var manager = new GameEventsManager();
            int testVal = 0;

            Action <TestEvent> l1 = evt => testVal += evt.value;
            Action <TestEvent> l2 = evt => testVal += evt.value;

            manager.Subscribe(l1);
            manager.Subscribe(l2);
            manager.Unsubscribe(l1);
            manager.Unsubscribe(l2);
            manager.Invoke(new TestEvent(10));

            Assert.IsTrue(testVal == 0);
        }
Exemplo n.º 2
0
        public void SubscriberIsRemoved()
        {
            var manager = new GameEventsManager();
            int testVal = 0;

            Action <TestEvent> listener = evt => testVal = evt.value;

            manager.Subscribe(listener);
            manager.Unsubscribe(listener);
            manager.Invoke(new TestEvent(10));

            Assert.IsTrue(testVal == 0);
        }