コード例 #1
0
        public void SendNotifications_SendAlwaysSucceeds_RemovesAllFromDatabase()
        {
            var(context, notificationService) = CreateTestTools(
                nameof(SendNotifications_SendAlwaysSucceeds_RemovesAllFromDatabase)
                );

            NotificationDataManager.CreateNotification(
                context, new Notification()
            {
                Content = "Message1", ContentType = "text/plain"
            }
                );
            NotificationDataManager.CreateNotification(
                context, new Notification()
            {
                Content = "Message2", ContentType = "text/plain"
            }
                );

            var notifyService = new MockRetryNotifyService(notificationService, true, TimeSpan.FromMinutes(1));

            notifyService.SendNotifications(new List <Notification>());

            Assert.Empty(context.Notifications);
        }
コード例 #2
0
        public void SendNotifications_OneOlderThanMinuteInDatabase_RemovesAllFromDatabase()
        {
            var(context, notificationService) = CreateTestTools(
                nameof(SendNotifications_OneOlderThanMinuteInDatabase_RemovesAllFromDatabase)
                );

            NotificationDataManager.CreateNotification(context,
                                                       new Notification()
            {
                Content = "Message1", ContentType = "text/plain"
            },
                                                       DateTime.Now - TimeSpan.FromMinutes(2)
                                                       );

            var notifyService = new MockRetryNotifyService(notificationService, false, TimeSpan.FromMinutes(1));

            notifyService.SendNotifications(new List <Notification>());

            Assert.Empty(context.Notifications);
        }
コード例 #3
0
        public void SendNotifications_SendAlwaysFails_SavesAllToDatabase()
        {
            var notifications = new List <Notification>()
            {
                new Notification()
                {
                    Content = "Message1", ContentType = "text/plain"
                },
                new Notification()
                {
                    Content = "Message2", ContentType = "text/plain"
                }
            };

            var(context, notificationService) = CreateTestTools(
                nameof(SendNotifications_SendAlwaysFails_SavesAllToDatabase)
                );
            var notifyService = new MockRetryNotifyService(notificationService, false, TimeSpan.FromMinutes(1));

            notifyService.SendNotifications(notifications);

            Assert.Equal(notifications.Count, context.Notifications.Count());
        }