public async Task Add_user_Notification_success()
        {
            //Arrange
            var model = new NotificationEventModel
            {
                Data = new NotificationData
                {
                    AppointmentDateTime = "23/01/2020",
                    FirstName           = "Romio",
                    OrganisationName    = "Little Runners",
                    Reason = "Healthy"
                },

                Type   = "AppointmentCancelled",
                UserId = Guid.NewGuid()
            };

            //Act
            var catalogContext   = new NotificationsDbContext(_dbOptions);
            var accessServ       = new NotificationsAccess(catalogContext);
            var NotificationServ = new NotificationsService(accessServ);
            var testController   = new NotificationsController(NotificationServ);
            var actionResult     = await testController.AddUserNotification(model).ConfigureAwait(false);

            //Assert
            Assert.IsType <OkObjectResult>(actionResult);
            var result = Assert.IsAssignableFrom <NotificationModel>(((OkObjectResult)actionResult).Value);

            Assert.Contains("Healthy", result.Message);
        }
 public NotificationsDbContextCleaner(
     NotificationsDbContext context,
     IWebHostEnvironment environment,
     ILogger <NotificationsDbContextCleaner> logger
     ) : base(context, environment, logger)
 {
     Users = context.Set <User>();
 }
示例#3
0
 public MyNotifications(
     UserContext userContext,
     NotificationsDbContext notificationsDbContext,
     NotificationManagerRegister notificationManagerRegister)
 {
     this.userContext                 = userContext;
     this.notificationsDbContext      = notificationsDbContext;
     this.notificationManagerRegister = notificationManagerRegister;
 }
示例#4
0
 public CloseMagic(CoreDbContext context,
                   EmailTemplateRegister emailSender,
                   NotificationsDbContext notificationsDbContext,
                   IOptions <AppConfig> appConfig)
 {
     this.context                = context;
     this.emailSender            = emailSender;
     this.notificationsDbContext = notificationsDbContext;
     this.appConfig              = appConfig;
 }
示例#5
0
 public SubmitMagic(CoreDbContext context,
                    EmailTemplateRegister emailSender,
                    NotificationsDbContext notificationsDbContext,
                    IOptions <AppConfig> appConfig,
                    UserManager <ApplicationUser> userManager)
 {
     this.context                = context;
     this.emailSender            = emailSender;
     this.notificationsDbContext = notificationsDbContext;
     this.appConfig              = appConfig;
     this.userManager            = userManager;
 }
示例#6
0
 public OnWorkItemAssigned(
     EventManager manager,
     EmailTemplateRegister emailSender,
     CoreDbContext dbContext,
     IOptions <AppConfig> appConfig,
     NotificationsDbContext notificationsDbContext) : base(manager)
 {
     this.emailSender            = emailSender;
     this.dbContext              = dbContext;
     this.appConfig              = appConfig;
     this.notificationsDbContext = notificationsDbContext;
 }
        public NotificationControllerTest()
        {
            _dbOptions = new DbContextOptionsBuilder <NotificationsDbContext>()
                         .UseInMemoryDatabase(databaseName: "in-memory")
                         .Options;

            using (var dbContext = new NotificationsDbContext(_dbOptions))
            {
                dbContext.AddRange(GetNoticationSeed());
                dbContext.Add(GetTemplateData());
                dbContext.SaveChanges();
            }
        }
示例#8
0
        public static void PopulateTestData(NotificationsDbContext dbContext)
        {
            var userGuid = Guid.Parse("b8412641-6436-49cc-816b-49b4a4f4ecd3");

            dbContext.Notifications.Add(new NotificationEntity(userGuid, "title1", "text1"));
            dbContext.Notifications.Add(new NotificationEntity(userGuid, "title2", "text3"));
            dbContext.Templates.Add(new TemplateEntity
            {
                Body  = "Hi {Firstname}, your appointment with {OrganisationName} at {AppointmentDateTime} has been - cancelled for the following reason: {Reason}.",
                Title = "Appointment Cancelled"
            });
            dbContext.SaveChanges();
        }
示例#9
0
 public OnActivityRecorded(
     EventManager manager,
     EmailTemplateRegister emailSender,
     CoreDbContext dbContext,
     IOptions <AppConfig> appConfig,
     NotificationsDbContext notificationsDbContext,
     UserManager <ApplicationUser> userManager) : base(manager)
 {
     this.emailSender            = emailSender;
     this.dbContext              = dbContext;
     this.appConfig              = appConfig;
     this.notificationsDbContext = notificationsDbContext;
     this.userManager            = userManager;
 }
示例#10
0
 private static void AddNotifications(NotificationsDbContext db, out Notification notification1, out Notification notification2, out Notification notification3)
 {
     notification1 = new Notification {
         NotificationId = 1, UserId = 1, CreatedAt = DateTime.Today - TimeSpan.FromDays(1)
     }.SetStringProperties();
     notification2 = new Notification {
         NotificationId = 2, UserId = 1, CreatedAt = DateTime.Today - TimeSpan.FromDays(2)
     }.SetStringProperties();
     notification3 = new Notification {
         NotificationId = 3, UserId = 1, CreatedAt = DateTime.Today - TimeSpan.FromDays(3), Subject = "Test"
     };
     db.AddRange(notification1, notification2, notification3);
     db.SaveChanges();
 }
示例#11
0
        public static async Task PublishForUser(this NotificationsDbContext ns,
                                                int userId,
                                                string entityType,
                                                string entityKey,
                                                string summary,
                                                string description)
        {
            var notification = new Notifications.Notification(
                new EntityReference(NotificationRecipientType.UserId.Value, userId.ToString()),
                new EntityReference(entityType, entityKey),
                summary,
                description);

            ns.Notifications.Add(notification);
            await ns.SaveChangesAsync();
        }
示例#12
0
 public AddComment(ConversationsDbContext <int> context,
                   UserContext userContext,
                   ApplicationDbContext applicationDbContext,
                   NotificationsDbContext notificationsDbContext,
                   ConversationManagerCollection conversationManagerCollection,
                   EmailTemplateRegister emailSender,
                   IOptions <AppConfig> appConfig)
 {
     this.context                       = context;
     this.userContext                   = userContext;
     this.applicationDbContext          = applicationDbContext;
     this.notificationsDbContext        = notificationsDbContext;
     this.conversationManagerCollection = conversationManagerCollection;
     this.emailSender                   = emailSender;
     this.appConfig                     = appConfig;
 }
        public async Task Get_user_Notification_Failed()
        {
            //Arrange
            var userId = new Guid();

            //Act
            var catalogContext   = new NotificationsDbContext(_dbOptions);
            var accessServ       = new NotificationsAccess(catalogContext);
            var NotificationServ = new NotificationsService(accessServ);
            var testController   = new NotificationsController(NotificationServ);
            var actionResult     = await testController.GetUserCancelledAppointmentNotification(userId).ConfigureAwait(false);

            //Assert
            Assert.IsType <NotFoundObjectResult>(actionResult);
            var result = ((NotFoundObjectResult)actionResult).Value;

            Assert.Null(result);
        }
示例#14
0
        public static async Task PublishForUser <T>(
            this NotificationsDbContext ns,
            string description,
            T entity,
            int sendToUserId,
            string summary,
            NotificationCategory category)
            where T : DomainEntity
        {
            var notification = new Notification(
                new EntityReference(NotificationRecipientType.UserId.Value, sendToUserId.ToString()),
                new EntityReference(typeof(T).FullName, entity.Key.ToString()),
                summary,
                description,
                category.Id);

            ns.Notifications.Add(notification);
            await ns.SaveChangesAsync();
        }
        public async Task Get_user_Notification_success()
        {
            //Arrange
            var userId = testUserId;

            //Act
            var catalogContext   = new NotificationsDbContext(_dbOptions);
            var accessServ       = new NotificationsAccess(catalogContext);
            var NotificationServ = new NotificationsService(accessServ);
            var testController   = new NotificationsController(NotificationServ);
            var actionResult     = await testController.GetUserCancelledAppointmentNotification(userId).ConfigureAwait(false);

            //Assert
            Assert.IsType <OkObjectResult>(actionResult);
            var result = Assert.IsAssignableFrom <List <NotificationModel> >(((OkObjectResult)actionResult).Value);

            Assert.Equal(3, result.Count);
            Assert.Equal(EventType.AppointmentCancelled.ToString(), result[0].EventType);
            Assert.Contains("Hi Firstname, your appointment with OrganisationName at AppointmentDateTime has been cancelled for the following reason: Reason.",
                            result[0].Message);
        }
示例#16
0
 public NotificationsAccess(NotificationsDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
 public NotificationsController(NotificationsDbContext db, IHubContext <NotificationsHub> hub, IUsersClient usersClient)
 {
     this.db          = db;
     this.hub         = hub;
     this.usersClient = usersClient;
 }
示例#18
0
 public NotificationsAccess(NotificationsDbContext dbContext, IMapper mapper)
 {
     this.dbContext = dbContext;
     this.mapper    = mapper;
 }
 public UserNotificationService(NotificationsDbContext dbContext)
 {
     _dbContext = dbContext;
 }
示例#20
0
 public Archive(NotificationsDbContext notificationsDbContext, UserContext userContext)
 {
     this.notificationsDbContext = notificationsDbContext;
     this.userContext            = userContext;
 }
示例#21
0
 public UserRepository(NotificationsDbContext context)
 {
     _context = context;
 }
示例#22
0
 public NotificationsService(NotificationsDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
示例#23
0
 public CoreMenus(NotificationsDbContext context, UserSecurityContext userSecurityContext)
 {
     this.context             = context;
     this.userSecurityContext = userSecurityContext;
 }
示例#24
0
 public AccountService(NotificationsDbContext dbContext, IEncrypter encrypter)
 {
     this.dbContext = dbContext;
     this.encrypter = encrypter;
 }
示例#25
0
 public WnsTokenStorage(NotificationsDbContext dbContext)
 {
     this.dbContext = dbContext;
 }