public async Task ThirdRoundReminderEmailsSentCorrectly() { //Assign await _dbConnection.ExecuteAsync($@" UPDATE EmployerSurveyHistory SET SentDate = DATEADD(DAY,-15,SentDate) WHERE UniqueSurveyCode IN (SELECT UniqueSurveyCode FROM EmployerSurveyCodes WHERE FeedbackId IN (SELECT FeedbackId FROM EmployerFeedback WHERE UserRef in @userRefs))", new { userRefs = new[] { _user3Guid } }); _employerSurveyReminderEmailer = new EmployerSurveyReminderEmailer(_dbEmployerFeedbackRepository, _notificationsApiClientMock.Object, _options, _surveyLoggerMock.Object); //Act await _employerSurveyReminderEmailer.SendEmailsAsync(); //Assert _notificationsApiClientMock.Verify(x => x.SendEmail(It.IsAny <Email>()), Times.Exactly(0)); }
public async Task Run( [TimerTrigger("%ReminderEmailerSchedule%")] TimerInfo myTimer, ILogger log) { log.LogInformation("Starting employer reminder emailer."); try { await _reminderEmailer.SendEmailsAsync(); log.LogInformation("Finished emailing employers."); } catch (Exception ex) { log.LogError(ex, "Unable to email employers."); throw; } }
public async Task FirstRoundReminderEmailsSentCorrectly() { //Assign await _dbConnection.ExecuteAsync($@" UPDATE EmployerSurveyHistory SET SentDate = @newSentDate WHERE UniqueSurveyCode IN (SELECT UniqueSurveyCode FROM EmployerSurveyCodes WHERE FeedbackId IN (SELECT FeedbackId FROM EmployerFeedback WHERE UserRef in @userRefs))", new { newSentDate = DateTime.UtcNow.AddDays(-15), userRefs = new[] { _user1Guid, _user2Guid } }); _notificationsApiClientMock = new Mock <INotificationsApi>(); _employerSurveyReminderEmailer = new EmployerSurveyReminderEmailer(_dbEmployerFeedbackRepository, _notificationsApiClientMock.Object, _options, _surveyLoggerMock.Object); //Act await _employerSurveyReminderEmailer.SendEmailsAsync(); //Assert _notificationsApiClientMock.Verify(x => x.SendEmail(It.IsAny <Email>()), Times.Exactly(2)); }
public async Task EmailUsingReminderTemplate() { await _emailer.SendEmailsAsync(); _mockEmailService.Verify(x => x.SendEmail(It.Is <Email>(a => a.TemplateId == EmailTemplates.ReminderTemplateId))); }