Exemple #1
0
        public async Task Should_Delete_All_Notifications_Between_StartDate_EndDate()
        {
            var now = DateTime.Now;

            var userIdentifier = AbpSession.ToUserIdentifier();
            await _notificationPublisher.PublishAsync("TestNotification", userIds : new[] { userIdentifier });

            Thread.Sleep(TimeSpan.FromSeconds(5));

            //this notification's creation time will be more than now+5sec
            await _notificationPublisher.PublishAsync("TestNotification2", userIds : new[] { userIdentifier });

            Thread.Sleep(TimeSpan.FromSeconds(5));

            //this notification's creation time will be more than now+10sec
            await _notificationPublisher.PublishAsync("TestNotification3", userIds : new[] { userIdentifier });

            var allNotifications = await _notificationStore.GetUserNotificationsWithNotificationsAsync(
                userIdentifier,
                startDate : now,
                endDate : now.AddSeconds(30)
                );

            allNotifications.Count.ShouldBe(3);

            //delete second added notification
            await _notificationStore.DeleteAllUserNotificationsAsync(
                userIdentifier,
                state : null,
                startDate : now.AddSeconds(5),
                endDate : now.AddSeconds(10)
                );

            //check
            var notifications = await _notificationStore.GetUserNotificationsWithNotificationsAsync(
                userIdentifier,
                startDate : now.AddSeconds(5),
                endDate : now.AddSeconds(10)
                );

            notifications.Count.ShouldBe(0);

            allNotifications = await _notificationStore.GetUserNotificationsWithNotificationsAsync(
                userIdentifier,
                startDate : now,
                endDate : now.AddSeconds(30)
                );

            allNotifications.Count.ShouldBe(2);

            //delete all added notification
            await _notificationStore.DeleteAllUserNotificationsAsync(
                userIdentifier,
                state : null,
                startDate : now,
                endDate : now.AddSeconds(30)
                );

            //check
            allNotifications = await _notificationStore.GetUserNotificationsWithNotificationsAsync(
                userIdentifier,
                startDate : now,
                endDate : now.AddSeconds(30)
                );

            allNotifications.Count.ShouldBe(0);
        }
 public Task DeleteAllUserNotificationsAsync(UserIdentifier user)
 {
     return(_store.DeleteAllUserNotificationsAsync(user));
 }
Exemple #3
0
 public Task DeleteAllUserNotificationsAsync(UserIdentifier user, UserNotificationState?state = null, DateTime?startDate = null, DateTime?endDate = null)
 {
     return(_store.DeleteAllUserNotificationsAsync(user, state, startDate, endDate));
 }
Exemple #4
0
 public Task DeleteAllUserNotificationsAsync(long userId)
 {
     return(_store.DeleteAllUserNotificationsAsync(userId));
 }