Пример #1
0
        public void IgnoresExceptions()
        {
            var target = new FilteringEventDispatcher();

            target.Subscribe(evt => { throw new Exception(); });
            target.Send(new Event());
        }
Пример #2
0
        public void CanFilterUsingTypeParameter()
        {
            var calls  = 0;
            var target = new FilteringEventDispatcher();

            target.On <Event>(e => calls++);
            target.Send(new Event());
            Assert.AreEqual(1, calls);
        }
Пример #3
0
        public void CanFilterUsingTypeExpression()
        {
            var target = new FilteringEventDispatcher();
            int calls  = 0;

            target.Subscribe(evt => calls++, evt => evt is Event);
            target.Send(new Event());
            Assert.AreEqual(1, calls);
        }
Пример #4
0
        public void CanRegisterGenericHandler()
        {
            var target = new FilteringEventDispatcher();
            int calls  = 0;

            target.Subscribe(evt => calls++);
            target.Send(new Event());
            Assert.AreEqual(1, calls);
        }
Пример #5
0
        public void CanFilter()
        {
            var target = new FilteringEventDispatcher();
            int calls  = 0;

            target.Subscribe(evt => calls++, evt => false);
            target.Send(new Event());
            Assert.AreEqual(0, calls);
        }
Пример #6
0
        public void CanUnregisterGenericHandler()
        {
            var             target  = new FilteringEventDispatcher();
            int             calls   = 0;
            Action <IEvent> handler = evt => calls++;

            target.Subscribe(handler);
            target.Send(new Event());
            Assert.AreEqual(1, calls);
            target.Unsubscribe(handler);
            calls = 0;
            target.Send(new Event());
            Assert.AreEqual(0, calls);
        }