/// <summary>
        /// Forwards the <see cref="EventTopic"/> related attributes processing to the <see cref="EventInspector"/>
        /// for unregistering publishers and/or subscribers.
        /// </summary>
        public override object TearDown(IBuilderContext context, object item)
        {
            WorkItem workItem = GetWorkItem(context, item);

            if (workItem != null)
            {
                EventInspector.Unregister(item, workItem);
            }

            return(base.TearDown(context, item));
        }
Ejemplo n.º 2
0
        public void EmptyTopicsGetsUnregistered()
        {
            EventTopic topic = new EventTopic();

            workItem.EventTopics.Add(topic, "GlobalEvent");
            Mocks.GlobalEventPublisher publisher  = new Mocks.GlobalEventPublisher();
            Mocks.GlobalEventHandler   subscriber = new Mocks.GlobalEventHandler();

            EventInspector.Register(publisher, workItem);
            Assert.AreEqual(1, topic.PublicationCount);

            EventInspector.Register(subscriber, workItem);
            Assert.AreEqual(1, topic.SubscriptionCount);

            EventInspector.Unregister(publisher, workItem);
            Assert.AreEqual(0, topic.PublicationCount);
            Assert.AreEqual(1, topic.SubscriptionCount);

            EventInspector.Unregister(subscriber, workItem);
            Assert.AreEqual(0, topic.PublicationCount);
            Assert.AreEqual(0, topic.SubscriptionCount);
        }