public bool RequestEmailReminder(ForgottenEmailViewModel forgottenEmailViewModel) { try { _candidateService.RequestEmailReminder(forgottenEmailViewModel.PhoneNumber); return(true); } catch (CustomException e) { switch (e.Code) { case Domain.Entities.ErrorCodes.EntityStateError: case Application.Interfaces.Candidates.ErrorCodes.CandidateNotFoundError: _logger.Info(e.Message, e); break; default: _logger.Error(e.Message, e); break; } return(false); } catch (Exception e) { _logger.Error("Send email reminder failed for " + forgottenEmailViewModel.PhoneNumber, e); return(false); } }
public void NotSent_NotVerified() { const string phoneNumber = "0123456789"; var viewModel = new ForgottenEmailViewModel { PhoneNumber = phoneNumber }; var candidateService = new Mock <ICandidateService>(); candidateService.Setup(cs => cs.RequestEmailReminder(phoneNumber)).Throws(new CustomException(Domain.Entities.ErrorCodes.EntityStateError)); var provider = new CandidateServiceProviderBuilder().With(candidateService).Build(); var sent = provider.RequestEmailReminder(viewModel); sent.Should().BeFalse(); }
public void Sent() { const string phoneNumber = "0123456789"; var viewModel = new ForgottenEmailViewModel { PhoneNumber = phoneNumber }; var candidateService = new Mock <ICandidateService>(); candidateService.Setup(cs => cs.RequestEmailReminder(phoneNumber)); var provider = new CandidateServiceProviderBuilder().Build(); var sent = provider.RequestEmailReminder(viewModel); sent.Should().BeTrue(); }