Exemplo n.º 1
0
        public void ClearThenResetInitialActivitySecretaryTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            processDesp.InitialActivity.Properties.SetValue("AutoAppendSecretary", true);

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            ChangeActivityResource(process.Descriptor.InitialActivity, (IUser)OguObjectSettings.GetConfig().Objects["ceo"].Object);
            WfRuntime.DecorateProcess(process);

            ChangeActivityResource(process.Descriptor.Activities["Initial"], (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object);
            WfRuntime.DecorateProcess(process);

            OutputProcessCandidates(process);
            ReturnExecutorTestHelper.OutputMainStream(process);

            Assert.AreEqual(3, processDesp.Activities.Count);
            Assert.AreEqual(process.InitialActivity.Descriptor.Key, process.Descriptor.InitialActivity.Key);
            Assert.AreEqual(WfActivityType.InitialActivity, process.Descriptor.InitialActivity.ActivityType);
            Assert.AreEqual(WfActivityType.InitialActivity, process.Descriptor.Activities["Initial"].ActivityType);

            Assert.AreEqual(3, process.MainStream.Activities.Count);
            Assert.AreEqual(WfActivityType.InitialActivity, process.MainStream.InitialActivity.ActivityType);
        }
Exemplo n.º 2
0
        public void SimpleSecretaryWithReturnLineTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptorWithSecretaryAndReturnLine();

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            OutputProcessCandidates(process);
            ReturnExecutorTestHelper.OutputMainStream(process);

            Assert.AreEqual(5, processDesp.Activities.Count);
            Assert.AreEqual(5, process.MainStream.Activities.Count);

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

            IWfActivityDescriptor firstSecretary = normalActivity.Descriptor.FromTransitions.FirstOrDefault().FromActivity;

            Assert.AreEqual(1, firstSecretary.ToTransitions.Count);

            IWfActivityDescriptor secondSecretary = normalActivity.Descriptor.ToTransitions.FirstOrDefault().ToActivity;

            Assert.AreEqual(2, secondSecretary.ToTransitions.Count);

            Assert.AreEqual(2, normalActivity.Descriptor.ToTransitions.Count);

            foreach (IWfTransitionDescriptor transition in normalActivity.Descriptor.ToTransitions)
            {
                Assert.AreEqual(secondSecretary.Key, transition.ToActivity.Key);
            }
        }
Exemplo n.º 3
0
        public void ParallelBranchActivitySecretaryTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptorWithBranchTemplate();

            IWfBranchProcessTemplateDescriptor template = processDesp.Activities["NormalActivity"].BranchProcessTemplates["Consign"];

            template.Resources.Clear();
            template.Resources.Add(new WfUserResourceDescriptor((IUser)OguObjectSettings.GetConfig().Objects["ceo"].Object));

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            WfProcessTestCommon.MoveToNextDefaultActivity(process);

            IWfProcess consignBranchProcess    = process.Activities.FindActivityByDescriptorKey("NormalActivity").BranchProcessGroups["Consign"].Branches.FirstOrDefault();
            IWfProcess distributeBranchProcess = process.Activities.FindActivityByDescriptorKey("NormalActivity").BranchProcessGroups["Distribute"].Branches.FirstOrDefault();

            Console.WriteLine("Consign Process");
            OutputProcessCandidates(consignBranchProcess);
            ReturnExecutorTestHelper.OutputMainStream(consignBranchProcess);

            Console.WriteLine("");

            Console.WriteLine("Distribute Process");
            OutputProcessCandidates(distributeBranchProcess);
            ReturnExecutorTestHelper.OutputMainStream(distributeBranchProcess);

            Assert.AreEqual(4, consignBranchProcess.Activities.Count);
            Assert.AreEqual(2, distributeBranchProcess.Activities.Count);

            Assert.AreEqual(4, consignBranchProcess.MainStream.Activities.Count);
            Assert.AreEqual(2, distributeBranchProcess.MainStream.Activities.Count);
        }
Exemplo n.º 4
0
        public void ChangeLeaderToApproverThenChangeToLeaderSecretaryTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptorWithSecretary();

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            ChangeActivityResource(process.Descriptor.Activities["NormalActivity"], (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object);

            WfRuntime.DecorateProcess(process);

            Console.WriteLine("没有秘书的");
            OutputProcessCandidates(process);
            ReturnExecutorTestHelper.OutputMainStream(process);

            ChangeActivityResource(process.Descriptor.Activities["NormalActivity"], (IUser)OguObjectSettings.GetConfig().Objects["ceo"].Object);

            WfRuntime.DecorateProcess(process);

            Console.WriteLine("有秘书的");
            OutputProcessCandidates(process);
            ReturnExecutorTestHelper.OutputMainStream(process);

            Assert.AreEqual(5, processDesp.Activities.Count);
            Assert.AreEqual(5, process.MainStream.Activities.Count);
        }
Exemplo n.º 5
0
        public void SimpleSecretaryTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptorWithSecretary();

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            OutputProcessCandidates(process);
            ReturnExecutorTestHelper.OutputMainStream(process);

            Assert.AreEqual(5, processDesp.Activities.Count);
            Assert.AreEqual(5, process.MainStream.Activities.Count);
        }
Exemplo n.º 6
0
        public void ChangeGenerateSimpleSecretaryTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptorWithSecretary();

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            ChangeActivityResource(process.Descriptor.Activities["NormalActivity"], (IUser)OguObjectSettings.GetConfig().Objects["vp"].Object);

            WfRuntime.DecorateProcess(process);

            OutputProcessCandidates(process);
            ReturnExecutorTestHelper.OutputMainStream(process);

            Assert.AreEqual(5, processDesp.Activities.Count);
            Assert.AreEqual(5, process.MainStream.Activities.Count);
        }
Exemplo n.º 7
0
        public void ActiveMatrixResourceTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.GetDynamicProcessDesp();
            IWfProcess           process     = WfProcessTestCommon.StartupProcess(processDesp, new Dictionary <string, object>()
            {
                { "CostCenter", "1001" },
                { "PayMethod", "1" },
                { "Age", 30 }
            });

            Console.WriteLine(process.Activities.Count);

            ReturnExecutorTestHelper.OutputMainStream(process);
            ReturnExecutorTestHelper.OutputEveryActivities(process);

            Assert.AreEqual(4, process.Activities.Count);
        }
Exemplo n.º 8
0
        public void DynamicActivityWithActivityMatrixReturnToInitialTest()
        {
            IRole role = PrepareSOARole();

            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            IWfActivityDescriptor templateActDesp = processDesp.Activities["NormalActivity"];

            FillDynamicActivitySimpleResource(templateActDesp, new WfResourceDescriptorCollection()
            {
                new WfRoleResourceDescriptor(role)
            });

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp, new Dictionary <string, object>()
            {
                { "CostCenter", "1001" }
            });

            //到第一个动态活动
            WfProcessTestCommon.MoveToNextDefaultActivityWithExecutor(process);

            process = WfRuntime.GetProcessByProcessID(process.ID);

            //到第二个动态活动
            WfProcessTestCommon.MoveToNextDefaultActivityWithExecutor(process);

            process = WfRuntime.GetProcessByProcessID(process.ID);

            //退回到起始点
            ReturnExecutorTestHelper.ExecuteReturnOperation(process.CurrentActivity, process.InitialActivity.Descriptor.Key);

            process = WfRuntime.GetProcessByProcessID(process.ID);

            Console.WriteLine(process.CurrentActivity.Descriptor.Key);
            Console.WriteLine(process.CompletedActivity.Descriptor.FromTransitions.GetAllCanTransitForwardTransitions().Count);

            ReturnExecutorTestHelper.OutputMainStream(process);
            ReturnExecutorTestHelper.OutputEveryActivities(process);

            Assert.AreEqual(1, process.CompletedActivity.Descriptor.FromTransitions.GetAllCanTransitForwardTransitions().Count,
                            "结束点应该只有一条有效的入线s");

            Assert.AreEqual(process.InitialActivity.Descriptor.Key, process.CurrentActivity.Descriptor.AssociatedActivityKey);
        }
Exemplo n.º 9
0
        public void BasicDynamicActivityReturnTest()
        {
            IWfProcessDescriptor processDesp = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            IWfActivityDescriptor templateActDesp = processDesp.Activities["NormalActivity"];

            FillDynamicActivitySimpleResource(templateActDesp, (IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object);

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            ReturnExecutorTestHelper.OutputMainStream(process);

            ReturnExecutorTestHelper.OutputEveryActivities(process);

            WfProcessTestCommon.MoveToNextDefaultActivity(process);
            ReturnExecutorTestHelper.ExecuteReturnOperation(process.CurrentActivity, processDesp.InitialActivity.Key);

            //N2(Initial)->N1->N4->N5->Completed
            ReturnExecutorTestHelper.OutputMainStream(process);

            //N1->N2(Initial)->N4->N5->Completed
            ReturnExecutorTestHelper.OutputEveryActivities(process);

            Assert.AreEqual("Initial", process.CurrentActivity.Descriptor.GetAssociatedActivity().Key);
            Assert.AreEqual(2, process.CurrentActivity.Descriptor.ToTransitions.Count);

            WfProcessTestCommon.MoveToNextDefaultActivity(process);
            //Assert.AreEqual("N4", process.CurrentActivity.Descriptor.Key); //To N4

            //N2(Initial)->N1->N4->N5->Completed
            ReturnExecutorTestHelper.OutputMainStream(process);

            //N1->N2(Initial)->N4->N5->Completed
            ReturnExecutorTestHelper.OutputEveryActivities(process);

            //IWfActivityDescriptor firstDynamicActDesp = ValidateDynamicActivities(process.InitialActivity.Descriptor, templateActDesp);

            //ValidateInDynamicTransitionsProperties(firstDynamicActDesp.FromTransitions, templateActDesp);

            //ValidateLastDynamicTransitions(templateActDesp);

            //ValidateTemplateCandidatesAndDynamicActivityCandidates(firstDynamicActDesp, templateActDesp);
        }