private bool ValidateTokens(Dictionary <string, string> tokens, ProviderAlertSummary alertSummary) { return(tokens["total_count_text"] == alertSummary.TotalCount.ToString() && tokens["link_to_mange_apprenticeships"].StartsWith(alertSummary.ProviderId.ToString()) && alertSummary.ChangesForReview == 0 ? string.IsNullOrWhiteSpace(tokens["changes_for_review"]) : tokens["changes_for_review"].StartsWith("* " + alertSummary.ChangesForReview) && alertSummary.DataMismatchCount == 0 ? string.IsNullOrWhiteSpace(tokens["mismatch_changes"]) : tokens["mismatch_changes"].StartsWith("* " + alertSummary.DataMismatchCount)); }
public WhenSendingProviderAlertSummaryEmailsFixture() { var fixture = new Fixture(); JobId = fixture.Create <string>(); FirstAlertSummary = fixture.Create <ProviderAlertSummary>(); SecondAlertSummary = fixture.Create <ProviderAlertSummary>(); AlertSummaryNoApprenticeChanges = fixture.Build <ProviderAlertSummary>().With(x => x.ChangesForReview, 0).Create(); AlertSummaryNoDataLocks = fixture.Build <ProviderAlertSummary>().With(x => x.DataMismatchCount, 0).Create(); ApprenticeshipRepository = new Mock <IApprenticeshipRepository>(); ApprenticeshipRepository.Setup(x => x.GetProviderApprenticeshipAlertSummary()) .ReturnsAsync(new List <ProviderAlertSummary>()); PasAccountApiClient = new Mock <IPasAccountApiClient>(); Sut = new ProviderAlertSummaryEmailService(ApprenticeshipRepository.Object, PasAccountApiClient.Object, Mock.Of <ILog>()); }
internal void VerifySendEmailToAllProviderRecipientsIsCalledNTimeWithSummaryAlert(ProviderAlertSummary alertSummary, int n) { PasAccountApiClient.Verify(x => x.SendEmailToAllProviderRecipients(alertSummary.ProviderId, It.Is <ProviderEmailRequest>(p => p.TemplateId == "ProviderAlertSummaryNotification2" && ValidateTokens(p.Tokens, alertSummary))), Times.Exactly(n)); }
internal void VerifySendEmailToAllProviderRecipientsIsCalledOnceWithSummaryAlert(ProviderAlertSummary alertSummary) { VerifySendEmailToAllProviderRecipientsIsCalledNTimeWithSummaryAlert(alertSummary, 1); }