protected void AssertBlockListCandidates(IEmployer employer, CandidateBlockList blockList, ICollection<Member> blockedMembers, ICollection<Member> notBlockedMembers)
        {
            // IsBlocked

            foreach (var member in blockedMembers)
                Assert.IsTrue(_candidateBlockListsQuery.IsBlocked(employer, blockList.Id, member.Id));
            foreach (var member in notBlockedMembers)
                Assert.IsFalse(_candidateBlockListsQuery.IsBlocked(employer, blockList.Id, member.Id));

            if (blockList.BlockListType == BlockListType.Permanent)
            {
                foreach (var member in blockedMembers)
                    Assert.IsTrue(_candidateBlockListsQuery.IsPermanentlyBlocked(employer, member.Id));
                foreach (var member in notBlockedMembers)
                    Assert.IsFalse(_candidateBlockListsQuery.IsPermanentlyBlocked(employer, member.Id));
            }

            // GetBlockedCandidateIds

            Assert.IsTrue((from m in blockedMembers select m.Id).CollectionEqual(_candidateBlockListsQuery.GetBlockedCandidateIds(employer, blockList.Id)));
            if (blockList.BlockListType == BlockListType.Permanent)
                Assert.IsTrue((from m in blockedMembers select m.Id).CollectionEqual(_candidateBlockListsQuery.GetPermanentlyBlockedCandidateIds(employer)));

            // GetEntryCounts

            var counts = _candidateBlockListsQuery.GetBlockedCounts(employer);
            if (counts.ContainsKey(blockList.Id))
                Assert.AreEqual(blockedMembers.Count, counts[blockList.Id]);
            else
                Assert.AreEqual(blockedMembers.Count, 0);
        }
Exemple #2
0
 private void CreateCandidates(int count, IEmployer employer, CandidateBlockList blockList)
 {
     for (var index = 0; index < count; ++index)
     {
         var member = CreateMember(index);
         _candidateListsCommand.AddCandidateToBlockList(employer, blockList, member.Id);
     }
 }
Exemple #3
0
        private CandidateBlockList CreateSpecialCandidateBlockList(Guid employerId, BlockListType blockListType)
        {
            var blockList = new CandidateBlockList {
                RecruiterId = employerId, BlockListType = blockListType
            };

            _contenderListsCommand.CreateList(blockList);
            return(blockList);
        }
        private static void AssertModel(CandidateBlockList blockList, IDictionary <Guid, int> expectedCounts, BlockListModel model)
        {
            Assert.AreEqual(blockList.BlockListType.ToString(), model.Type);

            int expectedCount;

            expectedCounts.TryGetValue(model.Id, out expectedCount);
            Assert.AreEqual(expectedCount, model.Count);
        }
Exemple #5
0
        int ICandidateListsCommand.AddCandidateToBlockList(IEmployer employer, CandidateBlockList blockList, Guid candidateId)
        {
            if (!CanModifyCandidates(employer, blockList))
            {
                throw new CandidateBlockListsPermissionsException(employer, blockList.Id);
            }

            AddCandidatesToBlockList(employer.Id, blockList, new[] { candidateId });
            return(_contenderListsQuery.GetListedCount(blockList.Id, null));
        }
Exemple #6
0
        int ICandidateListsCommand.RemoveCandidatesFromBlockList(IEmployer employer, CandidateBlockList blockList, IEnumerable <Guid> candidateIds)
        {
            if (!CanModifyCandidates(employer, blockList))
            {
                throw new CandidateBlockListsPermissionsException(employer, blockList.Id);
            }

            RemoveCandidatesFromList(blockList.Id, candidateIds);
            return(_contenderListsQuery.GetListedCount(blockList.Id, null));
        }
Exemple #7
0
        private void AddCandidatesToBlockList(Guid employerId, CandidateBlockList blockList, IEnumerable <Guid> candidateIds)
        {
            AddCandidatesToList(blockList.Id, candidateIds);

            // Remove from incompatible lists.

            if (blockList.BlockListType == BlockListType.Permanent)
            {
                RemoveCandidatesFromList(employerId, PermanentBlockListIncompatibleTypes, candidateIds);
            }
        }
Exemple #8
0
        private static bool CanModifyCandidates(IEmployer employer, CandidateBlockList blockList)
        {
            if (!CanAccessBlockList(employer, blockList, false))
            {
                return(false);
            }

            // Must own the blockList.

            return(blockList.RecruiterId == employer.Id);
        }
Exemple #9
0
        public void ListsTestsInitialize()
        {
            Resolve <IDbConnectionFactory>().DeleteAllTestData();

            _temporaryBlockList = null;
            _permanentBlockList = null;
            _flagList           = null;
            _privateFolder      = null;
            _sharedFolder       = null;
            _shortlistFolder    = null;
            _mobileFolder       = null;
        }
Exemple #10
0
        public void TestGetPermanentBlockList()
        {
            var employer  = CreateEmployer(1);
            var blockList = new CandidateBlockList {
                RecruiterId = employer.Id, BlockListType = BlockListType.Permanent
            };

            var flaggedBlockList = _candidateBlockListsQuery.GetPermanentBlockList(employer);

            AssertBlockList(employer, blockList, flaggedBlockList);
            AssertBlockList(employer, blockList, _candidateBlockListsQuery.GetBlockList(employer, flaggedBlockList.Id));
            AssertBlockLists(employer, _candidateBlockListsQuery.GetBlockLists(employer));
        }
Exemple #11
0
        public void TestGetTemporaryBlockList()
        {
            var employer  = CreateEmployer(1);
            var blockList = new CandidateBlockList {
                RecruiterId = employer.Id, BlockListType = BlockListType.Temporary
            };

            var shortlistBlockList = _candidateBlockListsQuery.GetTemporaryBlockList(employer);

            AssertBlockList(employer, blockList, shortlistBlockList);
            AssertBlockList(employer, blockList, _candidateBlockListsQuery.GetBlockList(employer, shortlistBlockList.Id));
            AssertBlockLists(employer, _candidateBlockListsQuery.GetBlockLists(employer));
        }
        protected static void AssertBlockList(IEmployer employer, CandidateBlockList expectedBlockList, CandidateBlockList blockList)
        {
            Assert.AreNotEqual(Guid.Empty, blockList.Id);
            Assert.AreNotEqual(DateTime.MinValue, blockList.CreatedTime);

            if (!((expectedBlockList.BlockListType == BlockListType.Permanent || expectedBlockList.BlockListType == BlockListType.Temporary) && expectedBlockList.Id == Guid.Empty))
                Assert.AreEqual(expectedBlockList.Id, blockList.Id);
            Assert.AreEqual(expectedBlockList.Name, blockList.Name);
            Assert.AreEqual(expectedBlockList.BlockListType, blockList.BlockListType);
            Assert.IsNull(blockList.Name);
            Assert.AreEqual(employer.Id, blockList.RecruiterId);
            Assert.AreEqual(expectedBlockList.RecruiterId, blockList.RecruiterId);
        }
Exemple #13
0
        private IList <Member> CreateCandidates(int count, IEmployer employer, CandidateBlockList blockList)
        {
            var members = new List <Member>();

            for (var index = 0; index < count; ++index)
            {
                var member = CreateMember(index);
                _candidateListsCommand.AddCandidateToBlockList(employer, blockList, member.Id);
                _memberSearchService.UpdateMember(member.Id);
                members.Add(member);
            }

            return(members);
        }
        protected static void AssertBlockLists(IEmployer employer, IList<CandidateBlockList> blockLists)
        {
            // Should always have a flagged and shortlist blockList.

            Assert.AreEqual(2, blockLists.Count);

            // Look for the temporary blockList.

            var flaggedBlockList = new CandidateBlockList { RecruiterId = employer.Id, BlockListType = BlockListType.Temporary };
            AssertBlockList(employer, flaggedBlockList, (from f in blockLists where f.BlockListType == BlockListType.Temporary select f).Single());

            // Look for the shortlist blockList.

            var shortlistBlockList = new CandidateBlockList { RecruiterId = employer.Id, BlockListType = BlockListType.Permanent };
            AssertBlockList(employer, shortlistBlockList, (from f in blockLists where f.BlockListType == BlockListType.Permanent select f).Single());
        }
Exemple #15
0
        private static bool CanAccessBlockList(IHasId <Guid> employer, CandidateBlockList blockList)
        {
            if (employer == null)
            {
                return(false);
            }
            if (blockList == null)
            {
                return(false);
            }
            if (blockList.IsDeleted)
            {
                return(false);
            }

            // Only the owner can edit or delete it.

            return(blockList.RecruiterId == employer.Id);
        }
Exemple #16
0
        private void CreateLists(IEmployer employer)
        {
            _temporaryBlockList = _candidateBlockListsQuery.GetTemporaryBlockList(employer);
            _permanentBlockList = _candidateBlockListsQuery.GetPermanentBlockList(employer);
            _flagList           = _candidateFlagListsQuery.GetFlagList(employer);

            _privateFolder = new CandidateFolder {
                Name = "PrivateFolder"
            };
            _candidateFoldersCommand.CreatePrivateFolder(employer, _privateFolder);

            _sharedFolder = new CandidateFolder {
                Name = "SharedFolder"
            };
            _candidateFoldersCommand.CreateSharedFolder(employer, _sharedFolder);

            _shortlistFolder = _candidateFoldersQuery.GetShortlistFolder(employer);
            _mobileFolder    = _candidateFoldersQuery.GetMobileFolder(employer);
        }
Exemple #17
0
        public void TestGetTemporaryPermanentBlockLists()
        {
            var employer   = CreateEmployer(1);
            var blockList1 = new CandidateBlockList {
                RecruiterId = employer.Id, BlockListType = BlockListType.Permanent
            };
            var blockList2 = new CandidateBlockList {
                RecruiterId = employer.Id, BlockListType = BlockListType.Temporary
            };

            var flaggedBlockList = _candidateBlockListsQuery.GetPermanentBlockList(employer);

            AssertBlockList(employer, blockList1, flaggedBlockList);
            AssertBlockList(employer, blockList1, _candidateBlockListsQuery.GetBlockList(employer, flaggedBlockList.Id));

            var shortlistBlockList = _candidateBlockListsQuery.GetTemporaryBlockList(employer);

            AssertBlockList(employer, blockList2, shortlistBlockList);
            AssertBlockList(employer, blockList2, _candidateBlockListsQuery.GetBlockList(employer, shortlistBlockList.Id));

            AssertBlockLists(employer, _candidateBlockListsQuery.GetBlockLists(employer));
        }
        private static void AssertModels(Guid employerId, IDictionary <Guid, int> expectedCounts, JsonBlockListsModel model)
        {
            // Shortlist and flagged are always returned.

            AssertJsonSuccess(model);
            Assert.AreEqual(2, model.BlockLists.Count);

            // Temporary blockList should be first.

            var temporaryBlockList = new CandidateBlockList {
                RecruiterId = employerId, BlockListType = BlockListType.Temporary
            };

            AssertModel(temporaryBlockList, expectedCounts, model.BlockLists[0]);

            // Permanent blockList should be next.

            var permanentBlockList = new CandidateBlockList {
                RecruiterId = employerId, BlockListType = BlockListType.Permanent
            };

            AssertModel(permanentBlockList, expectedCounts, model.BlockLists[1]);
        }
Exemple #19
0
 protected static void AssertBlockList(IEmployer employer, string name, CandidateBlockList blockList)
 {
     Assert.AreEqual(name, blockList.Name);
     Assert.AreEqual(false, blockList.IsDeleted);
     Assert.AreEqual(employer.Id, blockList.RecruiterId);
 }
Exemple #20
0
 public static string GetNameDisplayText(this CandidateBlockList blockList)
 {
     return(blockList.BlockListType.GetNameDisplayText());
 }
Exemple #21
0
        int ICandidateListsCommand.RemoveAllCandidatesFromBlockList(IEmployer employer, CandidateBlockList blockList)
        {
            if (!CanModifyCandidates(employer, blockList))
            {
                throw new CandidateBlockListsPermissionsException(employer, blockList.Id);
            }

            RemoveAllCandidatesFromList(blockList.Id);
            return(0);
        }
 protected static void AssertBlockList(IEmployer employer, CandidateBlockList expectedBlockList, IList<CandidateBlockList> blockLists)
 {
     Assert.AreEqual(1, blockLists.Count);
     AssertBlockList(employer, expectedBlockList, blockLists[0]);
 }