Ejemplo n.º 1
0
        public void RemoveFuncFromListenerThatDoesNotExistFails()
        {
            var e = new EventEmitter();

            Assert.That(() => e.RemoveListener("data", IncrementNumberBy2),
                        Throws.Exception
                        .TypeOf <DoesNotExistException>()
                        .With.Message.EqualTo("Event [data] does not exist to have listeners removed."));
        }
Ejemplo n.º 2
0
        public void ThrowsWhenRemovingFuncThatDoesNotExist()
        {
            var e = new EventEmitter();

            e.On("test_event", TestMethod);
            Assert.That(() => e.RemoveListener("test_event", IncrementNumber),
                        Throws.Exception
                        .TypeOf <DoesNotExistException>()
                        .With.Message.EqualTo("Func [Void IncrementNumber(System.Object)] does not exist to be removed."));
        }
Ejemplo n.º 3
0
        public void RemoveListenerRemovesFunction()
        {
            var e = new EventEmitter();

            numberToTest = 0;
            e.On("data", IncrementNumber);
            e.On("data", IncrementNumberBy2);
            e.RemoveListener("data", IncrementNumberBy2);
            e.Emit("data", numberToTest);
            Assert.AreEqual(1, numberToTest);
        }
Ejemplo n.º 4
0
        public void RemoveAllListenersRemovesListeners()
        {
            var e = new EventEmitter();

            numberToTest = 0;
            e.On("data", IncrementNumber);
            e.On("data", IncrementNumberBy2);
            e.RemoveAllListeners("data");
            Assert.That(() => e.RemoveListener("data", IncrementNumberBy2),
                        Throws.Exception
                        .TypeOf <DoesNotExistException>()
                        .With.Message.EqualTo("Func [Void IncrementNumberBy2(System.Object)] does not exist to be removed."));
        }
Ejemplo n.º 5
0
 private void Destroy()
 {
     if (toDestroy == null)
     {
         toDestroy = gameObject;
     }
     if (emitter != null)
     {
         emitter.RemoveListener <AbilityHit>(OnHit);
     }
     emitter   = null;
     destroyed = true;
     Destroy(toDestroy);
 }