public NotificationSender(INotificationTemplateRenderer notificationTemplateRender , INotificationMessageService notificationMessageService , ILogger <NotificationSender> logger , INotificationMessageSenderProviderFactory notificationMessageAccessor) { _notificationTemplateRender = notificationTemplateRender; _notificationMessageService = notificationMessageService; _notificationMessageAccessor = notificationMessageAccessor; _logger = logger; }
public async Task SmtpEmailNotificationMessageSender_SuccessSentMessage() { //Arrange string number = Guid.NewGuid().ToString(); string subject = "Order #{{customer_order.number}}"; string body = "You have order #{{customer_order.number}}"; var notification = new OrderSentEmailNotification() { CustomerOrder = new CustomerOrder() { Number = number }, From = "*****@*****.**", To = "*****@*****.**", Templates = new List <NotificationTemplate>() { new EmailNotificationTemplate() { Subject = subject, Body = body, } }, TenantIdentity = new TenantIdentity(null, null) }; _serviceMock.Setup(serv => serv.GetByTypeAsync(nameof(OrderSentEmailNotification), null, null, null)).ReturnsAsync(notification); _emailSendingOptionsMock.Setup(opt => opt.Value).Returns(_emailSendingOptions); _messageSender = new SmtpEmailNotificationMessageSender(_emailSendingOptionsMock.Object); _notificationMessageSenderProviderFactory = new NotificationMessageSenderProviderFactory(new List <INotificationMessageSender>() { _messageSender }); _notificationMessageSenderProviderFactory.RegisterSenderForType <EmailNotification, SmtpEmailNotificationMessageSender>(); _notificationSender = new NotificationSender(_templateRender, _messageServiceMock.Object, _logNotificationSenderMock.Object, _notificationMessageSenderProviderFactory); //Act var result = await _notificationSender.SendNotificationAsync(notification, null); //Assert Assert.True(result.IsSuccess); }
public EmailNotificationMessageSender(INotificationMessageSenderProviderFactory notificationMessageSenderProviderFactory, IOptions <EmailSendingOptions> emailSendingOptions /*, IConfiguration configuration*/) { _notificationMessageSenderProviderFactory = notificationMessageSenderProviderFactory; _emailSendingOptions = emailSendingOptions.Value; }