public void ShouldSend()
        {
            NotificationSettingsRequest nsRequest = new NotificationSettingsRequest()
            {
                EmailEnabled        = true,
                EmailAddress        = "*****@*****.**",
                SMSEnabled          = false,
                SMSNumber           = "2505555555",
                SubjectHdid         = "hdid",
                SMSVerificationCode = "123456",
                SMSVerified         = false,
            };
            string bearerToken = "bearer token";

            NotificationSettingsResponse nsResponse = new NotificationSettingsResponse(nsRequest);
            RequestResult <NotificationSettingsResponse> expectedResult = new RequestResult <NotificationSettingsResponse>()
            {
                ResourcePayload = nsResponse,
                ResultStatus    = Common.Constants.ResultType.Success,
            };
            var mockLogger     = new Mock <ILogger <NotificationSettingsService> >();
            var mockJobClient  = new Mock <IBackgroundJobClient>();
            var mockNSDelegate = new Mock <INotificationSettingsDelegate>();

            mockNSDelegate.Setup(s => s.SetNotificationSettings(nsRequest, bearerToken)).Returns(Task.FromResult(expectedResult));
            INotificationSettingsService service = new NotificationSettingsService(
                mockLogger.Object,
                mockJobClient.Object,
                mockNSDelegate.Object);
            RequestResult <NotificationSettingsResponse> actualResult = Task.Run(async() => await
                                                                                 service.SendNotificationSettings(nsRequest, bearerToken)).Result;

            Assert.True(actualResult.IsDeepEqual(expectedResult));
        }
        public void ShouldCreateSMSCode()
        {
            var mockLogger     = new Mock <ILogger <NotificationSettingsService> >();
            var mockJobClient  = new Mock <IBackgroundJobClient>();
            var mockNSDelegate = new Mock <INotificationSettingsDelegate>();

            INotificationSettingsService service = new NotificationSettingsService(
                mockLogger.Object,
                mockJobClient.Object,
                mockNSDelegate.Object);

            NotificationSettingsRequest nsr = new NotificationSettingsRequest()
            {
                EmailEnabled = true,
                EmailAddress = "*****@*****.**",
                SMSEnabled   = true,
                SMSNumber    = "2505555555",
                SubjectHdid  = "hdid",
                SMSVerified  = false,
            };

            Assert.True(nsr.SMSVerificationCode == null);
            service.QueueNotificationSettings(nsr);

            mockJobClient.Verify(x => x.Create(
                                     It.Is <Job>(job => job.Method.Name == "PushNotificationSettings" && job.Args[0] is string),
                                     It.IsAny <EnqueuedState>()));

            Assert.True(nsr.SMSVerificationCode != null);
        }
 public MailNotifierService(
     IMailService mailService,
     IIntranetUserService <IIntranetUser> intranetUserService,
     INotificationModelMapper <EmailNotifierTemplate, EmailNotificationMessage> notificationModelMapper,
     NotificationSettingsService notificationSettingsService)
 {
     _mailService                 = mailService;
     _intranetUserService         = intranetUserService;
     _notificationModelMapper     = notificationModelMapper;
     _notificationSettingsService = notificationSettingsService;
 }
示例#4
0
 public UiNotifierService(
     INotificationModelMapper <UiNotifierTemplate, UiNotificationMessage> notificationModelMapper,
     NotificationSettingsService notificationSettingsService,
     IIntranetUserService <IIntranetUser> intranetUserService,
     UiNotificationService notificationsService)
 {
     _notificationModelMapper     = notificationModelMapper;
     _notificationSettingsService = notificationSettingsService;
     _intranetUserService         = intranetUserService;
     _notificationsService        = notificationsService;
 }
 public MailNotifierService(
     IMailService mailService,
     IIntranetUserService <IIntranetUser> intranetUserService,
     INotificationModelMapper <EmailNotifierTemplate, EmailNotificationMessage> notificationModelMapper,
     NotificationSettingsService notificationSettingsService,
     ISqlRepository <global::Uintra.Notification.Notification> notificationRepository)
 {
     _mailService                 = mailService;
     _intranetUserService         = intranetUserService;
     _notificationModelMapper     = notificationModelMapper;
     _notificationSettingsService = notificationSettingsService;
     _notificationRepository      = notificationRepository;
 }
 public UiNotifierService(
     INotificationModelMapper <UiNotifierTemplate, UiNotificationMessage> notificationModelMapper,
     INotificationModelMapper <DesktopNotifierTemplate, DesktopNotificationMessage> desktopNotificationModelMapper,
     NotificationSettingsService notificationSettingsService,
     IIntranetMemberService <IIntranetMember> intranetMemberService,
     UiNotificationService notificationsService)
 {
     _notificationModelMapper        = notificationModelMapper;
     _notificationSettingsService    = notificationSettingsService;
     _intranetMemberService          = intranetMemberService;
     _notificationsService           = notificationsService;
     _desktopNotificationModelMapper = desktopNotificationModelMapper;
 }
        public void ShouldQueue()
        {
            NotificationSettingsRequest nsr = new NotificationSettingsRequest()
            {
                EmailEnabled        = true,
                EmailAddress        = "*****@*****.**",
                SMSEnabled          = true,
                SMSNumber           = "2505555555",
                SubjectHdid         = "hdid",
                SMSVerificationCode = "123456",
                SMSVerified         = false,
            };

            var mockLogger     = new Mock <ILogger <NotificationSettingsService> >();
            var mockJobClient  = new Mock <IBackgroundJobClient>();
            var mockNSDelegate = new Mock <INotificationSettingsDelegate>();
            var mockResourceDelegateDelegate = new Mock <IResourceDelegateDelegate>();
            var dbResult = new Database.Wrapper.DBResult <IEnumerable <ResourceDelegate> >();

            dbResult.Payload = new List <ResourceDelegate>();
            mockResourceDelegateDelegate.Setup(s => s.Get(nsr.SubjectHdid, 0, 500)).Returns(dbResult);
            INotificationSettingsService service = new NotificationSettingsService(
                mockLogger.Object,
                mockJobClient.Object,
                mockNSDelegate.Object,
                mockResourceDelegateDelegate.Object);

            var options = new JsonSerializerOptions
            {
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                IgnoreNullValues     = true,
                WriteIndented        = true,
            };

            string expectedJobParm = JsonSerializer.Serialize(nsr, options);

            service.QueueNotificationSettings(nsr);

            mockJobClient.Verify(x => x.Create(
                                     It.Is <Job>(job => job.Method.Name == "PushNotificationSettings" && (string)job.Args[0] == expectedJobParm),
                                     It.IsAny <EnqueuedState>()));
        }
        public void ShouldCreateSMSCode()
        {
            NotificationSettingsRequest nsr = new NotificationSettingsRequest()
            {
                EmailEnabled = true,
                EmailAddress = "*****@*****.**",
                SMSEnabled   = true,
                SMSNumber    = "2505555555",
                SubjectHdid  = "hdid",
                SMSVerified  = true,
            };

            var mockLogger     = new Mock <ILogger <NotificationSettingsService> >();
            var mockJobClient  = new Mock <IBackgroundJobClient>();
            var mockNSDelegate = new Mock <INotificationSettingsDelegate>();
            var mockResourceDelegateDelegate = new Mock <IResourceDelegateDelegate>();
            var dbResult = new Database.Wrapper.DBResult <IEnumerable <ResourceDelegate> >();

            dbResult.Payload = new List <ResourceDelegate>()
            {
                new ResourceDelegate()
                {
                    ProfileHdid = hdid
                },
            };
            mockResourceDelegateDelegate.Setup(s => s.Get(nsr.SubjectHdid, 0, 500)).Returns(dbResult);

            INotificationSettingsService service = new NotificationSettingsService(
                mockLogger.Object,
                mockJobClient.Object,
                mockNSDelegate.Object,
                mockResourceDelegateDelegate.Object);

            Assert.True(nsr.SMSVerificationCode == null);
            service.QueueNotificationSettings(nsr);

            mockJobClient.Verify(x => x.Create(
                                     It.Is <Job>(job => job.Method.Name == "PushNotificationSettings" && job.Args[0] is string),
                                     It.IsAny <EnqueuedState>()));

            Assert.True(nsr.SMSVerificationCode != null);
        }
示例#9
0
 public MonthlyEmailService(IMailService mailService,
                            IIntranetMemberService <IIntranetMember> intranetMemberService,
                            IExceptionLogger logger,
                            IBulletinsService <BulletinBase> bulletinsService,
                            IEventsService <EventBase> eventsService,
                            INewsService <NewsBase> newsService,
                            IUserTagRelationService userTagService,
                            IActivityLinkService activityLinkService,
                            NotificationSettingsService notificationSettingsService,
                            INotificationModelMapper <EmailNotifierTemplate, EmailNotificationMessage> notificationModelMapper,
                            IApplicationSettings applicationSettings)
     : base(mailService, intranetMemberService, logger, notificationSettingsService, applicationSettings)
 {
     _bulletinsService        = bulletinsService;
     _eventsService           = eventsService;
     _newsService             = newsService;
     _userTagService          = userTagService;
     _activityLinkService     = activityLinkService;
     _notificationModelMapper = notificationModelMapper;
 }
 public WelcomeMessageSetupStep(NotificationSettingsService notificationSettingsService)
 {
     _notificationSettingsService = notificationSettingsService;
 }