public async Task Invoke_NotificationRequest_ShouldCallListener() { // Arrange var listener = new FakeNotificationListener(); ServiceProvider .Setup(s => s.GetService(typeof(IEnumerable <INotificationListener>))) .Returns(new[] { listener }); HttpRequest .SetupGet(r => r.Path) .Returns("/notifications"); var notificationBytes = Encoding.UTF8.GetBytes("{\"id\":\"1\",\"event\":\"received\"}"); RequestBody.Write(notificationBytes); RequestBody.Position = 0; var target = GetTarget(); // Act await target.Invoke(HttpContext.Object); // Assert listener.Envelopes.Count.ShouldBe(1); listener.Envelopes[0].Id.ShouldBe("1"); listener.Envelopes[0].Event.ShouldBe(Event.Received); }
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); }