예제 #1
0
 public void HasSubscriptionsForTagIsCorrect()
 {
     var testTag = "TestTag";
     var notExistingTag = "NotExistingTag";
     var messenger = new MvxMessengerHub();
     Assert.AreEqual(false, messenger.HasSubscriptionsFor<MvxSubscriberChangeMessage>());
     Assert.AreEqual(false, messenger.HasSubscriptionsForTag<MvxSubscriberChangeMessage>(testTag));
     Assert.AreEqual(false, messenger.HasSubscriptionsFor<TestMessage>());
     Assert.AreEqual(false, messenger.HasSubscriptionsForTag<TestMessage>(null));
     Assert.AreEqual(false, messenger.HasSubscriptionsForTag<TestMessage>(notExistingTag));
     var changeToken = messenger.Subscribe<MvxSubscriberChangeMessage>(message => { });
     Assert.AreEqual(true, messenger.HasSubscriptionsForTag<MvxSubscriberChangeMessage>(null));
     Assert.AreEqual(false, messenger.HasSubscriptionsForTag<MvxSubscriberChangeMessage>(testTag));
     Assert.AreEqual(false, messenger.HasSubscriptionsForTag<TestMessage>(testTag));
     Assert.AreEqual(false, messenger.HasSubscriptionsForTag<TestMessage>(null));
     Assert.AreEqual(false, messenger.HasSubscriptionsForTag<TestMessage>(notExistingTag));
     var token = messenger.Subscribe<TestMessage>(m =>
     {
         // stuff
     }, tag: testTag);
     Assert.AreEqual(true, messenger.HasSubscriptionsForTag<MvxSubscriberChangeMessage>(null));
     Assert.AreEqual(false, messenger.HasSubscriptionsForTag<MvxSubscriberChangeMessage>(testTag));
     Assert.AreEqual(true, messenger.HasSubscriptionsForTag<TestMessage>(testTag));
     Assert.AreEqual(false, messenger.HasSubscriptionsForTag<TestMessage>(null));
     Assert.AreEqual(false, messenger.HasSubscriptionsForTag<TestMessage>(notExistingTag));
     messenger.Unsubscribe<TestMessage>(token);
     Assert.AreEqual(true, messenger.HasSubscriptionsForTag<MvxSubscriberChangeMessage>(null));
     Assert.AreEqual(false, messenger.HasSubscriptionsForTag<MvxSubscriberChangeMessage>(testTag));
     Assert.AreEqual(false, messenger.HasSubscriptionsForTag<TestMessage>(testTag));
     Assert.AreEqual(false, messenger.HasSubscriptionsForTag<TestMessage>(null));
     Assert.AreEqual(false, messenger.HasSubscriptionsForTag<TestMessage>(notExistingTag));
 }
예제 #2
0
        public void HasSubscriptionsForTagIsCorrect()
        {
            var testTag        = "TestTag";
            var notExistingTag = "NotExistingTag";
            var messenger      = new MvxMessengerHub();

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

            Assert.AreEqual(true, messenger.HasSubscriptionsForTag <MvxSubscriberChangeMessage>(null));
            Assert.AreEqual(false, messenger.HasSubscriptionsForTag <MvxSubscriberChangeMessage>(testTag));
            Assert.AreEqual(false, messenger.HasSubscriptionsForTag <TestMessage>(testTag));
            Assert.AreEqual(false, messenger.HasSubscriptionsForTag <TestMessage>(null));
            Assert.AreEqual(false, messenger.HasSubscriptionsForTag <TestMessage>(notExistingTag));
            var token = messenger.Subscribe <TestMessage>(m =>
            {
                // stuff
            }, tag: testTag);

            Assert.AreEqual(true, messenger.HasSubscriptionsForTag <MvxSubscriberChangeMessage>(null));
            Assert.AreEqual(false, messenger.HasSubscriptionsForTag <MvxSubscriberChangeMessage>(testTag));
            Assert.AreEqual(true, messenger.HasSubscriptionsForTag <TestMessage>(testTag));
            Assert.AreEqual(false, messenger.HasSubscriptionsForTag <TestMessage>(null));
            Assert.AreEqual(false, messenger.HasSubscriptionsForTag <TestMessage>(notExistingTag));
            messenger.Unsubscribe <TestMessage>(token);
            Assert.AreEqual(true, messenger.HasSubscriptionsForTag <MvxSubscriberChangeMessage>(null));
            Assert.AreEqual(false, messenger.HasSubscriptionsForTag <MvxSubscriberChangeMessage>(testTag));
            Assert.AreEqual(false, messenger.HasSubscriptionsForTag <TestMessage>(testTag));
            Assert.AreEqual(false, messenger.HasSubscriptionsForTag <TestMessage>(null));
            Assert.AreEqual(false, messenger.HasSubscriptionsForTag <TestMessage>(notExistingTag));
        }