Exemplo n.º 1
0
        public void ShouldReplaceEmailVariables()
        {
            var email   = EmailFaker.GenerateEmail().Generate();
            var message = email.GetMessage(UserFaker.GenerateUser().Generate(), new AccountResult(_faker.Random.Guid().ToString(), _faker.Database.Random.AlphaNumeric(5), _faker.Internet.Url()), UserCommandFaker.GenerateRegisterNewUserCommand().Generate());

            message.Content.Should()
            .NotContain("{{picture}}").And
            .NotContain("{{name}}").And
            .NotContain("{{username}}").And
            .NotContain("{{code}}").And
            .NotContain("{{url}}").And
            .NotContain("{{provider}}").And
            .NotContain("{{phoneNumber}}").And
            .NotContain("{{email}}");
        }
        public async Task Should_Update_Email_When_Type_Found()
        {
            var emailCommand = EmailCommandFaker.GenerateSaveEmailCommand().Generate();

            _emailRepository.Setup(s => s.GetByType(It.IsAny <EmailType>())).ReturnsAsync(EmailFaker.GenerateEmail().Generate());
            _emailRepository.Setup(s => s.Update(It.IsAny <Email>()));
            _uow.Setup(s => s.Commit()).ReturnsAsync(true);

            var result = await _commandHandler.Handle(emailCommand, CancellationToken.None);

            _emailRepository.Verify(s => s.Update(It.IsAny <Email>()), Times.Once);

            result.Should().BeTrue();
        }
Exemplo n.º 3
0
        public async Task ShouldSendEmailAfterSuccessfullRegistration()
        {
            _emailRepository.Setup(s => s.GetByType(It.IsAny <EmailType>())).ReturnsAsync(EmailFaker.GenerateEmail());
            _userService.Setup(s => s.CreateUserWithPass(It.IsAny <User>(), It.IsAny <string>())).ReturnsAsync(new AccountResult(_faker.Random.Guid().ToString(), _faker.Random.String(), _faker.Internet.Url()));

            var command = UserCommandFaker.GenerateRegisterNewUserCommand().Generate();

            var result = await _commandHandler.Handle(command, _tokenSource.Token);

            result.Should().BeTrue();
            _emailService.Verify(e => e.SendEmailAsync(It.IsAny <EmailMessage>()), Times.Once);
        }
        public async Task Should_Send_Email_After_Successfull_Registration()
        {
            _emailRepository.Setup(s => s.GetByType(It.IsAny <EmailType>())).ReturnsAsync(EmailFaker.GenerateEmail());
            _userService.Setup(s => s.CreateUserWithPass(It.IsAny <RegisterNewUserCommand>(), It.IsAny <string>())).ReturnsAsync(new AccountResult(_faker.Random.Guid().ToString(), _faker.Random.String(), _faker.Internet.Url()));
            _userService.SetupSequence(s => s.FindByNameAsync(It.IsAny <string>())).ReturnsAsync((IDomainUser)null).ReturnsAsync(UserFaker.GenerateUser(confirmedEmail: false).Generate());

            var command = UserCommandFaker.GenerateRegisterNewUserCommand(shouldConfirmEmail: true).Generate();

            var result = await _commandHandler.Handle(command, _tokenSource.Token);

            result.Should().BeTrue();
            _userService.Verify(s => s.CreateUserWithPass(It.IsAny <RegisterNewUserCommand>(), It.IsAny <string>()), Times.Once);
            _emailService.Verify(e => e.SendEmailAsync(It.IsAny <EmailMessage>()), Times.Once);
        }