Exemplo n.º 1
0
        public void TestStackedActions()
        {
            // Start tracked task A
            using (BackgroundTaskTracker.BeginTask("TestTaskA"))
            {
                // Start tracked task B
                using (BackgroundTaskTracker.BeginTask("TestTaskB"))
                {
                    // Should reflect action pending
                    Assert.IsTrue(BackgroundTaskTracker.Instance.ActionsPending);

                    // Should reflect 0 completion
                    Assert.AreEqual(BackgroundTaskTracker.Instance.CompletionProgress, 0);

                    // Should reflect task name as decription
                    Assert.AreEqual(BackgroundTaskTracker.Instance.CurrentActionDescription, "TestTaskB");

                    // Start tracked task C
                    using (BackgroundTaskTracker.BeginTask("TestTaskC"))
                    {
                        // Should reflect action pending
                        Assert.IsTrue(BackgroundTaskTracker.Instance.ActionsPending);

                        // Should reflect 0 completion
                        Assert.AreEqual(BackgroundTaskTracker.Instance.CompletionProgress, 0);

                        // Should reflect task name as decription
                        Assert.AreEqual(BackgroundTaskTracker.Instance.CurrentActionDescription, "TestTaskC");
                    }

                    // Complete C

                    // Should reflect 33% completion
                    Assert.AreEqual(BackgroundTaskTracker.Instance.CompletionProgress, 33);

                    // Should reflect task name B as decription
                    Assert.AreEqual(BackgroundTaskTracker.Instance.CurrentActionDescription, "TestTaskB");
                }

                // Complete B

                // Should reflect 66% completion
                Assert.AreEqual(BackgroundTaskTracker.Instance.CompletionProgress, 66);

                // Should reflect task name B as decription
                Assert.AreEqual(BackgroundTaskTracker.Instance.CurrentActionDescription, "TestTaskA");
            }
            // Tasks now complete
            // Verify no action state
            VerifyNoActionState();
        }
Exemplo n.º 2
0
        public void TestSingleAction()
        {
            // Start a tracked task
            using (BackgroundTaskTracker.BeginTask("TestTaskA"))
            {
                // Should reflect action pending
                Assert.IsTrue(BackgroundTaskTracker.Instance.ActionsPending);

                // Should reflect 0 completion
                Assert.AreEqual(BackgroundTaskTracker.Instance.CompletionProgress, 0);

                // Should reflect task name as decription
                Assert.AreEqual(BackgroundTaskTracker.Instance.CurrentActionDescription, "TestTaskA");
            }

            // Task now complete
            // Verify no action state
            VerifyNoActionState();
        }