예제 #1
0
        public void SendVersionedPushNotificationToDeviceWithoutWithInvalidVersionTest()
        {
            NotificationTest        test    = new NotificationTest();
            PushNotificationChannel channel = new PushNotificationChannel(this.CreateMobileServiceClient(), test.EventPublisher);

            PushNotification           notification = this.CreateNotification(new Version(1, 0, 0));
            NotificationAccount <Guid> account      = test.AddNotificationAccount(Guid.NewGuid(), mobileAppVersion: "Invalid");

            channel.SendAsync(account, notification).Wait();

            this.AssertSentFailed(test, account, notification, NotificationErrorCode.VersionMismatch);
        }
예제 #2
0
        public void SendPushNotificationForAnOutdatedVersionOfTheApplicationTest()
        {
            NotificationTest        test    = new NotificationTest();
            PushNotificationChannel channel = new PushNotificationChannel(this.CreateMobileServiceClient(), test.EventPublisher);

            PushNotification           notification = this.CreateNotification(new Version(1, 0, 0), new Version(1, 0, 2));
            NotificationAccount <Guid> account      = test.AddNotificationAccount(Guid.NewGuid(), mobileAppVersion: "1.0.3");

            channel.SendAsync(account, notification).Wait();

            this.AssertSentFailed(test, account, notification, NotificationErrorCode.VersionMismatch);
        }
예제 #3
0
        public void SendPushNotificationWithOnlyMinimumAppVersionSpecifiedTest()
        {
            NotificationTest        test    = new NotificationTest();
            PushNotificationChannel channel = new PushNotificationChannel(this.CreateMobileServiceClient(), test.EventPublisher);

            PushNotification           notification = this.CreateNotification(new Version(1, 0, 0));
            NotificationAccount <Guid> account      = test.AddNotificationAccount(Guid.NewGuid(), mobileAppVersion: "1.0.3");

            channel.SendAsync(account, notification).Wait();

            this.AssertSentSuccessful(test, account, notification);
        }
예제 #4
0
        public void SendPushNotificationForAccountWithoutMobileDeviceTest()
        {
            NotificationTest        test    = new NotificationTest();
            PushNotificationChannel channel = new PushNotificationChannel(this.CreateMobileServiceClient(), test.EventPublisher);

            PushNotification           notification = this.CreateNotification();
            NotificationAccount <Guid> account      = test.AddNotificationAccount(Guid.NewGuid(), "*****@*****.**", "Joe", null, (MobileDevice)null);

            channel.SendAsync(account, notification).Wait();

            this.AssertSentFailed(test, account, notification, NotificationErrorCode.MobileDeviceNotRegistered);
        }
예제 #5
0
        public void SendInvalidEndPointPushNotificationTest()
        {
            NotificationTest test = new NotificationTest();
            IMobilePushNotificationServiceClient mobileServiceClient = this.CreateMobileServiceClient();
            PushNotificationChannel channel = new PushNotificationChannel(mobileServiceClient, test.EventPublisher);

            PushNotification           notification = this.CreateNotification();
            NotificationAccount <Guid> account      = test.AddNotificationAccount();

            this.PushNotificationShouldFailAtEndPoint(mobileServiceClient);

            channel.SendAsync(account, notification).Wait();

            this.AssertSentFailed(test, account, notification, NotificationErrorCode.RouteFailure);
        }
예제 #6
0
        public void SchedulePushNotificationWithoutTimeZoneTest()
        {
            NotificationTest             test      = new NotificationTest();
            NotificationScheduler <Guid> scheduler = this.CreateScheduler(test);

            PushNotification           notification = this.CreateNotification();
            NotificationAccount <Guid> account      = test.AddNotificationAccount(Guid.NewGuid(), timeZone: null);

            DateTime deliveryDate = DateTime.UtcNow.AddDays(1);

            scheduler.Schedule(account.AccountId, notification, deliveryDate);

            DateTimeOffset expectedDeliveryDate = deliveryDate.ToDateTimeOffset("US/Eastern");

            this.AssertNotificationScheduledSuccessful(test, account, notification, expectedDeliveryDate);
        }
예제 #7
0
        public void SendOverDueNotificationTest()
        {
            NotificationTest test = new NotificationTest();

            INotificationChannel         channel;
            NotificationScheduler <Guid> scheduler = this.CreateScheduler(test, out channel);

            DateTime deliveryDate = DateTime.UtcNow;
            NotificationAccount <Guid> account            = test.AddNotificationAccount(Guid.NewGuid(), "US/Pacific");
            PushNotification           notificationToSend = this.CreateNotification();

            test.NotificationRepository.GetScheduledNotifications(Arg.Any <DateTime>()).Returns(new[] { new ScheduledNotification <Guid>(account.AccountId, notificationToSend, DateTime.UtcNow) });

            scheduler.SendScheduledNotifications(DateTime.UtcNow.AddDays(1)).Wait();

            channel.Received().SendAsync(account, notificationToSend);
            test.NotificationRepository.Received().DeleteScheduledNotification(notificationToSend.Id);
        }