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 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 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); }