Beispiel #1
0
        public void TriggerStaticEvent()
        {
            SimplePublisher publisher = (SimplePublisher)_container["SimplePublisher"];
            SimpleListener  listener  = (SimpleListener)_container["SimpleListener"];

            Assert.IsFalse(listener.Listened);
            Assert.IsNull(listener.Sender);

            publisher.Trigger();

            Assert.IsTrue(listener.Listened);
            Assert.AreSame(publisher, listener.Sender);
        }
Beispiel #2
0
        public void MultiEvents()
        {
            MultiListener     listener             = (MultiListener)_container["MultiListener"];
            MultiPublisher    publisher            = (MultiPublisher)_container["MultiPublisher"];
            PublisherListener publisherThatListens = (PublisherListener)_container["PublisherListener"];
            SimplePublisher   anotherPublisher     = (SimplePublisher)_container["SimplePublisher"];

            Assert.IsFalse(listener.Listened);
            Assert.IsNull(listener.Sender);

            publisher.Trigger1();

            Assert.IsTrue(listener.Listened);
            Assert.AreSame(publisher, listener.Sender);

            listener.Reset();

            publisher.Trigger2();

            Assert.IsTrue(listener.Listened);
            Assert.AreSame(publisher, listener.Sender);

            listener.Reset();

            publisherThatListens.Trigger1();

            Assert.IsTrue(listener.Listened);
            Assert.AreSame(publisherThatListens, listener.Sender);


            Assert.IsFalse(publisherThatListens.Listened);
            Assert.IsNull(publisherThatListens.Sender);

            anotherPublisher.Trigger();

            Assert.IsTrue(publisherThatListens.Listened);
            Assert.AreSame(anotherPublisher, publisherThatListens.Sender);
        }