예제 #1
0
        public void Create_User_Success()
        {
            ClearUsers();
            User testUser = new User
            {
                Id   = 1,
                Name = "Marko"
            };

            UserDB.AddNewUser(testUser);
            Assert.AreEqual(1, UserDB.listOfUsers.Count);
        }
예제 #2
0
 public bool Register(string user, string password)
 {
     if (user == string.Empty || password == string.Empty)
     {
         return(false);
     }
     if (!userDB.UserExist(user))
     {
         return(userDB.AddNewUser(user, password));
     }
     throw new CustomException("User has already registered!!");
 }
예제 #3
0
        public void Search_User_By_Name_Fail()
        {
            ClearUsers();
            User testUser = new User
            {
                Id   = 1,
                Name = "Marko"
            };

            UserDB.AddNewUser(testUser);

            Assert.AreEqual(null, UserDB.GetUserByName("Sinisa"));
        }
예제 #4
0
        public void Search_User_By_Name_Success()
        {
            ClearUsers();
            User testUser = new User
            {
                Id   = 1,
                Name = "Marko"
            };

            UserDB.AddNewUser(testUser);

            Assert.AreEqual(testUser, UserDB.GetUserByName("Marko"));
        }
예제 #5
0
        public void Get_All_Users_Success()
        {
            ClearUsers();
            User testUser = new User
            {
                Id   = 1,
                Name = "Marko"
            };

            UserDB.AddNewUser(testUser);

            Assert.AreEqual(1, UserDB.GetAllUsers().Count);
        }
예제 #6
0
        public void Delete_User_Fail()
        {
            ClearUsers();
            User testUser = new User
            {
                Id   = 1,
                Name = "Marko"
            };

            UserDB.AddNewUser(testUser);
            UserDB.DeleteUser(2);

            Assert.AreEqual(1, UserDB.listOfUsers.Count);
        }
        public ActionResult RegistrationForm(string userName, string pass, string email)
        {
            UserModel newUser = new UserModel(userName, pass, email);
            bool      isAdded = user.AddNewUser(newUser);

            if (isAdded == true)
            {
                int id = user.getUserId(userName, pass);
                game.CreateRankingForUser(id);
                return(RedirectToAction("LogIn"));
            }
            else
            {
                Session["error"] = "Vartotojas tokiu vardu jau yra";
                return(RedirectToAction("Register"));
            }
        }
예제 #8
0
        public void Create_User_Fail()
        {
            ClearUsers();
            User testUser1 = new User
            {
                Id   = 1,
                Name = "Marko"
            };
            User testUser2 = new User
            {
                Id   = 1,
                Name = "Sinisa"
            };

            UserDB.AddNewUser(testUser1);
            UserDB.AddNewUser(testUser2);
            Assert.AreEqual(1, UserDB.listOfUsers.Count);
        }
예제 #9
0
        public void Modify_User_Fail()
        {
            ClearUsers();
            User testUser = new User
            {
                Id   = 1,
                Name = "Marko"
            };

            UserDB.AddNewUser(testUser);

            User testUser1 = new User
            {
                Id   = 1,
                Name = "Sinisa"
            };

            UserDB.ModifyUser(testUser1);

            Assert.AreEqual(null, UserDB.GetUserByName("Marko"));
        }