Example #1
0
        public void TestSubscribeWithIDWithArg()
        {
            var subscriber = new MockSubscriber();
            var sender     = new MockSenderWithID();

            Messenger.Subscribe <MockArgs> (subscriber, sender, subscriber.HandleMessage);
            var countBefore = subscriber.MessagesReceived;

            Messenger.Send(sender, new MockArgs());

            Assert.AreEqual(0, countBefore);
            Assert.AreEqual(1, subscriber.MessagesReceived);
        }
Example #2
0
        public void TestUnsubscribeWithIDWithArg()
        {
            var unsubscriber = new MockSubscriber();
            var sender       = new MockSenderWithID();

            Messenger.Subscribe <MockArgs> (unsubscriber, sender, unsubscriber.HandleMessage);
            var countAfterSubscribe = unsubscriber.MessagesReceived;

            Messenger.Send(sender, new MockArgs());
            var countAfterSend = unsubscriber.MessagesReceived;

            Messenger.Unsubscribe <MockArgs> (unsubscriber, sender);
            Messenger.Send(sender, new MockArgs());

            Assert.AreEqual(0, countAfterSubscribe);
            Assert.AreEqual(1, countAfterSend);
            Assert.AreEqual(1, unsubscriber.MessagesReceived);
        }