コード例 #1
0
ファイル: TaskDecoratorTest.cs プロジェクト: zf321/ESS.FW.Bpm
        public virtual void TestDecorateCandidateUsers()
        {
            // given
            IList <string> aCandidateUserList = new List <string>();

            aCandidateUserList.Add("john");
            aCandidateUserList.Add("peter");
            aCandidateUserList.Add("mary");

            foreach (var candidateUser in aCandidateUserList)
            {
                var candidateUserExpression = ExpressionManager.CreateExpression(candidateUser);
                TaskDefinition.AddCandidateUserIdExpression(candidateUserExpression);
            }

            // when
            Decorate(Task, TaskDecorator);

            // then
            var candidates = Task.Candidates;

            Assert.AreEqual(3, candidates.Count);

            foreach (var identityLink in candidates)
            {
                var taskId = identityLink.TaskId;
                Assert.AreEqual(Task.Id, taskId);

                Assert.AreEqual(IdentityLinkType.Candidate, identityLink.Type);

                var userId = identityLink.UserId;
                if ("john".Equals(userId))
                {
                    Assert.AreEqual("john", userId);
                }
                else if ("peter".Equals(userId))
                {
                    Assert.AreEqual("peter", userId);
                }
                else if ("mary".Equals(userId))
                {
                    Assert.AreEqual("mary", userId);
                }
                else
                {
                    Assert.Fail("Unexpected user: " + userId);
                }
            }
        }