Ejemplo n.º 1
0
        public virtual void TestDecorateCandidateGroups()
        {
            // given
            IList <string> aCandidateGroupList = new List <string>();

            aCandidateGroupList.Add("management");
            aCandidateGroupList.Add("accounting");
            aCandidateGroupList.Add("backoffice");

            foreach (var candidateGroup in aCandidateGroupList)
            {
                var candidateGroupExpression = ExpressionManager.CreateExpression(candidateGroup);
                TaskDefinition.AddCandidateGroupIdExpression(candidateGroupExpression);
            }

            // 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 groupId = identityLink.GroupId;
                if ("management".Equals(groupId))
                {
                    Assert.AreEqual("management", groupId);
                }
                else if ("accounting".Equals(groupId))
                {
                    Assert.AreEqual("accounting", groupId);
                }
                else if ("backoffice".Equals(groupId))
                {
                    Assert.AreEqual("backoffice", groupId);
                }
                else
                {
                    Assert.Fail("Unexpected group: " + groupId);
                }
            }
        }