示例#1
0
        public void test_global_events_fire()
        {
            GlobalEventStream.Reset();
            var listener  = new ListensToEvents();
            var listener2 = new ListensToEventsWithContext();

            GlobalEventStream.Trigger(new GlobalEvent());
            GlobalEventStream.Trigger(new GlobalEvent());

            Assert(listener.EventsHandled == 2);
            Assert(listener2.EventsHandled == 2);
            Assert(GlobalEventStream.EventsDispatched == 4);
        }
        public void test_global_events_fire()
        {
            GlobalEventStream.Reset();
              var listener = new ListensToEvents();
              var listener2 = new ListensToEventsWithContext();

              GlobalEventStream.Trigger(new GlobalEvent());
              GlobalEventStream.Trigger(new GlobalEvent());

              Assert(listener.EventsHandled == 2);
              Assert(listener2.EventsHandled == 2);
              Assert(GlobalEventStream.EventsDispatched == 4);
        }
示例#3
0
        public void test_when_object_expires_it_no_longer_receives_events()
        {
            GlobalEventStream.Reset();
            using (var listener = new ListensToEvents())
            {
                using (var listener2 = new ListensToEventsWithContext())
                {
                    GlobalEventStream.Trigger(new GlobalEvent());

                    Assert(listener2.EventsHandled == 1);
                    Assert(GlobalEventStream.EventsDispatched == 2);
                }

                GlobalEventStream.Trigger(new GlobalEvent());
                Assert(listener.EventsHandled == 2);
                Assert(GlobalEventStream.EventsDispatched == 3);
            }

            GlobalEventStream.Trigger(new GlobalEvent());
            Assert(GlobalEventStream.EventsDispatched == 3);
        }
        public void test_when_object_expires_it_no_longer_receives_events()
        {
            GlobalEventStream.Reset();
              using (var listener = new ListensToEvents())
              {
            using(var listener2 = new ListensToEventsWithContext())
            {
              GlobalEventStream.Trigger(new GlobalEvent());

              Assert(listener2.EventsHandled == 1);
              Assert(GlobalEventStream.EventsDispatched == 2);
            }

            GlobalEventStream.Trigger(new GlobalEvent());
            Assert(listener.EventsHandled == 2);
            Assert(GlobalEventStream.EventsDispatched == 3);
              }

              GlobalEventStream.Trigger(new GlobalEvent());
              Assert(GlobalEventStream.EventsDispatched == 3);
        }