Пример #1
0
        //TEST:  SQLSECURITYMANAGER_REGISTERUSER_FAILURETEST
        //Test the functionality of the SqlSecurityManager RegisterUser method when using unintended test data.
        //Previous method created this User, therefore the UserName should be reserved, and this method will not be able to use it
        public void SqlSecurityManager_RegisterUser_FAILURETest()
        {
            SqlSecurityManager manager = new SqlSecurityManager();

            //ARRANGE
            //Create a test user with test parameters
            Store.Data.User newUser = new User();
            newUser.UserName        = "******";
            newUser.Password        = "******";
            newUser.ConfirmPassword = "******";
            newUser.EmailAddress    = "*****@*****.**";
            //ACT
            int result = manager.RegisterUser(newUser);

            //ASSERT
            Assert.IsNotNull(result);
            Assert.AreEqual(result, -1);
        }
Пример #2
0
        public ViewResult Register(Store.Data.User U)
        {
            if (ModelState.IsValid)
            {
                int result = manager.RegisterUser(U);

                if (result == 1)
                {
                    ModelState.Clear();
                    U = null;
                    ViewBag.Message = "User Successfully Registered";
                }
                else
                {
                    ModelState.AddModelError("UserName", "This Username already exists");
                }
            }
            return(View(U));
        }