예제 #1
0
        public void CountSubscriptionsForIsCorrect()
        {
            var messenger = new MvxMessengerHub();

            Assert.AreEqual(false, messenger.HasSubscriptionsFor <MvxSubscriberChangeMessage>());
            Assert.AreEqual(false, messenger.HasSubscriptionsFor <TestMessage>());
            var changeToken = messenger.Subscribe <MvxSubscriberChangeMessage>(message => { });

            Assert.AreEqual(1, messenger.CountSubscriptionsFor <MvxSubscriberChangeMessage>());
            Assert.AreEqual(0, messenger.CountSubscriptionsFor <TestMessage>());
            var token = messenger.Subscribe <TestMessage>(m =>
            {
                // stuff
            });

            Assert.AreEqual(1, messenger.CountSubscriptionsFor <MvxSubscriberChangeMessage>());
            Assert.AreEqual(1, messenger.CountSubscriptionsFor <TestMessage>());
            var token2 = messenger.Subscribe <TestMessage>(m =>
            {
                // stuff
            });

            Assert.AreEqual(1, messenger.CountSubscriptionsFor <MvxSubscriberChangeMessage>());
            Assert.AreEqual(2, messenger.CountSubscriptionsFor <TestMessage>());
            messenger.Unsubscribe <TestMessage>(token);
            Assert.AreEqual(1, messenger.CountSubscriptionsFor <MvxSubscriberChangeMessage>());
            Assert.AreEqual(1, messenger.CountSubscriptionsFor <TestMessage>());
            messenger.Unsubscribe <TestMessage>(token2);
            Assert.AreEqual(1, messenger.CountSubscriptionsFor <MvxSubscriberChangeMessage>());
            Assert.AreEqual(0, messenger.CountSubscriptionsFor <TestMessage>());
        }
예제 #2
0
 public void CountSubscriptionsForIsCorrect()
 {
     var messenger = new MvxMessengerHub();
     Assert.AreEqual(false, messenger.HasSubscriptionsFor<MvxSubscriberChangeMessage>());
     Assert.AreEqual(false, messenger.HasSubscriptionsFor<TestMessage>());
     var changeToken = messenger.Subscribe<MvxSubscriberChangeMessage>(message => { });
     Assert.AreEqual(1, messenger.CountSubscriptionsFor<MvxSubscriberChangeMessage>());
     Assert.AreEqual(0, messenger.CountSubscriptionsFor<TestMessage>());
     var token = messenger.Subscribe<TestMessage>(m =>
     {
         // stuff
     });
     Assert.AreEqual(1, messenger.CountSubscriptionsFor<MvxSubscriberChangeMessage>());
     Assert.AreEqual(1, messenger.CountSubscriptionsFor<TestMessage>());
     var token2 = messenger.Subscribe<TestMessage>(m =>
     {
         // stuff
     });
     Assert.AreEqual(1, messenger.CountSubscriptionsFor<MvxSubscriberChangeMessage>());
     Assert.AreEqual(2, messenger.CountSubscriptionsFor<TestMessage>());
     messenger.Unsubscribe<TestMessage>(token);
     Assert.AreEqual(1, messenger.CountSubscriptionsFor<MvxSubscriberChangeMessage>());
     Assert.AreEqual(1, messenger.CountSubscriptionsFor<TestMessage>());
     messenger.Unsubscribe<TestMessage>(token2);
     Assert.AreEqual(1, messenger.CountSubscriptionsFor<MvxSubscriberChangeMessage>());
     Assert.AreEqual(0, messenger.CountSubscriptionsFor<TestMessage>());
 }