コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }