public NotificationSenderIntegrationTests() { _emailSendingOptions = new SmtpSenderOptions() { SmtpServer = "smtp.gmail.com", Port = 587, Login = "******", Password = "" }; _templateRender = new LiquidTemplateRenderer(); _messageServiceMock = new Mock <INotificationMessageService>(); _emailSendingOptionsMock = new Mock <IOptions <SmtpSenderOptions> >(); _serviceMock = new Mock <INotificationService>(); _repositoryMock = new Mock <INotificationRepository>(); _logNotificationSenderMock = new Mock <ILogger <NotificationSender> >(); _eventPulisherMock = new Mock <IEventPublisher>(); INotificationRepository RepositoryFactory() => _repositoryMock.Object; _notificationRegistrar = new NotificationService(RepositoryFactory, _eventPulisherMock.Object); if (!AbstractTypeFactory <NotificationTemplate> .AllTypeInfos.SelectMany(x => x.AllSubclasses).Contains(typeof(EmailNotificationTemplate))) { AbstractTypeFactory <NotificationTemplate> .RegisterType <EmailNotificationTemplate>().MapToType <NotificationTemplateEntity>(); } if (!AbstractTypeFactory <NotificationMessage> .AllTypeInfos.SelectMany(x => x.AllSubclasses).Contains(typeof(EmailNotificationMessage))) { AbstractTypeFactory <NotificationMessage> .RegisterType <EmailNotificationMessage>().MapToType <NotificationMessageEntity>(); } _notificationRegistrar.RegisterNotification <RegistrationEmailNotification>(); _notificationRegistrar.RegisterNotification <ResetPasswordEmailNotification>(); }
public NotificationSenderUnitTests() { _templateRender = new LiquidTemplateRenderer(); _messageServiceMock = new Mock <INotificationMessageService>(); _messageSenderMock = new Mock <INotificationMessageSender>(); _serviceMock = new Mock <INotificationService>(); _logNotificationSenderMock = new Mock <ILogger <NotificationSender> >(); _emailSendingOptionsMock = new Mock <IOptions <EmailSendingOptions> >(); _senderFactoryMock = new Mock <INotificationMessageSenderProviderFactory>(); _smtpEmailNotificationMessageSenderMock = new Mock <SmtpEmailNotificationMessageSender>(_emailSendingOptionsMock.Object); _senderFactoryMock.Setup(s => s.GetSenderForNotificationType(nameof(EmailNotification))).Returns(_messageSenderMock.Object); _sender = new NotificationSender(_templateRender, _messageServiceMock.Object, _logNotificationSenderMock.Object, _senderFactoryMock.Object); if (!AbstractTypeFactory <NotificationTemplate> .AllTypeInfos.SelectMany(x => x.AllSubclasses).Contains(typeof(EmailNotificationTemplate))) { AbstractTypeFactory <NotificationTemplate> .RegisterType <EmailNotificationTemplate>().MapToType <NotificationTemplateEntity>(); } if (!AbstractTypeFactory <NotificationMessage> .AllTypeInfos.SelectMany(x => x.AllSubclasses).Contains(typeof(EmailNotificationMessage))) { AbstractTypeFactory <NotificationMessage> .RegisterType <EmailNotificationMessage>().MapToType <NotificationMessageEntity>(); } }
public OrderModuleController( ICustomerOrderService customerOrderService , ICustomerOrderSearchService searchService , IStoreService storeService , IUniqueNumberGenerator numberGenerator , IPlatformMemoryCache platformMemoryCache , Func <IOrderRepository> repositoryFactory , ICustomerOrderBuilder customerOrderBuilder , IShoppingCartService cartService , IChangeLogSearchService changeLogSearchService , INotificationTemplateRenderer notificationTemplateRenderer , INotificationSearchService notificationSearchService , ICustomerOrderTotalsCalculator totalsCalculator) { _customerOrderService = customerOrderService; _searchService = searchService; _uniqueNumberGenerator = numberGenerator; _storeService = storeService; _platformMemoryCache = platformMemoryCache; _repositoryFactory = repositoryFactory; //_securityService = securityService; //_permissionScopeService = permissionScopeService; _customerOrderBuilder = customerOrderBuilder; _cartService = cartService; _changeLogSearchService = changeLogSearchService; _notificationTemplateRenderer = notificationTemplateRenderer; _notificationSearchService = notificationSearchService; _totalsCalculator = totalsCalculator; }
public OrderModuleController( ICustomerOrderService customerOrderService , ICustomerOrderSearchService searchService , IStoreService storeService , IUniqueNumberGenerator numberGenerator , IPlatformMemoryCache platformMemoryCache , Func <IOrderRepository> repositoryFactory , ICustomerOrderBuilder customerOrderBuilder , IShoppingCartService cartService , IChangeLogSearchService changeLogSearchService , INotificationTemplateRenderer notificationTemplateRenderer , INotificationSearchService notificationSearchService , ICustomerOrderTotalsCalculator totalsCalculator , IAuthorizationService authorizationService , IConverter converter , IOptions <HtmlToPdfOptions> htmlToPdfOptions , IOptions <MvcNewtonsoftJsonOptions> jsonOptionsAccessor) { _customerOrderService = customerOrderService; _searchService = searchService; _uniqueNumberGenerator = numberGenerator; _storeService = storeService; _platformMemoryCache = platformMemoryCache; _repositoryFactory = repositoryFactory; _customerOrderBuilder = customerOrderBuilder; _cartService = cartService; _changeLogSearchService = changeLogSearchService; _notificationTemplateRenderer = notificationTemplateRenderer; _notificationSearchService = notificationSearchService; _totalsCalculator = totalsCalculator; _authorizationService = authorizationService; _htmlToPdfOptions = htmlToPdfOptions.Value; _converter = converter; _jsonOptions = jsonOptionsAccessor.Value; }
public NotificationsController(INotificationSearchService notificationSearchService , INotificationService notificationService , INotificationTemplateRenderer notificationTemplateRender ) { _notificationSearchService = notificationSearchService; _notificationService = notificationService; _notificationTemplateRender = notificationTemplateRender; }
public NotificationSender(INotificationTemplateRenderer notificationTemplateRender , INotificationMessageService notificationMessageService , ILogger <NotificationSender> logger , INotificationMessageSenderProviderFactory notificationMessageAccessor) { _notificationTemplateRender = notificationTemplateRender; _notificationMessageService = notificationMessageService; _notificationMessageAccessor = notificationMessageAccessor; _logger = logger; }
public NotificationSender(INotificationTemplateRenderer notificationTemplateRender , INotificationMessageService notificationMessageService , INotificationMessageSenderFactory notificationMessageAccessor , IBackgroundJobClient jobClient) { _notificationTemplateRender = notificationTemplateRender; _notificationMessageService = notificationMessageService; _notificationMessageSenderFactory = notificationMessageAccessor; _jobClient = jobClient; }
public override NotificationMessage ToMessage(NotificationMessage message, INotificationTemplateRenderer render) { var smsNotificationMessage = (SmsNotificationMessage)message; var template = (SmsNotificationTemplate)Templates.FindWithLanguage(message.LanguageCode); if (template != null) { smsNotificationMessage.Message = render.Render(template.Message, this); } smsNotificationMessage.Number = Number; return(base.ToMessage(message, render)); }
public override async Task ToMessageAsync(NotificationMessage message, INotificationTemplateRenderer render) { await base.ToMessageAsync(message, render); var smsNotificationMessage = (SmsNotificationMessage)message; var template = (SmsNotificationTemplate)Templates.FindTemplateForLanguage(message.LanguageCode); if (template != null) { smsNotificationMessage.Message = await render.RenderAsync(template.Message, this, template.LanguageCode); } smsNotificationMessage.Number = Number; }
public virtual Task ToMessageAsync(NotificationMessage message, INotificationTemplateRenderer render) { message.TenantIdentity = new TenantIdentity(TenantIdentity?.Id, TenantIdentity?.Type); message.NotificationType = Type; message.NotificationId = Id; message.LanguageCode = LanguageCode; message.LastSendError = CustomValidationError ?? message.LastSendError; if (!string.IsNullOrEmpty(CustomValidationError)) { message.Status = NotificationMessageStatus.Error; } return(Task.CompletedTask); }
public override NotificationMessage ToMessage(NotificationMessage message, INotificationTemplateRenderer render) { var emailMessage = (EmailNotificationMessage)message; var template = (EmailNotificationTemplate)Templates.FindWithLanguage(message.LanguageCode); if (template != null) { emailMessage.Subject = render.Render(template.Subject, this); emailMessage.Body = render.Render(template.Body, this); emailMessage.From = From; emailMessage.To = To; emailMessage.CC = CC; emailMessage.BCC = BCC; emailMessage.Attachments = Attachments; } return(base.ToMessage(message, render)); }
public override async Task ToMessageAsync(NotificationMessage message, INotificationTemplateRenderer render) { await base.ToMessageAsync(message, render); var emailMessage = (EmailNotificationMessage)message; var template = (EmailNotificationTemplate)Templates.FindTemplateForLanguage(message.LanguageCode); if (template != null) { emailMessage.Subject = await render.RenderAsync(template.Subject, this, template.LanguageCode); emailMessage.Body = await render.RenderAsync(template.Body, this, template.LanguageCode); } emailMessage.From = From; emailMessage.To = To; emailMessage.CC = CC; emailMessage.BCC = BCC; emailMessage.Attachments = Attachments; }
public NotificationSenderIntegrationTests() { _emailSendingOptions = new SmtpSenderOptions() { SmtpServer = "smtp.gmail.com", Port = 587, Login = "******", Password = "******" }; _templateRender = new LiquidTemplateRenderer(); _messageServiceMock = new Mock <INotificationMessageService>(); _emailSendingOptionsMock = new Mock <IOptions <SmtpSenderOptions> >(); _serviceMock = new Mock <INotificationService>(); _repositoryMock = new Mock <INotificationRepository>(); _logNotificationSenderMock = new Mock <ILogger <NotificationSender> >(); _eventPulisherMock = new Mock <IEventPublisher>(); INotificationRepository RepositoryFactory() => _repositoryMock.Object; _notificationRegistrar = new NotificationService(RepositoryFactory, _eventPulisherMock.Object); //todo if (!AbstractTypeFactory <Notification> .AllTypeInfos.Any(t => t.IsAssignableTo(nameof(EmailNotification)))) { AbstractTypeFactory <Notification> .RegisterType <EmailNotification>().MapToType <NotificationEntity>(); } if (!AbstractTypeFactory <NotificationTemplate> .AllTypeInfos.Any(t => t.IsAssignableTo(nameof(EmailNotificationTemplate)))) { AbstractTypeFactory <NotificationTemplate> .RegisterType <EmailNotificationTemplate>().MapToType <NotificationTemplateEntity>(); } if (!AbstractTypeFactory <NotificationMessage> .AllTypeInfos.Any(t => t.IsAssignableTo(nameof(EmailNotificationMessage)))) { AbstractTypeFactory <NotificationMessage> .RegisterType <EmailNotificationMessage>().MapToType <NotificationMessageEntity>(); } _notificationRegistrar.RegisterNotification <RegistrationEmailNotification>(); }
public NotificationSenderUnitTests() { _templateRender = new LiquidTemplateRenderer(Options.Create(new LiquidRenderOptions() { CustomFilterTypes = new HashSet <Type> { typeof(UrlFilters), typeof(TranslationFilter) } })); _messageServiceMock = new Mock <INotificationMessageService>(); _messageSenderMock = new Mock <INotificationMessageSender>(); _senderFactoryMock = new Mock <INotificationMessageSenderFactory>(); _senderFactoryMock.Setup(s => s.GetSender(It.IsAny <NotificationMessage>())).Returns(_messageSenderMock.Object); _backgroundJobClient = new Mock <IBackgroundJobClient>(); _sender = new NotificationSender(_templateRender, _messageServiceMock.Object, _senderFactoryMock.Object, _backgroundJobClient.Object); if (!AbstractTypeFactory <NotificationTemplate> .AllTypeInfos.SelectMany(x => x.AllSubclasses).Contains(typeof(EmailNotificationTemplate))) { AbstractTypeFactory <NotificationTemplate> .RegisterType <EmailNotificationTemplate>().MapToType <NotificationTemplateEntity>(); } if (!AbstractTypeFactory <NotificationMessage> .AllTypeInfos.SelectMany(x => x.AllSubclasses).Contains(typeof(EmailNotificationMessage))) { AbstractTypeFactory <NotificationMessage> .RegisterType <EmailNotificationMessage>().MapToType <NotificationMessageEntity>(); } if (!AbstractTypeFactory <NotificationScriptObject> .AllTypeInfos.SelectMany(x => x.AllSubclasses).Contains(typeof(NotificationScriptObject))) { AbstractTypeFactory <NotificationScriptObject> .RegisterType <NotificationScriptObject>() .WithFactory(() => new NotificationScriptObject(null, null)); } _notificationSearchServiceMock = new Mock <INotificationSearchService>(); _notificationRegistrar = new NotificationRegistrar(null); }
public NotificationSenderIntegrationTests() { var builder = new ConfigurationBuilder() .AddUserSecrets <NotificationSenderIntegrationTests>(); Configuration = builder.Build(); _emailSendingOptions = new SmtpSenderOptions() { SmtpServer = "smtp.gmail.com", // If use smtp.gmail.com then SSL is enabled and check https://www.google.com/settings/security/lesssecureapps Port = 587, Login = Configuration["SenderEmail"], Password = Configuration["SenderEmailPassword"], EnableSsl = true }; _templateRender = new LiquidTemplateRenderer(Options.Create(new LiquidRenderOptions() { CustomFilterTypes = new HashSet <Type> { typeof(UrlFilters), typeof(TranslationFilter) } })); _messageServiceMock = new Mock <INotificationMessageService>(); _emailSendingOptionsMock = new Mock <IOptions <SmtpSenderOptions> >(); _logNotificationSenderMock = new Mock <ILogger <NotificationSender> >(); _notificationServiceMock = new Mock <INotificationService>(); _notificationSearchServiceMock = new Mock <INotificationSearchService>(); _backgroundJobClient = new Mock <IBackgroundJobClient>(); _notificationRegistrar = new NotificationRegistrar(null); if (!AbstractTypeFactory <NotificationTemplate> .AllTypeInfos.SelectMany(x => x.AllSubclasses).Contains(typeof(EmailNotificationTemplate))) { AbstractTypeFactory <NotificationTemplate> .RegisterType <EmailNotificationTemplate>().MapToType <NotificationTemplateEntity>(); } if (!AbstractTypeFactory <NotificationMessage> .AllTypeInfos.SelectMany(x => x.AllSubclasses).Contains(typeof(EmailNotificationMessage))) { AbstractTypeFactory <NotificationMessage> .RegisterType <EmailNotificationMessage>().MapToType <NotificationMessageEntity>(); } if (!AbstractTypeFactory <NotificationTemplate> .AllTypeInfos.SelectMany(x => x.AllSubclasses).Contains(typeof(SmsNotificationTemplate))) { AbstractTypeFactory <NotificationTemplate> .RegisterType <SmsNotificationTemplate>().MapToType <NotificationTemplateEntity>(); } if (!AbstractTypeFactory <NotificationMessage> .AllTypeInfos.SelectMany(x => x.AllSubclasses).Contains(typeof(SmsNotificationMessage))) { AbstractTypeFactory <NotificationMessage> .RegisterType <SmsNotificationMessage>().MapToType <NotificationMessageEntity>(); } _notificationRegistrar.RegisterNotification <RegistrationEmailNotification>(); _notificationRegistrar.RegisterNotification <ResetPasswordEmailNotification>(); _notificationRegistrar.RegisterNotification <TwoFactorSmsNotification>(); if (!AbstractTypeFactory <NotificationScriptObject> .AllTypeInfos.SelectMany(x => x.AllSubclasses).Contains(typeof(NotificationScriptObject))) { AbstractTypeFactory <NotificationScriptObject> .RegisterType <NotificationScriptObject>() .WithFactory(() => new NotificationScriptObject(null, null)); } _emailSendingOptionsMock.Setup(opt => opt.Value).Returns(_emailSendingOptions); }