public void NotificationRecipientsBuildsQuery4() { var query = new NotificationRecipients() .AddDeviceWithQuery(string.Empty) .AddGroupWithQuery(string.Empty) .AddUserWithQuery(string.Empty) .BuildQuery(); Assert.AreEqual("/groups;ql=/users;ql=/devices;ql=/notifications", query); }
public void NotificationRecipientsBuildsQuery3() { var query = new NotificationRecipients() .AddDeviceWithQuery("d") .AddGroupWithQuery("p") .AddUserWithQuery("u") .BuildQuery(); Assert.AreEqual("/groups;ql=p/users;ql=u/devices;ql=d/notifications", query); }
public void NotificationRecipientsBuildsQuery2() { var query = new NotificationRecipients() .AddDeviceWithName("d") .AddGroupWithPath("p") .AddUserWithUuid("u") .BuildQuery(); Assert.AreEqual("/groups/p/users/u/devices/d/notifications", query); }
public void ShouldPublishNotifications() { //Set up const string appleNotifierName = "apple_notifier"; const string googleNotifierName = "google_notifier"; const string username = "******"; const string appleTestMessge = "test message for Apple"; const string androidTestMessage = "test message for Android"; var client = InitializeClientAndLogin(AuthType.Organization); CreateAppleNotifier(client,appleNotifierName); CreateAndroidNotifier(client,googleNotifierName); CreateUser(username, client); //Setup Notifications var appleNotification = new AppleNotification(appleNotifierName, appleTestMessge, "chime"); var googleNotification = new AndroidNotification(googleNotifierName, androidTestMessage); //Setup recipients and scheduling INotificationRecipients recipients = new NotificationRecipients().AddUserWithName(username); var schedulerSettings = new NotificationSchedulerSettings {DeliverAt = DateTime.Now.AddDays(1)}; client.PublishNotification(new Notification[] {appleNotification, googleNotification}, recipients, schedulerSettings); //Assert UsergridCollection<dynamic> entities = client.GetEntities<dynamic>("notifications", query: "order by created desc"); dynamic notification = entities.FirstOrDefault(); Assert.IsNotNull(notification); Assert.IsNotNull(notification.uuid); Assert.AreEqual(appleTestMessge, notification.payloads.apple_notifier.aps.alert.Value); Assert.AreEqual("chime", notification.payloads.apple_notifier.aps.sound.Value); Assert.AreEqual(androidTestMessage, notification.payloads.google_notifier.data.Value); //Cancel notification and assert it is canceled client.CancelNotification(notification.uuid.Value); dynamic entity = client.GetEntity<dynamic>("notifications", notification.uuid.Value); Assert.AreEqual(entity.state.Value, "CANCELED"); }
public void PublishNotificationShouldDelegateToNotificationsManagerWithCorrectParameters() { var notifications = new Notification[] {new AppleNotification("notifierName", "message", "chime")}; INotificationRecipients recipients = new NotificationRecipients().AddUserWithName("username"); var schedulerSettings = new NotificationSchedulerSettings {DeliverAt = DateTime.Now.AddDays(1)}; _client.PublishNotification(notifications, recipients, schedulerSettings); _notificationsManager.Received(1).PublishNotification(notifications, recipients, schedulerSettings); }