コード例 #1
0
        public void Email_confirmation_can_be_resent()
        {
            // Arrange
            var user = new User()
            {
                Id             = "userId",
                Email          = "*****@*****.**",
                EmailConfirmed = false,
                PasswordHash   = "password",
                Username       = "******"
            };

            var userManager = new UserManagerMock();

            userManager.SetupExistingUser(user);

            var tokenService = new TokenServiceMock();

            tokenService.SetupTokenBuild(u => u.Id + "_token");

            var logger = new ConsoleLoggerMock <AccountService>();

            var confirmationSender = new EmailConfirmationSenderMock();

            var emailConfirmationService = new EmailConfirmationServiceMock();

            emailConfirmationService.SetupConfirmEmailFor(user, "userId_token");

            var service = new AccountService(
                userManager.Object, emailConfirmationService.Object, confirmationSender.Object, tokenService.Object, logger.Object);

            // Act
            OperationResult result = service.ResendConfirmationEmail("*****@*****.**", "password").Result;

            // Assert
            Assert.True(result.IsValid);
            confirmationSender.VerifyEmailSent("username", "*****@*****.**");
        }
コード例 #2
0
        public void Users_email_can_be_changed()
        {
            // Arrange
            var user = new User()
            {
                Id             = "userId",
                Email          = "*****@*****.**",
                EmailConfirmed = true,
                PasswordHash   = "password",
                Username       = "******"
            };

            var userManager = new UserManagerMock();

            userManager.SetupExistingUser(user);

            var tokenService = new TokenServiceMock();

            tokenService.SetupTokenBuild(u => u.Id + "_token");

            var logger = new ConsoleLoggerMock <AccountService>();

            var confirmationSender = new EmailConfirmationSenderMock();

            var emailConfirmationService = new EmailConfirmationServiceMock();

            emailConfirmationService.SetupConfirmEmailFor(user, "userId_token");

            var service = new AccountService(
                userManager.Object, emailConfirmationService.Object, confirmationSender.Object, tokenService.Object, logger.Object);

            // Act
            OperationResult result = service.ChangeEmail("userId", "*****@*****.**", "password").Result;

            // Assert
            Assert.True(result.IsValid);
            Assert.AreEqual("*****@*****.**", user.Email);
        }
コード例 #3
0
        public void After_confirm_email_call_users_email_is_confirmed()
        {
            // Arrange
            var user = new User()
            {
                Id             = "userId",
                Email          = "*****@*****.**",
                EmailConfirmed = false
            };

            var userManager = new UserManagerMock();

            userManager.SetupExistingUser(user);

            var tokenService = new TokenServiceMock();

            tokenService.SetupTokenBuild(u => u.Id + "_token");

            var logger = new ConsoleLoggerMock <AccountService>();

            var confirmationSender = new EmailConfirmationSenderMock();

            var emailConfirmationService = new EmailConfirmationServiceMock();

            emailConfirmationService.SetupConfirmEmailFor(user, "userId_token");


            var service = new AccountService(
                userManager.Object, emailConfirmationService.Object, confirmationSender.Object, tokenService.Object, logger.Object);

            // Act
            OperationResult result = service.ConfirmEmail("userId", "userId_token").Result;

            // Assert
            Assert.True(result.IsValid);
            Assert.True(user.EmailConfirmed);
        }