public async Task Invoke_MessageRequest_ShouldCallListener()
        {
            // Arrange
            var listener = new FakeMessageListener();

            ServiceProvider
            .Setup(s => s.GetService(typeof(IEnumerable <IMessageListener>)))
            .Returns(new[] { listener });
            HttpRequest
            .SetupGet(r => r.Path)
            .Returns("/messages");
            var messageBytes = Encoding.UTF8.GetBytes("{\"type\":\"text/plain\",\"content\":\"Hello world!\"}");

            RequestBody.Write(messageBytes);
            RequestBody.Position = 0;

            var target = GetTarget();

            // Act
            await target.Invoke(HttpContext.Object);

            // Assert
            listener.Envelopes.Count.ShouldBe(1);
            listener.Envelopes[0].Type.ToString().ShouldBe("text/plain");
            listener.Envelopes[0].Content.ToString().ShouldBe("Hello world!");
        }
        public void SetUp()
        {
            base.SetUp();

            MessageListener  = new FakeMessageListener();
            MessageListeners = new List <FakeMessageListener>();
            MessageListeners.Add(MessageListener);
            ServiceProvider
            .Setup(s => s.GetService(typeof(IEnumerable <IMessageListener>)))
            .Returns(() => MessageListeners);
            NotificationListener  = new FakeNotificationListener();
            NotificationListeners = new List <FakeNotificationListener>();
            NotificationListeners.Add(NotificationListener);
            ServiceProvider
            .Setup(s => s.GetService(typeof(IEnumerable <INotificationListener>)))
            .Returns(() => NotificationListeners);
            CommandListener  = new FakeCommandListener();
            CommandListeners = new List <FakeCommandListener>();
            CommandListeners.Add(CommandListener);
            ServiceProvider
            .Setup(s => s.GetService(typeof(IEnumerable <ICommandListener>)))
            .Returns(() => CommandListeners);
        }