public void pauseAndResumeFromTaskTreeTest()
        {
            SyncTriggerSystem system = createSystem();
            SyncTask          task   = system.doTask("Use",
                                                     useAction1,//在AskTask暂停了
                                                     useAction2);

            void useAction1(CardEngine g1)
            {
                g1.trigger.doTask("Ask",
                                  askAction1,
                                  askAction2);
                void askAction1(CardEngine g2)
                {
                    g2.trigger.currentTask.parent.context["i"] = 1;
                }

                void askAction2(CardEngine g2)
                {
                    g2.trigger.pauseTask(g2.trigger.currentTask);
                }
            }

            void useAction2(CardEngine g1)
            {
                g1.trigger.currentTask.context["i"] = 2;
            }

            Assert.AreEqual(1, task.context["i"]);
            Assert.AreEqual(1, system.getPausedTasks().Count());
            system.resumeTask(system.getPausedTasks().First());
            Assert.AreEqual(2, task.context["i"]);
            Assert.AreEqual(0, system.getPausedTasks().Count());
        }
        public void pauseAndResumeTest()
        {
            SyncTriggerSystem system = createSystem();
            int i    = 0;
            var task = system.doTask(
                game => i++,
                game => i++,
                game => game.trigger.pauseTask(game.trigger.currentTask),
                game => i++);

            Assert.Null(system.currentTask);
            Assert.AreEqual(SyncTaskState.paused, task.state);
            Assert.AreEqual(task, system.getPausedTasks()[0]);
            Assert.AreEqual(2, i);

            system.resumeTask(task);

            Assert.AreEqual(SyncTaskState.finished, task.state);
            Assert.AreEqual(0, system.getPausedTasks().Length);
            Assert.AreEqual(3, i);
        }