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

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

            IUser originalApprover = (IUser)OguObjectSettings.GetConfig().Objects[OguObject.approver1.ToString()].Object;

            normalActDesp.Resources.Clear();
            normalActDesp.Resources.Add(new WfUserResourceDescriptor(originalApprover));

            IWfProcess process = WfProcessTestCommon.StartupProcess(processDesp);

            WfProcessTestCommon.MoveToNextDefaultActivityWithExecutor(process);

            process = WfRuntime.GetProcessByProcessID(process.ID);

            IUser newApprover = (IUser)OguObjectSettings.GetConfig().Objects[OguObject.approver2.ToString()].Object;

            WfReplaceAssigneesExecutor executor = new WfReplaceAssigneesExecutor(process.CurrentActivity, process.CurrentActivity, originalApprover, new IUser[] { newApprover });

            executor.Execute();

            process = WfRuntime.GetProcessByProcessID(process.ID);

            UserTaskCollection tasks = UserTaskAdapter.Instance.LoadUserTasks(build => build.AppendItem("ACTIVITY_ID", process.CurrentActivity.ID));

            Assert.AreEqual(1, tasks.Count);
            Assert.AreEqual(newApprover.ID, tasks[0].SendToUserID);
        }