public void ReturnOnceThenWithdrawTest()
        {
            IWfActivity activityD = ReturnExecutorTestHelper.PrepareAndMoveToSpecialActivity();

            int originalActivityCount = activityD.Process.Activities.Count;

            Assert.AreEqual("D", activityD.Descriptor.Key);
            ReturnExecutorTestHelper.OutputMainStream(activityD.Process);
            ReturnExecutorTestHelper.OutputEveryActivities(activityD.Process);

            ReturnExecutorTestHelper.ExecuteReturnOperation(activityD, "A");

            Console.WriteLine("退件之后");
            ReturnExecutorTestHelper.OutputMainStream(activityD.Process);
            ReturnExecutorTestHelper.OutputEveryActivities(activityD.Process);

            IWfProcess process = DoWithdrawExecutor(activityD.Process);

            Console.WriteLine("撤回之后");
            ReturnExecutorTestHelper.OutputMainStream(process);
            ReturnExecutorTestHelper.OutputEveryActivities(process);

            Assert.AreEqual(originalActivityCount, process.Activities.Count, "撤回后与退件前的活动数一样");
            Assert.AreEqual(originalActivityCount, process.Descriptor.Activities.Count, "撤回后与退件前的活动数一样");
        }
        public void ReturnTwiceTest()
        {
            IWfActivity activityD = ReturnExecutorTestHelper.PrepareAndMoveToSpecialActivity();

            Assert.AreEqual("D", activityD.Descriptor.Key);
            ReturnExecutorTestHelper.OutputMainStream(activityD.Process);
            ReturnExecutorTestHelper.OutputEveryActivities(activityD.Process);

            //第一次退回
            ReturnExecutorTestHelper.ExecuteReturnOperation(activityD, "A");

            Console.WriteLine("第一次退回后");
            ReturnExecutorTestHelper.OutputMainStream(activityD.Process);
            ReturnExecutorTestHelper.OutputEveryActivities(activityD.Process);

            WfProcessTestCommon.MoveToNextDefaultActivity(activityD.Process);   //B1
            WfProcessTestCommon.MoveToNextDefaultActivity(activityD.Process);   //C1
            WfProcessTestCommon.MoveToNextDefaultActivity(activityD.Process);   //D1

            Assert.AreEqual("D", activityD.Process.CurrentActivity.Descriptor.AssociatedActivityKey);

            //在B的出线C和E之间选择E
            activityD.Process.ApplicationRuntimeParameters["IsCLine"] = false;

            //第二次退回
            ReturnExecutorTestHelper.ExecuteReturnOperation(activityD, "A");

            Console.WriteLine("第二次退回后");
            ReturnExecutorTestHelper.OutputMainStream(activityD.Process);
            ReturnExecutorTestHelper.OutputEveryActivities(activityD.Process);

            ReturnExecutorTestHelper.ValidateMainStreamActivities(activityD.Process, "A", "B", "E", "D", "F");
        }
        public void ReturnTwiceThenWithdrawTwiceTest()
        {
            IWfActivity activityD = ReturnExecutorTestHelper.PrepareAndMoveToSpecialActivity();

            int originalActivityCount = activityD.Process.Activities.Count;

            Assert.AreEqual("D", activityD.Descriptor.Key);
            ReturnExecutorTestHelper.OutputMainStream(activityD.Process);
            ReturnExecutorTestHelper.OutputEveryActivities(activityD.Process);

            //第一次退回
            ReturnExecutorTestHelper.ExecuteReturnOperation(activityD, "A");

            Console.WriteLine("第一次退回后");
            ReturnExecutorTestHelper.OutputMainStream(activityD.Process);
            ReturnExecutorTestHelper.OutputEveryActivities(activityD.Process);

            WfProcessTestCommon.MoveToNextDefaultActivity(activityD.Process);   //B1
            WfProcessTestCommon.MoveToNextDefaultActivity(activityD.Process);   //C1
            WfProcessTestCommon.MoveToNextDefaultActivity(activityD.Process);   //D1

            Assert.AreEqual("D", activityD.Process.CurrentActivity.Descriptor.AssociatedActivityKey);

            //在B的出线C和E之间选择E
            activityD.Process.ApplicationRuntimeParameters["IsCLine"] = false;

            //第二次退回
            ReturnExecutorTestHelper.ExecuteReturnOperation(activityD, "A");

            Console.WriteLine("第二次退回后");
            ReturnExecutorTestHelper.OutputMainStream(activityD.Process);
            ReturnExecutorTestHelper.OutputEveryActivities(activityD.Process);

            IWfProcess process = process = DoWithdrawExecutor(activityD.Process);

            Console.WriteLine("第一组撤回之后");
            ReturnExecutorTestHelper.OutputMainStream(process);
            ReturnExecutorTestHelper.OutputEveryActivities(process);

            process = DoWithdrawExecutor(activityD.Process);    //C1;
            process = DoWithdrawExecutor(activityD.Process);    //B1
            process = DoWithdrawExecutor(activityD.Process);    //A1

            process = DoWithdrawExecutor(activityD.Process);

            Console.WriteLine("第二组撤回之后");
            ReturnExecutorTestHelper.OutputMainStream(process);
            ReturnExecutorTestHelper.OutputEveryActivities(process);

            Assert.AreEqual(originalActivityCount, process.Activities.Count, "撤回后与退件前的活动数一样");
            Assert.AreEqual(originalActivityCount, process.Descriptor.Activities.Count, "撤回后与退件前的活动数一样");
        }
        public void ReturnOnceTest()
        {
            IWfActivity activityD = ReturnExecutorTestHelper.PrepareAndMoveToSpecialActivity();

            Assert.AreEqual("D", activityD.Descriptor.Key);
            ReturnExecutorTestHelper.OutputMainStream(activityD.Process);
            ReturnExecutorTestHelper.OutputEveryActivities(activityD.Process);

            ReturnExecutorTestHelper.ValidateMainStreamActivities(activityD.Process, "A", "B", "C", "D", "F");

            ReturnExecutorTestHelper.ExecuteReturnOperation(activityD, "A");

            IWfActivity returnedActivity = activityD.Process.CurrentActivity;

            Assert.AreEqual("A", returnedActivity.Descriptor.AssociatedActivityKey);
            Assert.AreEqual(activityD.ID, returnedActivity.CreatorInstanceID);
            ReturnExecutorTestHelper.ValidateBRelativeActivityOutTransitions(activityD.Process.CurrentActivity);

            ReturnExecutorTestHelper.OutputMainStream(activityD.Process);
            ReturnExecutorTestHelper.OutputEveryActivities(activityD.Process);

            ReturnExecutorTestHelper.ValidateMainStreamActivities(activityD.Process, "A", "B", "C", "D", "F");
        }