示例#1
0
        public void Dispose_Unsubscribes_All_Registered_Subscribers()
        {
            var messageChannel = new MessageChannel();

            var subscriber1 = messageChannel.Subscribe <string>();
            var subscriber2 = messageChannel.Subscribe <int>();
            var subscriber3 = messageChannel.Subscribe <object>();
            var subscriber4 = messageChannel.Subscribe <object>();

            messageChannel.Dispose();

            Assert.False(messageChannel.IsSubscribed(subscriber1));
            Assert.False(messageChannel.IsSubscribed(subscriber2));
            Assert.False(messageChannel.IsSubscribed(subscriber3));
            Assert.False(messageChannel.IsSubscribed(subscriber4));
        }
示例#2
0
        public void IsSubscribed_Returns_True_If_Subscriber_Is_Subscribed()
        {
            var messageChannel = new MessageChannel();

            var subscriber = messageChannel.Subscribe <string>();

            Assert.True(messageChannel.IsSubscribed(subscriber));
        }
示例#3
0
        public void IsSubscribed_Returns_False_If_Subscribers_MessageType_IsNull()
        {
            var mockSubscriber = new Mock <ISubscriber>();

            var messageChannel = new MessageChannel();

            Assert.False(messageChannel.IsSubscribed(mockSubscriber.Object));
        }
示例#4
0
        public void IsSubscribed_Returns_False_If_Subscriber_IsNot_Subscribed()
        {
            var mockSubscriber = new Mock <ISubscriber>();

            mockSubscriber.SetupGet(x => x.MessageType).Returns(typeof(string));

            var messageChannel = new MessageChannel();

            Assert.False(messageChannel.IsSubscribed(mockSubscriber.Object));
        }
示例#5
0
        public void IsSubscribed_Returns_False_If_Subscriber_Is_Null()
        {
            var messageChannel = new MessageChannel();

            Assert.False(messageChannel.IsSubscribed(null));
        }