public ReminderEmailerTests() { _options = Options.Create(new EmailSettings { FeedbackSiteBaseUrl = "https://test-site.com/", BatchSize = 10 }); var emailDetails = new List <EmployerSurveyInvite> { new EmployerSurveyInvite { UserRef = new Guid("7f11a6b0-a25b-45a5-bdfc-4424dfba85e8"), EmailAddress = "*****@*****.**" } }; _mockStore.Setup(x => x.GetEmployerInvitesToBeSentReminder(It.IsAny <int>())).ReturnsAsync(emailDetails); _emailer = new EmployerSurveyReminderEmailer(_mockStore.Object, _mockEmailService.Object, _options, _mockLogger.Object); }
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 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 SurveyReminderEmailer(EmployerSurveyReminderEmailer reminderEmailer) { _reminderEmailer = reminderEmailer; }