コード例 #1
0
        public void resetpassword_post_should_have_resetpasswordsent_view_and_should_send_resetpassword_email()
        {
            // Arrange
            _applicationSettings.UseWindowsAuthentication = false;
            Core.Configuration.SiteSettings siteSettings = _settingsService.GetSiteSettings();

            string email = "*****@*****.**";

            _userService.AddUser(email, "test", "test", false, true);
            _userService.Users.First(x => x.Email == email).IsActivated = true;

            ResetPasswordEmailStub resetEmail     = new ResetPasswordEmailStub(_applicationSettings, _settingsRepository, _emailClientMock);
            UserController         userController = new UserController(_applicationSettings, _userService, _userContext, _settingsService, null, resetEmail);

            userController.SetFakeControllerContext();

            // Act
            ActionResult result = userController.ResetPassword(email);

            // Assert
            ViewResult viewResult = result.AssertResultIs <ViewResult>();

            Assert.That(viewResult.ViewName, Is.EqualTo("ResetPasswordSent"));
            Assert.That(resetEmail.IsSent, Is.True);
            Assert.That(resetEmail.Model.ExistingEmail, Is.EqualTo(email));
            Assert.That(resetEmail.Model.PasswordResetKey, Is.EqualTo(UserServiceMock.RESETKEY));
        }
コード例 #2
0
        public void resendconfirmation_post_with_invalid_email_should_show_signup_view()
        {
            // Arrange
            _applicationSettings.UseWindowsAuthentication = false;
            Core.Configuration.SiteSettings siteSettings = _settingsService.GetSiteSettings();

            ResetPasswordEmailStub resetEmail     = new ResetPasswordEmailStub(_applicationSettings, _settingsRepository, _emailClientMock);
            UserController         userController = new UserController(_applicationSettings, _userService, _userContext, _settingsService, null, resetEmail);

            userController.SetFakeControllerContext();

            // Act
            ActionResult result = userController.ResendConfirmation("doesnt exist");

            // Assert
            ViewResult viewResult = result.AssertResultIs <ViewResult>();

            Assert.That(viewResult.ViewName, Is.EqualTo("Signup"));
        }
コード例 #3
0
        public void resetpassword_post_should_not_send_email_with_invalid_modelstate()
        {
            // Arrange
            _applicationSettings.UseWindowsAuthentication = false;
            Core.Configuration.SiteSettings siteSettings = _settingsService.GetSiteSettings();

            ResetPasswordEmailStub resetEmail     = new ResetPasswordEmailStub(_applicationSettings, _settingsRepository, _emailClientMock);
            UserController         userController = new UserController(_applicationSettings, _userService, _userContext, _settingsService, null, resetEmail);

            userController.SetFakeControllerContext();

            // Act
            ActionResult result = userController.ResetPassword("fake email");

            // Assert
            ViewResult viewResult = result.AssertResultIs <ViewResult>();

            viewResult.AssertViewRendered();
            Assert.That(userController.ModelState.Count, Is.EqualTo(1));
            Assert.That(resetEmail.IsSent, Is.EqualTo(false));
        }
コード例 #4
0
        public void ResetPassword_POST_Should_Not_Send_Email_With_Invalid_ModelState()
        {
            // Arrange
            _applicationSettings.UseWindowsAuthentication = false;
            SiteSettings siteSettings = _settingsService.GetSiteSettings();

            ResetPasswordEmailStub resetEmail = new ResetPasswordEmailStub(_applicationSettings, _repository, _emailClientMock);
            UserController userController = new UserController(_applicationSettings, _userService, _userContext, _settingsService, null, resetEmail);
            userController.SetFakeControllerContext();

            // Act
            ActionResult result = userController.ResetPassword("fake email");

            // Assert
            ViewResult viewResult = result.AssertResultIs<ViewResult>();
            viewResult.AssertViewRendered();
            Assert.That(userController.ModelState.Count, Is.EqualTo(1));
            Assert.That(resetEmail.IsSent, Is.EqualTo(false));
        }
コード例 #5
0
        public void ResetPassword_POST_Should_Have_ResetPasswordSent_View_And_Should_Send_ResetPassword_Email()
        {
            // Arrange
            _applicationSettings.UseWindowsAuthentication = false;
            SiteSettings siteSettings = _settingsService.GetSiteSettings();

            string email = "*****@*****.**";
            _userService.AddUser(email, "test", "test", false, true);
            _userService.Users.First(x => x.Email == email).IsActivated = true;

            ResetPasswordEmailStub resetEmail = new ResetPasswordEmailStub(_applicationSettings, _repository, _emailClientMock);
            UserController userController = new UserController(_applicationSettings, _userService, _userContext, _settingsService, null, resetEmail);
            userController.SetFakeControllerContext();

            // Act
            ActionResult result = userController.ResetPassword(email);

            // Assert
            ViewResult viewResult = result.AssertResultIs<ViewResult>();
            Assert.That(viewResult.ViewName, Is.EqualTo("ResetPasswordSent"));
            Assert.That(resetEmail.IsSent, Is.True);
            Assert.That(resetEmail.Model.ExistingEmail, Is.EqualTo(email));
            Assert.That(resetEmail.Model.PasswordResetKey, Is.EqualTo(UserServiceMock.RESETKEY));
        }
コード例 #6
0
        public void ResendConfirmation_POST_With_Invalid_Email_Should_Show_Signup_View()
        {
            // Arrange
            _applicationSettings.UseWindowsAuthentication = false;
            SiteSettings siteSettings = _settingsService.GetSiteSettings();

            ResetPasswordEmailStub resetEmail = new ResetPasswordEmailStub(_applicationSettings, _repository, _emailClientMock);
            UserController userController = new UserController(_applicationSettings, _userService, _userContext, _settingsService, null, resetEmail);
            userController.SetFakeControllerContext();

            // Act
            ActionResult result = userController.ResendConfirmation("doesnt exist");

            // Assert
            ViewResult viewResult = result.AssertResultIs<ViewResult>();
            Assert.That(viewResult.ViewName, Is.EqualTo("Signup"));
        }