public MainWindow() { InitializeComponent(); AppDomain.CurrentDomain.UnhandledException += (s, e) => { MessageBox.Show(e.ExceptionObject.ToString()); }; NotificationClient.NotificationClosed += NotificationClient_NotificationClosed; NotificationClient.NotificationCreated += NotificationClient_NotificationCreated; NotificationClient.NotificationActionOccurred += NotificationClient_NotificationActionOccurred; toggleButtons(false); NotificationClient.OnInitComplete += async() => { toggleButtons(true); //var status = await NotificationClient.GetProviderStatusAsync(); //Dispatcher.Invoke(() => //{ // bodyContentTypeSelector.SelectedIndex = 0; // connected.Content = !status.Connected ? "Failed to connect." : "Connected"; // if(status.Connected) // { // version.Content = $"(v.{status.Version})"; // } //}); }; NotificationClient.Initialize(); }
public void CreateNotification_CreateNotification_ReturnsOptions() { var are = new AutoResetEvent(false); string id = Guid.NewGuid().ToString(); var options = new NotificationOptions { Title = id, Body = id, Icon = id, Category = id, Buttons = new ButtonOptions[] { } }; NotificationClient.OnInitComplete += async() => { var notification = await NotificationClient.CreateNotificationAsync(id, options); Assert.AreEqual(id, notification.Id); are.Set(); }; NotificationClient.Initialize(uri); are.WaitOne(); }
public async Task CreateNotification_CreateExpiringNotificationWithHandler_CallsNotificationActionEventHandler() { var are = new AutoResetEvent(false); string id = Guid.NewGuid().ToString(); var options = new NotificationOptions { Title = id, Body = id, Icon = id, Category = id, Expires = DateTime.Now.AddSeconds(10), Buttons = new ButtonOptions[] { }, OnNotificationExpired = new Dictionary <string, object> { { "foo", "bar" } } }; NotificationClient.OnInitComplete += () => { are.Set(); }; NotificationClient.NotificationActionOccurred += (@event) => { Assert.AreEqual(ActionTriggers.Expire, @event.ActionTrigger); Assert.IsTrue(@event.NotificationActionResult.ContainsKey("foo")); Assert.AreEqual("bar", @event.NotificationActionResult["foo"]); are.Set(); }; NotificationClient.Initialize(uri); are.WaitOne(); await NotificationClient.CreateNotificationAsync(id, options); are.WaitOne(); }
public async Task ClearNotification_ClearingCreatedNotification_TriggersClosedEvent() { var are = new AutoResetEvent(false); string id = Guid.NewGuid().ToString(); var options = new NotificationOptions { Title = id, Body = id, Icon = id, Category = id, Buttons = new ButtonOptions[] { } }; NotificationClient.OnInitComplete += () => { are.Set(); }; NotificationClient.NotificationClosed += (@event) => { Assert.AreEqual(id, @event.NotificationOptions.Id); are.Set(); }; NotificationClient.NotificationCreated += async(@event) => { Assert.AreEqual(id, @event.NotificationOptions.Id); await NotificationClient.ClearNotificationAsync(id); }; NotificationClient.Initialize(uri); are.WaitOne(); await NotificationClient.CreateNotificationAsync(id, options); are.WaitOne(); }
public MainWindow() { InitializeComponent(); AppDomain.CurrentDomain.UnhandledException += (s, e) => { MessageBox.Show(e.ExceptionObject.ToString()); }; NotificationClient.NotificationClosed += NotificationClient_NotificationClosed; NotificationClient.NotificationCreated += NotificationClient_NotificationCreated; NotificationClient.NotificationActionOccurred += NotificationClient_NotificationActionOccurred; NotificationClient.OnInitComplete += () => { toggleButtons(true); Dispatcher.Invoke(() => { bodyContentTypeSelector.SelectedIndex = 0; }); }; NotificationClient.Initialize(); toggleButtons(false); }
public async Task CreateNotification_CreateNotificationWithoutBody_ThrowsException() { var are = new AutoResetEvent(false); string id = Guid.NewGuid().ToString(); var options = new NotificationOptions { Title = id, Icon = id, Category = id, Buttons = new ButtonOptions[] { } }; NotificationClient.OnInitComplete += () => { are.Set(); }; NotificationClient.Initialize(uri); are.WaitOne(); await NotificationClient.CreateNotificationAsync(id, options); }
public void Initialize_NullInitCompleteHandler_ExceptionThrown() { Assert.ThrowsException <InvalidOperationException>(() => { NotificationClient.Initialize(uri); }); }