예제 #1
0
        public SocialNetworkNotificationEntityUnitTests()
        {
            _repositoryMock    = new Mock <INotificationRepository>();
            _repositoryFactory = () => _repositoryMock.Object;
            _mockUnitOfWork    = new Mock <IUnitOfWork>();
            _repositoryMock.Setup(ss => ss.UnitOfWork).Returns(_mockUnitOfWork.Object);
            _eventPublisherMock    = new Mock <IEventPublisher>();
            _notificationService   = new NotificationService(_repositoryFactory, _eventPublisherMock.Object);
            _notificationRegistrar = _notificationService;
            //todo
            if (!AbstractTypeFactory <Notification> .AllTypeInfos.Any(t => t.IsAssignableTo(nameof(SocialNetworkNotification))))
            {
                AbstractTypeFactory <Notification> .RegisterType <SocialNetworkNotification>().MapToType <NotificationEntity>();
            }

            if (!AbstractTypeFactory <NotificationTemplate> .AllTypeInfos.Any(t => t.IsAssignableTo(nameof(SocialNetworkTemplate))))
            {
                AbstractTypeFactory <NotificationTemplate> .RegisterType <SocialNetworkTemplate>().MapToType <NotificationTemplateEntity>();
            }

            if (!AbstractTypeFactory <NotificationMessage> .AllTypeInfos.Any(t => t.IsAssignableTo(nameof(SocialNetworkMessage))))
            {
                AbstractTypeFactory <NotificationMessage> .RegisterType <SocialNetworkMessage>().MapToType <NotificationMessageEntity>();
            }

            if (!AbstractTypeFactory <NotificationEntity> .AllTypeInfos.Any(t => t.IsAssignableTo(nameof(SocialNetworkNotificationEntity))))
            {
                AbstractTypeFactory <NotificationEntity> .RegisterType <SocialNetworkNotificationEntity>();
            }
        }
예제 #2
0
        public NotificationsExportImportManagerIntegrationTests()
        {
            _repositoryMock    = new Mock <INotificationRepository>();
            _eventPulisherMock = new Mock <IEventPublisher>();
            INotificationRepository RepositoryFactory() => _repositoryMock.Object;

            _mockUnitOfWork = new Mock <IUnitOfWork>();
            _repositoryMock.Setup(ss => ss.UnitOfWork).Returns(_mockUnitOfWork.Object);
            _notificationSearchService        = new NotificationSearchService(RepositoryFactory);
            _notificationService              = new NotificationService(RepositoryFactory, _eventPulisherMock.Object);
            _notificationsExportImportManager = new NotificationsExportImportManager(_notificationSearchService, _notificationService);

            _notificationRegistrar = new NotificationService(RepositoryFactory, _eventPulisherMock.Object);

            if (!AbstractTypeFactory <Notification> .AllTypeInfos.Any(t => t.IsAssignableTo(nameof(EmailNotification))))
            {
                AbstractTypeFactory <Notification> .RegisterType <EmailNotification>().MapToType <NotificationEntity>();

                AbstractTypeFactory <NotificationEntity> .RegisterType <EmailNotificationEntity>();
            }

            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 NotificationsExportImportManagerIntegrationTests()
        {
            _repositoryMock    = new Mock <INotificationRepository>();
            _eventPulisherMock = new Mock <IEventPublisher>();
            INotificationRepository RepositoryFactory() => _repositoryMock.Object;

            _mockUnitOfWork = new Mock <IUnitOfWork>();
            _repositoryMock.Setup(ss => ss.UnitOfWork).Returns(_mockUnitOfWork.Object);
            _notificationSearchServiceMock = new Mock <INotificationSearchService>();
            _notificationServiceMock       = new Mock <INotificationService>();

            _notificationsExportImportManager = new NotificationsExportImport(_notificationSearchServiceMock.Object, _notificationServiceMock.Object, GetJsonSerializer());

            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 = new NotificationService(RepositoryFactory, _eventPulisherMock.Object);
            _notificationRegistrar.RegisterNotification <RegistrationEmailNotification>();
        }
        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>();
        }
예제 #5
0
 public NotificationSearchServiceUnitTests()
 {
     _repositoryMock            = new Mock <INotificationRepository>();
     _repositoryFactoryMock     = new Mock <Func <INotificationRepository> >();
     _eventPublisherMock        = new Mock <IEventPublisher>();
     _notificationRegistrar     = new NotificationService(_repositoryFactoryMock.Object, _eventPublisherMock.Object);
     _repositoryFactory         = () => _repositoryMock.Object;
     _notificationSearchService = new NotificationSearchService(_repositoryFactory);
 }
        public NotificationServiceUnitTests()
        {
            _repositoryMock    = new Mock <INotificationRepository>();
            _repositoryFactory = () => _repositoryMock.Object;
            _mockUnitOfWork    = new Mock <IUnitOfWork>();
            _repositoryMock.Setup(ss => ss.UnitOfWork).Returns(_mockUnitOfWork.Object);
            _eventPublisherMock    = new Mock <IEventPublisher>();
            _notificationService   = new NotificationService(_repositoryFactory, _eventPublisherMock.Object);
            _notificationRegistrar = _notificationService;

            if (!AbstractTypeFactory <NotificationEntity> .AllTypeInfos.SelectMany(x => x.AllSubclasses).Contains(typeof(EmailNotificationEntity)))
            {
                AbstractTypeFactory <NotificationEntity> .RegisterType <EmailNotificationEntity>();
            }
        }
        public SocialNetworkNotificationEntityUnitTests()
        {
            _repositoryMock    = new Mock <INotificationRepository>();
            _repositoryFactory = () => _repositoryMock.Object;
            _mockUnitOfWork    = new Mock <IUnitOfWork>();
            _repositoryMock.Setup(ss => ss.UnitOfWork).Returns(_mockUnitOfWork.Object);
            _eventPublisherMock = new Mock <IEventPublisher>();
            var templateLoader = new Mock <INotificationTemplateLoader>();

            _memCache                  = GetCache();
            _notificationService       = new NotificationService(_repositoryFactory, _eventPublisherMock.Object, templateLoader.Object, _memCache);
            _notificationServiceMock   = new Mock <INotificationService>();
            _notificationSearchService = new NotificationSearchService(_repositoryFactory, _notificationServiceMock.Object, _memCache);
            _notificationRegistrar     = new NotificationRegistrar(null);

            if (!AbstractTypeFactory <NotificationEntity> .AllTypeInfos.SelectMany(x => x.AllSubclasses).Contains(typeof(SocialNetworkNotificationEntity)))
            {
                AbstractTypeFactory <NotificationEntity> .RegisterType <SocialNetworkNotificationEntity>();
            }
        }
예제 #8
0
        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 NotificationSearchServiceUnitTests()
        {
            _repositoryMock                = new Mock <INotificationRepository>();
            _repositoryFactoryMock         = new Mock <Func <INotificationRepository> >();
            _eventPublisherMock            = new Mock <IEventPublisher>();
            _repositoryFactory             = () => _repositoryMock.Object;
            _notificationServiceMock       = new Mock <INotificationService>();
            _notificationSearchServiceMock = new Mock <INotificationSearchService>();
            _memCache                  = GetCache();
            _cacheEntryMock            = new Mock <ICacheEntry>();
            _notificationRegistrar     = new NotificationRegistrar(null);
            _notificationSearchService = new NotificationSearchService(_repositoryFactory, _notificationServiceMock.Object, _memCache);


            var criteria = AbstractTypeFactory <NotificationSearchCriteria> .TryCreateInstance();

            criteria.Take             = 1;
            criteria.NotificationType = nameof(InvoiceEmailNotification);
            _notificationSearchServiceMock.Setup(x => x.SearchNotificationsAsync(criteria)).ReturnsAsync(new NotificationSearchResult());
            _notificationRegistrar.RegisterNotification <InvoiceEmailNotification>();

            criteria.NotificationType = nameof(OrderSentEmailNotification);
            _notificationSearchServiceMock.Setup(x => x.SearchNotificationsAsync(criteria)).ReturnsAsync(new NotificationSearchResult());
            _notificationRegistrar.RegisterNotification <OrderSentEmailNotification>();

            criteria.NotificationType = nameof(OrderPaidEmailNotification);
            _notificationSearchServiceMock.Setup(x => x.SearchNotificationsAsync(criteria)).ReturnsAsync(new NotificationSearchResult());
            _notificationRegistrar.RegisterNotification <OrderPaidEmailNotification>();

            criteria.NotificationType = nameof(RemindUserNameEmailNotification);
            _notificationSearchServiceMock.Setup(x => x.SearchNotificationsAsync(criteria)).ReturnsAsync(new NotificationSearchResult());
            _notificationRegistrar.RegisterNotification <RemindUserNameEmailNotification>();

            criteria.NotificationType = nameof(RegistrationEmailNotification);
            _notificationSearchServiceMock.Setup(x => x.SearchNotificationsAsync(criteria)).ReturnsAsync(new NotificationSearchResult());
            _notificationRegistrar.RegisterNotification <RegistrationEmailNotification>();
        }
예제 #10
0
        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);
        }