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); }
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); } }
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); }
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)); }
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)); }
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); } }
private static bool CanModifyCandidates(IEmployer employer, CandidateBlockList blockList) { if (!CanAccessBlockList(employer, blockList, false)) { return(false); } // Must own the blockList. return(blockList.RecruiterId == employer.Id); }
public void ListsTestsInitialize() { Resolve <IDbConnectionFactory>().DeleteAllTestData(); _temporaryBlockList = null; _permanentBlockList = null; _flagList = null; _privateFolder = null; _sharedFolder = null; _shortlistFolder = null; _mobileFolder = null; }
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)); }
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); }
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()); }
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); }
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); }
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]); }
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); }
public static string GetNameDisplayText(this CandidateBlockList blockList) { return(blockList.BlockListType.GetNameDisplayText()); }
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]); }