Esempio n. 1
0
        public async Task <IActionResult> SendActivationEmail(SendActivationEmailRequest request)
        {
            var response = await mediator.Send(request);

            Log.Information(
                $"User {request.Email} resent activation account email link to email address: {request.Email}");

            return(this.CreateResponse(response));
        }
        public void SetUp()
        {
            var sendActivationEmailResult = new SendActivationEmailResult
            {
                Email    = Test,
                Token    = Test,
                Username = Test
            };
            var emailTemplate = new EmailTemplate
            {
                TemplateName      = Test,
                Subject           = Test,
                Content           = Test,
                AllowedParameters = new[] { "{{username}}", "{{callbackUrl}}" }
            };

            request = new SendActivationEmailRequest
            {
                Email = Test
            };

            authService            = new Mock <IAuthService>();
            cryptoService          = new Mock <ICryptoService>();
            emailSender            = new Mock <IEmailSender>();
            emailTemplateGenerator = new Mock <IEmailTemplateGenerator>();
            configuration          = new Mock <IConfiguration>();

            authService.Setup(a => a.GenerateActivationEmailToken(It.IsNotNull <string>()))
            .ReturnsAsync(sendActivationEmailResult);
            cryptoService.Setup(c => c.Encrypt(It.IsAny <string>()))
            .Returns(Test);
            configuration.Setup(c => c.GetSection(It.IsAny <string>()))
            .Returns(new Mock <IConfigurationSection>().Object);
            emailTemplateGenerator.Setup(etg => etg.FindEmailTemplate(It.IsAny <string>()))
            .ReturnsAsync(emailTemplate);
            emailSender.Setup(es => es.Send(It.IsAny <EmailMessage>()))
            .ReturnsAsync(true);

            sendActivationEmailCommand = new SendActivationEmailCommand(authService.Object, cryptoService.Object,
                                                                        emailSender.Object, emailTemplateGenerator.Object, configuration.Object);
        }