Exemplo n.º 1
0
        public void GET_Register_Anonymous()
        {
            //Arrange
            var request = new Mock <HttpRequestBase>();

            request.SetupGet(x => x.IsAuthenticated).Returns(false);

            var context = new Mock <HttpContextBase>();

            context.SetupGet(x => x.Request).Returns(request.Object);

            var routeData = new RouteData();

            routeData.Values.Add("culture", "en");
            routeData.Values.Add("controller", "UserAccount");
            routeData.Values.Add("action", "Register");

            _controller.ControllerContext = new ControllerContext(context.Object, routeData, _controller);

            //Act
            var result = (ViewResult)_controller.Register();

            //Assert
            Assert.That(result.ViewName, Is.Empty);
        }
        public void RegisterTest()
        {
            UserAccountController userController = CreateFakeUserAccountController();

            //Register user correctly
            var response = userController.Register(new RegisterUserModel(
                                                       "reg-user-name", "reg-user-email", "reg-user-password"
                                                       ));

            Assert.IsType <OkResult>(response);

            User registeredUser = _usersService.GetByEmail("reg-user-email");

            Assert.Equal("reg-user-name", registeredUser.Name);
            Assert.Equal("reg-user-email", registeredUser.Email);
            Assert.True(PasswordVerifier.VerifyPasswordHash("reg-user-password", registeredUser.PasswordHash, registeredUser.PasswordSalt));
        }