Exemplo n.º 1
0
        public void WillUpdatePasswordIfNewPwsMatch()
        {
            //setup
            MockUserRepository mock       = new MockUserRepository();
            UserController     controller = new UserController(mock);
            //login a temp user to check with
            UserLogin temp2 = new UserLogin()
            {
                un = "*****@*****.**", pword = "password"
            };
            User user = new User();

            // execute Login
            controller.Index(user, temp2);

            //handle updating password
            UserProfile temp = new UserProfile()
            {
                currentPW = "password", newPW = "password2", newPW2 = "password2"
            };

            controller.UserProfile(user, temp);
            user = mock.Users.Where(x => x.Name == user.Name).First();
            Assert.AreEqual("password2", user.Password);
        }
Exemplo n.º 2
0
        public void WillNotUpdatePasswordIfCurrentPwDoesntMatch()
        {
            //setup
            MockUserRepository mock       = new MockUserRepository();
            UserController     controller = new UserController(mock);
            //login a temp user to check with
            UserLogin temp2 = new UserLogin()
            {
                un = "*****@*****.**", pword = "password"
            };
            User user = new User();

            // execute Login
            controller.Index(user, temp2);

            //handle updating password
            UserProfile temp = new UserProfile()
            {
                currentPW = "random", newPW = "password", newPW2 = "password"
            };

            controller.UserProfile(user, temp);

            Assert.AreEqual("password", user.Password);
        }
Exemplo n.º 3
0
        public void WillNotCreateUserWithoutEmail()
        {
            //setup
            MockUserRepository mock       = new MockUserRepository();
            UserController     controller = new UserController(mock);
            UserLogin          temp       = new UserLogin()
            {
                un = "IWantToSignUp", pword = "password", pword2 = "password"
            };
            User user = new User();

            // execute createuser
            controller.Createuser(user, temp);

            // Assert user not created
            // if null user wasn't created
            Assert.IsNull(user.Name);
            Assert.IsNull(user.Password);
        }
Exemplo n.º 4
0
        public void WillNotLoginUserWithoutEmail()
        {
            //setup
            MockUserRepository mock       = new MockUserRepository();
            UserController     controller = new UserController(mock);
            UserLogin          temp       = new UserLogin()
            {
                un = "letmelogin", pword = "password"
            };
            User user = new User();

            //execute login
            controller.Index(user, temp);

            //assert not logged in
            //if null user was not logged in
            Assert.IsNull(user.Name);
            Assert.IsNull(user.Password);
        }
Exemplo n.º 5
0
        public void WillNotLoginWithWrongPassword()
        {
            // setup
            MockUserRepository mock       = new MockUserRepository();
            UserController     controller = new UserController(mock);
            UserLogin          temp       = new UserLogin()
            {
                un = "*****@*****.**", pword = "wrongPassword"
            };
            User user = new User();

            // execute Login
            controller.Index(user, temp);

            // assert not logged in
            // if null user was not logged in
            Assert.IsNull(user.Name);
            Assert.IsNull(user.Password);
        }
Exemplo n.º 6
0
        public void CanLogin()
        {
            // setup
            MockUserRepository mock       = new MockUserRepository();
            UserController     controller = new UserController(mock);
            UserLogin          temp       = new UserLogin()
            {
                un = "*****@*****.**", pword = "password"
            };
            User user = new User();

            // execute Login
            controller.Index(user, temp);

            // assert user is logged in
            //checks to see if user object got right data assigned to its attributes
            Assert.AreEqual(user.Name, "*****@*****.**");
            Assert.AreEqual(user.Password, "password");
            Assert.AreEqual(user.UserID, 0);
        }
Exemplo n.º 7
0
        public void CanCreateUser()
        {
            // setup
            MockUserRepository mock       = new MockUserRepository();
            UserController     controller = new UserController(mock);
            User user = new User();
            //controller.Session["User"] = user;
            UserLogin temp = new UserLogin()
            {
                un = "*****@*****.**", pword = "password", pword2 = "password"
            };

            // excute Createuser
            controller.Createuser(user, temp);

            // assert user object holds new login and user is added to database
            // if equal user is signed in
            Assert.AreEqual(user.Name, "*****@*****.**");
            //if not null new user was added to database
            user = mock.Users.Where(x => x.Name == "*****@*****.**").FirstOrDefault();
            Assert.IsNotNull(user);
        }
Exemplo n.º 8
0
        public void WillNotCreateUserWithSameName()
        {
            // setup
            MockUserRepository mock       = new MockUserRepository();
            UserController     controller = new UserController(mock);
            UserLogin          temp       = new UserLogin()
            {
                un = "*****@*****.**", pword = "password", pword2 = "password"
            };
            User user = new User();

            // execute createuser
            controller.Createuser(user, temp);

            // Assert user not created
            // if null user is not created
            Assert.IsNull(user.Name);
            Assert.IsNull(user.Password);
            //if one user wasn't added to database
            int s = mock.Users.Select(x => x).Where(x => x.Name == temp.un).Count();

            Assert.AreEqual(s, 1);
        }
Exemplo n.º 9
0
        public void CanLogOut()
        {
            MockUserRepository mock       = new MockUserRepository();
            UserController     controller = new UserController(mock);
            UserLogin          temp       = new UserLogin()
            {
                un = "*****@*****.**", pword = "password"
            };
            User user = new User();

            // execute Login
            controller.Index(user, temp);

            // execute Logout
            controller.LogOut(user);

            // assert user is logged out
            // if null user was logged out
            Assert.IsNull(user.UserID);
            Assert.IsNull(user.Name);
            Assert.IsNull(user.Password);
            Assert.IsNull(user.Pantrys);
        }