public void DispatcherServiceTest() {
#endif
            TestVM vm = new TestVM();
            UserControl control = new UserControl() { DataContext = vm };
            DispatcherService service = new DispatcherService();
            Interactivity.Interaction.GetBehaviors(control).Add(service);
            Window.Content = control;
#if NETFX_CORE
            await EnqueueShowWindow();
#else
            EnqueueShowWindow();
#endif
            EnqueueCallback(() => {
                Assert.IsFalse(vm.IsProgress);
                vm.Calculate();
                Assert.IsTrue(vm.IsProgress);
            });
#if NETFX_CORE
            await WaitConditional(() => vm.Task.IsCompleted);
#else
            EnqueueWait(() => vm.Task.IsCompleted);
#endif
            EnqueueWindowUpdateLayout();
            EnqueueCallback(() => {
#if !NETFX_CORE
                DispatcherHelper.DoEvents();
#endif
                Assert.IsFalse(vm.IsProgress);
                Assert.IsTrue(vm.IsCompleted);
            });
            EnqueueTestComplete();
        }
Example #2
0
        public void DispatcherServiceTest()
        {
            TestVM      vm      = new TestVM();
            UserControl control = new UserControl()
            {
                DataContext = vm
            };
            DispatcherService service = new DispatcherService();

            Interactivity.Interaction.GetBehaviors(control).Add(service);
            Window.Content = control;
            EnqueueShowWindow();
            EnqueueCallback(() => {
                Assert.IsFalse(vm.IsProgress);
                vm.Calculate();
                Assert.IsTrue(vm.IsProgress);
            });
            EnqueueWait(() => vm.Task.IsCompleted);
            EnqueueWindowUpdateLayout();
            EnqueueCallback(() => {
                DispatcherHelper.DoEvents();
                Assert.IsFalse(vm.IsProgress);
                Assert.IsTrue(vm.IsCompleted);
            });
            EnqueueTestComplete();
        }