Ejemplo n.º 1
0
        public void CanRegisterLocalEventPublisher()
        {
            EventInspector.Register(new Mocks.LocalEventPublisher(), workItem);

            Assert.AreEqual(1, workItem.EventTopics.Count);
            Assert.AreEqual("LocalEvent", workItem.EventTopics.Get("LocalEvent").Name);
            Assert.AreEqual(1, workItem.EventTopics.Get("LocalEvent").PublicationCount);
        }
Ejemplo n.º 2
0
 protected virtual void OnCreatedChannel(object sender, EventArgs <IChannel> e)
 {
     if (CreatedChannel != null)
     {
         EventInspector.Register(e.Data, workItem);
         CreatedChannel(sender, e);
     }
 }
Ejemplo n.º 3
0
        public void CanRegisterGlobalEventPublisher()
        {
            EventTopic handle = new EventTopic();

            EventInspector.Register(new Mocks.GlobalEventPublisher(), workItem);

            Assert.AreEqual(1, workItem.EventTopics.Count);
            Assert.AreEqual("GlobalEvent", workItem.EventTopics.Get("GlobalEvent").Name);
            Assert.AreEqual(1, workItem.EventTopics.Get("GlobalEvent").PublicationCount);
        }
        /// <summary>
        /// Forwards the <see cref="EventTopic"/> related attributes processing to the <see cref="EventInspector"/>
        /// for registering publishers and/or subscribers.
        /// </summary>
        public override object BuildUp(IBuilderContext context, Type t, object existing, string id)
        {
            WorkItem workItem = GetWorkItem(context, existing);

            if (workItem != null)
            {
                EventInspector.Register(existing, workItem);
            }

            return(base.BuildUp(context, t, existing, id));
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public void CanRegisterObject()
        {
            EventInspector.Register(new object(), workItem);

            Assert.AreEqual(0, workItem.EventTopics.Count);
        }
Ejemplo n.º 7
0
 public void CannotRegisterNullObject()
 {
     EventInspector.Register(null, workItem);
 }
Ejemplo n.º 8
0
        public void CanRegisterObjectWithOverloadedMethodes()
        {
            EventInspector.Register(new subA(), workItem);

            Assert.AreEqual(1, workItem.EventTopics.Count);
        }