Esempio n. 1
0
        public void BasicDeleteActivityExecutorTest()
        {
            IWfProcess process = WfProcessTestCommon.StartupSimpleProcess();

            int originalActCount = process.Activities.Count;

            IWfActivity targetActivity = process.Activities.FindActivityByDescriptorKey("NormalActivity");

            WfActivityDescriptorCreateParams createParams = new WfActivityDescriptorCreateParams();

            WfAddActivityExecutor addExecutor = new WfAddActivityExecutor(process.CurrentActivity, targetActivity, createParams);

            addExecutor.Execute();

            IWfActivityDescriptor newActDesp = targetActivity.Descriptor.ToTransitions.FirstOrDefault().ToActivity;

            WfRuntime.ClearCache();

            process = WfRuntime.GetProcessByProcessID(process.ID);

            targetActivity = process.Activities.FindActivityByDescriptorKey(newActDesp.Key);
            WfDeleteActivityExecutor deleteExecutor = new WfDeleteActivityExecutor(process.CurrentActivity, targetActivity);

            deleteExecutor.Execute();

            WfMainStreamActivityDescriptorCollection processDespMSA = process.Descriptor.GetMainStreamActivities();
            WfMainStreamActivityDescriptorCollection processMSA     = process.GetMainStreamActivities(true);

            processDespMSA.Output("流程描述中的主线活动");
            processMSA.Output("主线流程中的主线活动");

            Assert.AreEqual(process.Descriptor.Activities.Count, process.MainStream.Activities.Count);
            Assert.AreEqual(processDespMSA.Count, processMSA.Count);

            Assert.IsNull(process.Activities.FindActivityByDescriptorKey(targetActivity.Descriptor.Key));
            Assert.IsNull(process.MainStream.Activities[targetActivity.MainStreamActivityKey]);
        }