private void OnSimpleTextToastButtonTapped(object sender, GestureEventArgs e) { SimpleToastNotification simpleToastNotification = new SimpleToastNotification(); simpleToastNotification.Content = "Bonjour " + DateTime.UtcNow.ToString("T"); _notificationManager.Enqueue(simpleToastNotification); }
public async Task ToastNotificationManagerTest_Enqueue_ExistingNotification_ShouldUpdateExistingNotification() { await Deployment.Current.Dispatcher.InvokeAsync(() => { // Arrange Grid rootGrid = new Grid(); ToastNotificationManager manager = new ToastNotificationManager(rootGrid); ToastNotificationBase notification1 = new SimpleToastNotification(); ToastNotificationBase notification2 = new SimpleToastNotification(); notification2.Id = "test"; manager.Enqueue(notification1); manager.Enqueue(notification2); SimpleToastNotification notification2updated = new SimpleToastNotification(); notification2updated.Id = "test"; notification2updated.Title = "Updated content"; // Act manager.Enqueue(notification2updated); // Assert Assert.AreEqual(2, manager.QueuedNotifications.Count); Assert.IsInstanceOfType(manager.QueuedNotifications.Last(), typeof(SimpleToastNotification)); SimpleToastNotification resultNotification = manager.QueuedNotifications.Last() as SimpleToastNotification; Assert.AreSame(notification2updated.Title, resultNotification.Title); return(null); }); }
public async Task ToastNotificationManagerTest_GetToastById_KnowId_ShouldReturnNotifcation() { await Deployment.Current.Dispatcher.InvokeAsync(() => { // Arrange Grid rootGrid = new Grid(); ToastNotificationManager manager = new ToastNotificationManager(rootGrid); ToastNotificationBase notification1 = new SimpleToastNotification(); manager.Enqueue(notification1); manager.Enqueue(new SimpleToastNotification() { Id = "TestId", Title = "success" }); // Act ToastNotificationBase toast = manager.GetToastById("TestId"); // Assert Assert.IsNotNull(toast); Assert.IsInstanceOfType(toast, typeof(SimpleToastNotification)); SimpleToastNotification notification = toast as SimpleToastNotification; Assert.AreSame("success", notification.Title); return(null); }); }
public async Task ToastNotificationManagerTest_Enqueue_ShouldBeTheLastItem() { await Deployment.Current.Dispatcher.InvokeAsync(() => { // Arrange Grid rootGrid = new Grid(); ToastNotificationManager manager = new ToastNotificationManager(rootGrid); ToastNotificationBase notification1 = new SimpleToastNotification(); ToastNotificationBase notification2 = new SimpleToastNotification(); manager.Enqueue(notification1); // Act manager.Enqueue(notification2); // Assert Assert.AreEqual(2, manager.QueuedNotifications.Count); Assert.AreEqual(notification2, manager.QueuedNotifications.Last()); return(null); }); }
public async Task ToastNotificationManagerTest_GetToastById_UnknownId_ShouldReturnNull() { await Deployment.Current.Dispatcher.InvokeAsync(() => { // Arrange Grid rootGrid = new Grid(); ToastNotificationManager manager = new ToastNotificationManager(rootGrid); ToastNotificationBase notification1 = new SimpleToastNotification(); manager.Enqueue(notification1); // Act ToastNotificationBase toast = manager.GetToastById("newTag"); // Assert Assert.IsNull(toast); return(null); }); }