public void When_object_has_multiple_listeners_should_subscribe_to_all()
        {
            var eventAggregator = new EventAggregator();
            var handler         = new SomeMessageHandler2();

            eventAggregator.AddListener(handler);
            eventAggregator.SendMessage <SomeMessage>();
            eventAggregator.SendMessage <SomeMessage2>();

            handler.EventsTrapped.Count().ShouldEqual(2);
        }
        public void Can_remove_a_good_listener_with_a_zombied_listener()
        {
            var eventAggregator = new EventAggregator();

            SomeMessageHandler2 messageHandler2 = new SomeMessageHandler2();

            AddHandlerInScopeThatWillRemoveInstanceWhenGarbageCollected(eventAggregator, false);
            eventAggregator.AddListener(messageHandler2);
            GC.Collect();

            // both good and zombied listeners
            eventAggregator.GetListeners().Count().ShouldEqual(2);

            // should not throw if removing a good listener
            eventAggregator.RemoveListener(messageHandler2);

            // should be only zombie left
            eventAggregator.GetListeners().Count().ShouldEqual(1);
            eventAggregator.SendMessage <SomeMessage>();

            // after call to SendMessage, the zombied listener should be removed.
            eventAggregator.GetListeners().Count().ShouldEqual(0);
        }