public async Task WhenMessageIsTemplatedThenSubjectIsFormatted()
        {
            var source = new Mock <IEmailSender>();

            SendEmailDto saveDto = null;

            source.Setup(c => c.SendAsync(It.IsAny <SendEmailDto>()))
            .Callback <SendEmailDto>((dto) => saveDto = dto)
            .Returns(Task.CompletedTask);

            var emailService = new EmailNotificationService(source.Object);
            var message      = new TemplatedTestEmailNotification(
                "*****@*****.**",
                "Softeq Unit Test",
                new TestEmailModel("google.com", "Softeq Unit Test"));

            await emailService.SendAsync(message);

            var expectedSubject = string.Format(message.Subject, message.TemplateModel.Name);

            source.Verify(sender => sender.SendAsync(It.IsAny <SendEmailDto>()), Times.Once);
            Assert.NotNull(saveDto);
            Assert.Equal(message.Text, saveDto.Text);
            Assert.Equal(message.Recipients, saveDto.Recipients);
            Assert.Equal(expectedSubject, saveDto.Subject);
        }
        public async Task WhenMessageIsMissingArgumentNullExceptionIsThrown()
        {
            var source = new Mock <IEmailSender>();

            var emailService = new EmailNotificationService(source.Object);
            await Assert.ThrowsAsync <ArgumentNullException>(() => emailService.SendAsync(null));
        }
 public async Task SendForgotPasswordEmailSuccessfully()
 {
     IEmailSender sender       = new SendGridEmailSender(_fixture.Configuration);
     var          emailService = new EmailNotificationService(sender);
     await emailService.SendAsync(new TestEmailNotification(
                                      "*****@*****.**",
                                      "Softeq Unit Test",
                                      new TestEmailModel("google.com", "Softeq Unit Test")));
 }