コード例 #1
0
        public void ResultsTest() {
            CustomNotification toast;
            Task<NotificationResult> task;
            var notifier = new CustomNotifier();

            toast = new CustomNotification(null, notifier);
            task = notifier.ShowAsync(toast, 1);
            WaitWithDispatcher(task);
            Assert.AreEqual(NotificationResult.TimedOut, task.Result);

            toast = new CustomNotification(null, notifier);
            task = notifier.ShowAsync(toast, 1);
            toast.Activate();
            WaitWithDispatcher(task);
            Assert.AreEqual(NotificationResult.Activated, task.Result);

            toast = new CustomNotification(null, notifier);
            task = notifier.ShowAsync(toast, 1);
            toast.Dismiss();
            WaitWithDispatcher(task);
            Assert.AreEqual(NotificationResult.UserCanceled, task.Result);

            toast = new CustomNotification(null, notifier);
            task = notifier.ShowAsync(toast, 1);
            toast.Hide();
            WaitWithDispatcher(task);
            Assert.AreEqual(NotificationResult.ApplicationHidden, task.Result);

            var tasks = Enumerable.Range(0, 10).Select(_ => notifier.ShowAsync(new CustomNotification(null, notifier), 1)).ToList();
            tasks.ToList().ForEach(WaitWithDispatcher);
            tasks.ToList().ForEach(t => Assert.AreEqual(NotificationResult.TimedOut, t.Result));
        }