public void MatchCandidates_WithMagicLinkToken_ReturnsMatchingCandidates(string token, IEnumerable <string> expectedFirstNames) { _mockService.Setup(mock => mock.CreateQuery("contact", _context)).Returns(MockCandidates()); _mockService.Setup(mock => mock.LoadProperty(It.IsAny <Entity>(), new Relationship("dfe_contact_dfe_candidatequalification_ContactId"), _context)); _mockService.Setup(mock => mock.LoadProperty(It.IsAny <Entity>(), new Relationship("dfe_contact_dfe_candidatepastteachingposition_ContactId"), _context)); _mockService.Setup(mock => mock.LoadProperty(It.IsAny <Entity>(), new Relationship("dfe_contact_dfe_servicesubscription_contact"), _context)); _mockService.Setup(mock => mock.LoadProperty(It.IsAny <Entity>(), new Relationship("msevtmgt_contact_msevtmgt_eventregistration_Contact"), _context)); var result = _crm.MatchCandidates(token); result.Select(c => c.FirstName).Should().BeEquivalentTo(expectedFirstNames); }
public CandidateMagicLinkExchangeResult Exchange(string token) { var matchingCandidates = _crm.MatchCandidates(token); // Return null if there are no matches and also in the very // unlikely case a token has been duplicated. if (matchingCandidates.Count() != 1) { return(new CandidateMagicLinkExchangeResult(null)); } var candidate = matchingCandidates.First(); var result = new CandidateMagicLinkExchangeResult(candidate); candidate.MagicLinkTokenStatusId = (int)Candidate.MagicLinkTokenStatus.Exchanged; return(result); }