public async Task GetUserNotification_Test() { var Notification1 = new UserNotifications { Id = 1, UserId = 1, Message = "message1", MessageDate = DateTime.Now }; _dbContext.Set <UserNotifications>().Add(Notification1); var Notification2 = new UserNotifications { Id = 2, UserId = 1, Message = "message2", MessageDate = DateTime.Now }; _dbContext.Set <UserNotifications>().Add(Notification2); await _dbContext.SaveChangesAsync(); var efRepository = new EfRepository <UserNotifications>(_dbContext); var getUserNotificationQuery = new GetUserNotificationQuery(efRepository, _httpContextAccessor); var notifications = await getUserNotificationQuery.ExecuteAsync(); Assert.NotNull(notifications); Assert.Equal(2, notifications.Count); }
public async Task GetUserNotificationVerifyData_Test() { var notification = new UserNotifications { Id = 1, UserId = 1, Message = "message1", MessageDate = DateTime.Now.AddDays(-3) }; _dbContext.Set <UserNotifications>().Add(notification); await _dbContext.SaveChangesAsync(); var efRepository = new EfRepository <UserNotifications>(_dbContext); var getUserNotificationQuery = new GetUserNotificationQuery(efRepository, _httpContextAccessor); var result = (await getUserNotificationQuery.ExecuteAsync()).FirstOrDefault(); Assert.NotNull(result); Assert.Equal(notification.Message, result.Message); Assert.Equal(notification.MessageDate, result.MessageDate); Assert.Equal((DateTime.Now.Date - notification.MessageDate).Days < 2, result.IsNew); }