public void MainStreamActivitiesWithAmountCondition() { IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptorWithCondition(); IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp); process.ApplicationRuntimeParameters["Amount"] = 2500; WfMainStreamActivityDescriptorCollection mainActs = process.GetMainStreamActivities(true); mainActs.Output("不经过领导的主线活动"); Assert.IsTrue(mainActs.ContainsKey("NormalActivity")); Assert.IsFalse(mainActs.ContainsKey("ManagerActivity")); //改变条件 process.ApplicationRuntimeParameters["Amount"] = 10000; mainActs = process.GetMainStreamActivities(true); mainActs.Output("经过领导的主线活动"); Assert.IsTrue(mainActs.ContainsKey("NormalActivity")); Assert.IsTrue(mainActs.ContainsKey("ManagerActivity")); }
public void AddActivityWithConsignExecutorTest() { IWfProcess process = WfProcessTestCommon.StartupSimpleProcess(); int originalActCount = process.Activities.Count; IWfActivity targetActivity = process.Activities.FindActivityByDescriptorKey("NormalActivity"); WfActivityDescriptorCreateParams createParams = new WfActivityDescriptorCreateParams(); createParams.AllAgreeWhenConsign = true; createParams.Users = new OguDataCollection <IUser>(); createParams.Users.Add((IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object); createParams.Users.Add((IUser)OguObjectSettings.GetConfig().Objects["approver2"].Object); WfAddActivityExecutor executor = new WfAddActivityExecutor(process.CurrentActivity, targetActivity, createParams); executor.Execute(); Assert.AreEqual(originalActCount + 1, process.Activities.Count); WfMainStreamActivityDescriptorCollection processDespMSA = process.Descriptor.GetMainStreamActivities(); WfMainStreamActivityDescriptorCollection processMSA = process.GetMainStreamActivities(true); processDespMSA.Output("流程描述中的主线活动"); processMSA.Output("主线流程中的主线活动"); Assert.AreEqual(1, executor.AddedActivity.Descriptor.BranchProcessTemplates.Count); Assert.AreEqual(1, executor.AddedActivity.GetMainStreamActivityDescriptor().BranchProcessTemplates.Count); Assert.AreEqual(process.Descriptor.Activities.Count, process.MainStream.Activities.Count); Assert.AreEqual(processDespMSA.Count, processMSA.Count); }
public void BasicAddActivityExecutorTest() { IWfProcess process = WfProcessTestCommon.StartupSimpleProcess(); int originalActCount = process.Activities.Count; IWfActivity targetActivity = process.Activities.FindActivityByDescriptorKey("NormalActivity"); WfActivityDescriptorCreateParams createParams = new WfActivityDescriptorCreateParams(); WfAddActivityExecutor executor = new WfAddActivityExecutor(process.CurrentActivity, targetActivity, createParams); executor.Execute(); Assert.IsNotNull(executor.AddedActivity.GetMainStreamActivityDescriptor()); Assert.AreEqual(originalActCount + 1, process.Activities.Count); 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); }
public void BaseAddApproverExecutorOnlyAddApproverModeTest() { IWfProcess process = WfProcessTestCommon.StartupSimpleProcess(); int originalActCount = process.Activities.Count; WfProcessTestCommon.MoveToNextDefaultActivity(process); IWfActivity targetActivity = process.Activities.FindActivityByDescriptorKey("NormalActivity"); WfAddApproverExecutor executor = new WfAddApproverExecutor(process.CurrentActivity, targetActivity); executor.AddApproverMode = WfAddApproverMode.OnlyAddApprover; executor.Assignees.Add((IUser)OguObjectSettings.GetConfig().Objects[OguObject.approver1.ToString()].Object); executor.Execute(); Assert.AreEqual(originalActCount + 1, process.Activities.Count); Assert.AreEqual(originalActCount + 1, process.MainStream.Activities.Count); WfMainStreamActivityDescriptorCollection processDespMSA = process.Descriptor.GetMainStreamActivities(); WfMainStreamActivityDescriptorCollection processMSA = process.GetMainStreamActivities(true); processDespMSA.Output("流程描述中的主线活动"); processMSA.Output("主线流程中的主线活动"); }
public void BaseAddApproverExecutorStandardModeWithWithdrawTest() { IWfProcess process = WfProcessTestCommon.StartupSimpleProcess(); int originalActCount = process.Activities.Count; WfProcessTestCommon.MoveToNextDefaultActivity(process); int originalElapsedActCount = process.ElapsedActivities.Count; IWfActivity targetActivity = process.Activities.FindActivityByDescriptorKey("NormalActivity"); WfAddApproverExecutor executor = new WfAddApproverExecutor(process.CurrentActivity, targetActivity); executor.Assignees.Add((IUser)OguObjectSettings.GetConfig().Objects[OguObject.approver1.ToString()].Object); executor.Execute(); Console.WriteLine("Elapsed activities: {0}", process.ElapsedActivities.Count); process = WfRuntime.GetProcessByProcessID(process.ID); WfWithdrawExecutor withdrawExecutor = new WfWithdrawExecutor(process.CurrentActivity, process.CurrentActivity); withdrawExecutor.Execute(); Console.WriteLine("Elapsed activities: {0}", process.ElapsedActivities.Count); Assert.AreEqual(originalElapsedActCount, process.ElapsedActivities.Count); Assert.AreEqual(originalActCount, process.Activities.Count, "撤回后,恢复为加签之前的状态"); Assert.AreEqual(originalActCount, process.MainStream.Activities.Count, "撤回后,主线流程的活动也没有变化"); WfMainStreamActivityDescriptorCollection processDespMSA = process.Descriptor.GetMainStreamActivities(); WfMainStreamActivityDescriptorCollection processMSA = process.GetMainStreamActivities(true); processDespMSA.Output("流程描述中的主线活动"); processMSA.Output("主线流程中的主线活动"); }
public void AddActivityWithTwoOutTransitionsExecutorTest() { IWfProcess process = WfProcessTestCommon.StartupSimpleProcess(); int originalActCount = process.Activities.Count; IWfActivity targetActivity = process.Activities.FindActivityByDescriptorKey("NormalActivity"); targetActivity.Descriptor.ToTransitions.FirstOrDefault().Properties.SetValue("Name", "同意"); //增加一条出线 IWfTransitionDescriptor tReturn = targetActivity.Descriptor.ToTransitions.AddBackwardTransition(process.InitialActivity.Descriptor); tReturn.Properties.SetValue("Name", "不同意"); WfActivityDescriptorCreateParams createParams = new WfActivityDescriptorCreateParams(); createParams.AllAgreeWhenConsign = false; createParams.Users = new OguDataCollection <IUser>(); createParams.Users.Add((IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object); WfAddActivityExecutor executor = new WfAddActivityExecutor(process.CurrentActivity, targetActivity, createParams); executor.Execute(); process = WfRuntime.GetProcessByProcessID(process.ID); IWfActivity addedActivity = process.Activities[executor.AddedActivity.ID]; targetActivity = process.Activities.FindActivityByDescriptorKey("NormalActivity"); Assert.AreEqual(originalActCount + 1, process.Activities.Count); Assert.AreEqual(1, targetActivity.Descriptor.ToTransitions.Count); Assert.IsFalse(targetActivity.Descriptor.ToTransitions[0].IsBackward); Assert.AreEqual(2, addedActivity.Descriptor.ToTransitions.Count, "新加的活动应该也有两条出线"); Assert.AreEqual("同意", addedActivity.Descriptor.ToTransitions[0].Name); Assert.AreEqual("不同意", addedActivity.Descriptor.ToTransitions[1].Name); 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); }
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]); }