Ejemplo n.º 1
0
        public NotificationEmailSenderTests()
        {
            A.CallTo(() => urlGenerator.UI())
            .Returns(uiUrl);

            sut = new NotificationEmailSender(Options.Create(texts), emailSender, urlGenerator, log);
        }
Ejemplo n.º 2
0
        private async Task SendEmailAsync(string template, string emailSubj, string emailBody, IUser user, TemplatesVars vars)
        {
            if (string.IsNullOrWhiteSpace(emailBody))
            {
                LogWarning($"No email subject configured for {template}");
                return;
            }

            if (string.IsNullOrWhiteSpace(emailSubj))
            {
                LogWarning($"No email body configured for {template}");
                return;
            }

            vars.URL = urlGenerator.UI();

            vars.User = user;

            emailSubj = Format(emailSubj, vars);
            emailBody = Format(emailBody, vars);

            try
            {
                await emailSender.SendAsync(user.Email, emailSubj, emailBody);
            }
            catch (Exception ex)
            {
                log.LogError(ex, w => w
                             .WriteProperty("action", "SendNotification")
                             .WriteProperty("status", "Failed"));

                throw;
            }
        }
Ejemplo n.º 3
0
        public NotificationEmailSenderTests()
        {
            A.CallTo(() => assigner.Email)
            .Returns("*****@*****.**");
            A.CallTo(() => assigner.Claims)
            .Returns(assignerClaims);

            A.CallTo(() => user.Email)
            .Returns("*****@*****.**");
            A.CallTo(() => user.Claims)
            .Returns(assigneeClaims);

            A.CallTo(() => urlGenerator.UI())
            .Returns(uiUrl);

            sut = new NotificationEmailSender(Options.Create(texts), emailSender, urlGenerator, log);
        }