Beispiel #1
0
        public void GetChannel_Throws_KeyNotFoundException_If_Channel_Is_Not_Registered()
        {
            const string notRegisteredChannelId = nameof(notRegisteredChannelId);

            var mockMessageChannel = new Mock<IMessageChannel>();

            IMessageChannel MessageBusFactory(string channelId) => mockMessageChannel.Object;

            var messageBus = new MessageBus(MessageBusFactory);

            Assert.Throws<KeyNotFoundException>(() => messageBus.GetChannel(null));
            Assert.Throws<KeyNotFoundException>(() => messageBus.GetChannel(string.Empty));
            Assert.Throws<KeyNotFoundException>(() => messageBus.GetChannel(notRegisteredChannelId));
        }
Beispiel #2
0
        public void GetChannel_Returns_Registerd_Channel()
        {
            const string registeredChannelId = nameof(registeredChannelId);

            var mockMessageChannel = new Mock<IMessageChannel>();

            IMessageChannel MessageBusFactory(string channelId) => mockMessageChannel.Object;

            var messageBus = new MessageBus(MessageBusFactory);

            messageBus.RegisterChannel(registeredChannelId);

            Assert.Equal(mockMessageChannel.Object, messageBus.GetChannel(registeredChannelId));
        }