コード例 #1
0
        public void BasicResolutionChangedHandlingTest()
        {
            var testScreen = new TestScreen {
                bounds = new Rect(0, 0, 1000, 500)
            };
            var notifier = new CustomNotifier(testScreen);

            notifier.UpdatePositioner(NotificationPosition.BottomRight, 2);
            var toasts = Enumerable.Range(0, 3).Select(_ => new CustomNotification(null, notifier)).ToList();
            var tasks  = toasts.Select(toast => notifier.ShowAsync(toast, 1)).ToList();

            var pos = CustomNotifier.positioner;
            var ps  = pos.Items.Select(i => pos.GetItemPosition(i)).ToList();

            Assert.AreEqual(new Point(615, 390), ps[0]);
            Assert.AreEqual(new Point(615, 290), ps[1]);

            testScreen.bounds = new Rect(0, 0, 800, 600);
            testScreen.Changed();
            pos = CustomNotifier.positioner;
            ps  = pos.Items.Select(i => pos.GetItemPosition(i)).ToList();
            Assert.AreEqual(new Point(415, 490), ps[0]);
            Assert.AreEqual(new Point(415, 390), ps[1]);

            tasks.ToList().ForEach(WaitWithDispatcher);
            tasks.ToList().ForEach(t => Assert.AreEqual(NotificationResult.TimedOut, t.Result));
        }
コード例 #2
0
        public void ShowingTooManyToastsTest()
        {
            var notifier = new CustomNotifier();

            notifier.UpdatePositioner(NotificationPosition.TopRight, 100);

            var tasks = Enumerable.Range(0, 100).Select(_ => notifier.ShowAsync(new CustomNotification(null, notifier), 1)).ToList();

            tasks.ToList().ForEach(WaitWithDispatcher);
            tasks.ToList().ForEach(t => Assert.AreEqual(NotificationResult.TimedOut, t.Result));
        }
コード例 #3
0
        public void UpdatingPositionerTest()
        {
            CustomNotification        toast;
            Task <NotificationResult> task;
            var notifier = new CustomNotifier();
            var tasks    = Enumerable.Range(0, 5).Select(_ => notifier.ShowAsync(new CustomNotification(null, notifier), 1)).ToList();

            tasks.ToList().ForEach(WaitWithDispatcher);
            tasks.ToList().ForEach(t => Assert.AreEqual(NotificationResult.TimedOut, t.Result));

            toast = new CustomNotification(null, notifier);
            task  = notifier.ShowAsync(toast, 1);
            notifier.UpdatePositioner(NotificationPosition.TopRight, 2);
            WaitWithDispatcher(task);
            Assert.AreEqual(NotificationResult.TimedOut, task.Result);
            tasks = Enumerable.Range(0, 10).Select(_ => notifier.ShowAsync(new CustomNotification(null, notifier), 1)).ToList();
            notifier.UpdatePositioner(NotificationPosition.TopRight, 2);
            tasks.ToList().ForEach(WaitWithDispatcher);
            tasks.ToList().ForEach(t => Assert.AreEqual(NotificationResult.TimedOut, t.Result));
        }
コード例 #4
0
        public void RemovePostponedNotificationTest()
        {
            var notifier = new CustomNotifier();

            notifier.UpdatePositioner(NotificationPosition.TopRight, 1);

            var toasts = Enumerable.Range(0, 3).Select(_ => new CustomNotification(null, notifier)).ToList();
            var tasks  = toasts.Select(toast => notifier.ShowAsync(toast, 1)).ToList();

            toasts[2].Hide();
            tasks.ToList().ForEach(WaitWithDispatcher);
            Assert.AreEqual(NotificationResult.TimedOut, tasks[0].Result);
            Assert.AreEqual(NotificationResult.TimedOut, tasks[1].Result);
            Assert.AreEqual(NotificationResult.ApplicationHidden, tasks[2].Result);
        }
コード例 #5
0
        public void NotificationsArentLostOnPositionerUpdateTest()
        {
            var testScreen = new TestScreen {
                bounds = new Rect(0, 0, 1000, 500)
            };
            var notifier1  = new CustomNotifier(testScreen);
            var notifier2  = new CustomNotifier(testScreen);
            var positioner = CustomNotifier.positioner;

            notifier1.UpdatePositioner(NotificationPosition.BottomRight, 5);
            var toasts1 = Enumerable.Range(0, 1).Select(_ => new CustomNotification(null, notifier1)).ToList();
            var toasts2 = Enumerable.Range(0, 1).Select(_ => new CustomNotification(null, notifier2)).ToList();
            var tasks1  = toasts1.Select(toast => notifier1.ShowAsync(toast, 1)).ToList();
            var tasks2  = toasts2.Select(toast => notifier2.ShowAsync(toast, 1)).ToList();

            tasks1.Union(tasks2).ToList().ForEach(WaitWithDispatcher);
            tasks1.Union(tasks2).ToList().ForEach(t => Assert.AreEqual(NotificationResult.TimedOut, t.Result));
        }
コード例 #6
0
        public void ResolutionChangingTest()
        {
            var testScreen = new TestScreen {
                bounds = new Rect(0, 0, 1000, 500)
            };
            var notifier = new CustomNotifier(testScreen);

            notifier.UpdatePositioner(NotificationPosition.BottomRight, 2);
            var toasts = Enumerable.Range(0, 3).Select(_ => new CustomNotification(null, notifier)).ToList();
            var tasks  = toasts.Select(toast => notifier.ShowAsync(toast, 1)).ToList();

            Assert.AreEqual(2, CustomNotifier.positioner.Items.Count(i => i != null));

            testScreen.bounds = new Rect(0, 0, 800, 600);
            testScreen.Changed();

            Assert.AreEqual(2, CustomNotifier.positioner.Items.Count(i => i != null));

            tasks.ToList().ForEach(WaitWithDispatcher);
        }
コード例 #7
0
        public void UpdatePositionerTest()
        {
            var testScreen = new TestScreen {
                bounds = new Rect(0, 0, 800, 600)
            };
            var notifier = new CustomNotifier(testScreen);
            var pos      = CustomNotifier.positioner;

            var toast = new CustomNotification(null, notifier);
            var task  = notifier.ShowAsync(toast, 1);
            var p1    = CustomNotifier.positioner.GetItemPosition(CustomNotifier.positioner.Items[0]);

            Assert.AreEqual(415, p1.X);
            Assert.AreEqual(20, p1.Y);

            notifier.UpdatePositioner(NotificationPosition.BottomRight, 3);
            p1 = CustomNotifier.positioner.GetItemPosition(CustomNotifier.positioner.Items[0]);
            Assert.AreEqual(415, p1.X);
            Assert.AreEqual(490, p1.Y);

            WaitWithDispatcher(task);
        }
コード例 #8
0
        public void ResolutionChangingTest() {
            var testScreen = new TestScreen { bounds = new System.Drawing.Rectangle(0, 0, 1000, 500) };
            var notifier = new CustomNotifier(testScreen);
            notifier.UpdatePositioner(NotificationPosition.BottomRight, 2);
            var toasts = Enumerable.Range(0, 3).Select(_ => new CustomNotification(null, notifier)).ToList();
            var tasks = toasts.Select(toast => notifier.ShowAsync(toast, 1)).ToList();

            Assert.AreEqual(2, CustomNotifier.positioner.Items.Count(i => i != null));

            testScreen.bounds = new System.Drawing.Rectangle(0, 0, 800, 600);
            testScreen.Changed();

            Assert.AreEqual(2, CustomNotifier.positioner.Items.Count(i => i != null));

            tasks.ToList().ForEach(WaitWithDispatcher);
        }
コード例 #9
0
        public void UpdatePositionerTest() {
            var testScreen = new TestScreen { bounds = new System.Drawing.Rectangle(0, 0, 800, 600) };
            var notifier = new CustomNotifier(testScreen);
            var pos = CustomNotifier.positioner;

            var toast = new CustomNotification(null, notifier);
            var task = notifier.ShowAsync(toast, 1);
            var p1 = CustomNotifier.positioner.GetItemPosition(CustomNotifier.positioner.Items[0]);
            Assert.AreEqual(415, p1.X);
            Assert.AreEqual(20, p1.Y);

            notifier.UpdatePositioner(NotificationPosition.BottomRight, 3);
            p1 = CustomNotifier.positioner.GetItemPosition(CustomNotifier.positioner.Items[0]);
            Assert.AreEqual(415, p1.X);
            Assert.AreEqual(490, p1.Y);

            WaitWithDispatcher(task);
        }
コード例 #10
0
 public void NotificationsArentLostOnPositionerUpdateTest() {
     var testScreen = new TestScreen { bounds = new System.Drawing.Rectangle(0, 0, 1000, 500) };
     var notifier1 = new CustomNotifier(testScreen);
     var notifier2 = new CustomNotifier(testScreen);
     var positioner = CustomNotifier.positioner;
     notifier1.UpdatePositioner(NotificationPosition.BottomRight, 5);
     var toasts1 = Enumerable.Range(0, 1).Select(_ => new CustomNotification(null, notifier1)).ToList();
     var toasts2 = Enumerable.Range(0, 1).Select(_ => new CustomNotification(null, notifier2)).ToList();
     var tasks1 = toasts1.Select(toast => notifier1.ShowAsync(toast, 1)).ToList();
     var tasks2 = toasts2.Select(toast => notifier2.ShowAsync(toast, 1)).ToList();
     tasks1.Union(tasks2).ToList().ForEach(WaitWithDispatcher);
     tasks1.Union(tasks2).ToList().ForEach(t => Assert.AreEqual(NotificationResult.TimedOut, t.Result));
 }
コード例 #11
0
        public void BasicResolutionChangedHandlingTest() {
            var testScreen = new TestScreen { bounds = new System.Drawing.Rectangle(0, 0, 1000, 500) };
            var notifier = new CustomNotifier(testScreen);
            notifier.UpdatePositioner(NotificationPosition.BottomRight, 2);
            var toasts = Enumerable.Range(0, 3).Select(_ => new CustomNotification(null, notifier)).ToList();
            var tasks = toasts.Select(toast => notifier.ShowAsync(toast, 1)).ToList();

            var pos = CustomNotifier.positioner;
            var ps = pos.Items.Select(i => pos.GetItemPosition(i)).ToList();
            Assert.AreEqual(new Point(615, 390), ps[0]);
            Assert.AreEqual(new Point(615, 290), ps[1]);

            testScreen.bounds = new System.Drawing.Rectangle(0, 0, 800, 600);
            testScreen.Changed();
            pos = CustomNotifier.positioner;
            ps = pos.Items.Select(i => pos.GetItemPosition(i)).ToList();
            Assert.AreEqual(new Point(415, 490), ps[0]);
            Assert.AreEqual(new Point(415, 390), ps[1]);

            tasks.ToList().ForEach(WaitWithDispatcher);
            tasks.ToList().ForEach(t => Assert.AreEqual(NotificationResult.TimedOut, t.Result));
        }
コード例 #12
0
        public void RemovePostponedNotificationTest() {
            var notifier = new CustomNotifier();
            notifier.UpdatePositioner(NotificationPosition.TopRight, 1);

            var toasts = Enumerable.Range(0, 3).Select(_ => new CustomNotification(null, notifier)).ToList();
            var tasks = toasts.Select(toast => notifier.ShowAsync(toast, 1)).ToList();
            toasts[2].Hide();
            tasks.ToList().ForEach(WaitWithDispatcher);
            Assert.AreEqual(NotificationResult.TimedOut, tasks[0].Result);
            Assert.AreEqual(NotificationResult.TimedOut, tasks[1].Result);
            Assert.AreEqual(NotificationResult.ApplicationHidden, tasks[2].Result);
        }
コード例 #13
0
        public void ShowingTooManyToastsTest() {
            var notifier = new CustomNotifier();
            notifier.UpdatePositioner(NotificationPosition.TopRight, 100);

            var tasks = Enumerable.Range(0, 100).Select(_ => notifier.ShowAsync(new CustomNotification(null, notifier), 1)).ToList();
            tasks.ToList().ForEach(WaitWithDispatcher);
            tasks.ToList().ForEach(t => Assert.AreEqual(NotificationResult.TimedOut, t.Result));
        }
コード例 #14
0
        public void UpdatingPositionerTest() {
            CustomNotification toast;
            Task<NotificationResult> task;
            var notifier = new CustomNotifier();
            var tasks = Enumerable.Range(0, 5).Select(_ => notifier.ShowAsync(new CustomNotification(null, notifier), 1)).ToList();
            tasks.ToList().ForEach(WaitWithDispatcher);
            tasks.ToList().ForEach(t => Assert.AreEqual(NotificationResult.TimedOut, t.Result));

            toast = new CustomNotification(null, notifier);
            task = notifier.ShowAsync(toast, 1);
            notifier.UpdatePositioner(NotificationPosition.TopRight, 2);
            WaitWithDispatcher(task);
            Assert.AreEqual(NotificationResult.TimedOut, task.Result);
            tasks = Enumerable.Range(0, 10).Select(_ => notifier.ShowAsync(new CustomNotification(null, notifier), 1)).ToList();
            notifier.UpdatePositioner(NotificationPosition.TopRight, 2);
            tasks.ToList().ForEach(WaitWithDispatcher);
            tasks.ToList().ForEach(t => Assert.AreEqual(NotificationResult.TimedOut, t.Result));
        }
コード例 #15
0
 void UpdateCustomNotifierPositioner()
 {
     CustomNotifier.UpdatePositioner(CustomNotificationPosition, CustomNotificationVisibleMaxCount);
 }