public void WhenCalled_SendTheMessageToMessageDispatcher() { // Arrange var excludedTemplatesId = new List <string>(); _repo.Setup(x => x.GetDisabledNotifications("organizationId")) .Returns(excludedTemplatesId); var templates = new List <NotificationTemplate> { new NotificationTemplate(EmailNotification.Instance, _event, false) }; _repo.Setup(x => x.GetNotificationTemplatesByNotificationEvent(_event, excludedTemplatesId)) .Returns(templates); var messageToSend = new NotificationMessage("subject", "body", _event); _messageGenerator.Setup(x => x.Generate(It.IsIn <NotificationTemplate>(templates), _notificationData)) .Returns(messageToSend); // Act _sut.Handle(_recipient, _event, _notificationData).Wait(); // Assert _messageDispatcher.Verify(x => x.Dispatch(It.IsAny <EmailNotification>(), messageToSend, _recipient)); }