public void TestLogin()
        {
            Chatroom chatroom = new Chatroom();
            User     user     = new User("user");

            chatroom.Register(user.Nickname);
            Boolean firstL = chatroom.Login("user");

            Assert.AreEqual(firstL, true);
            Boolean secondL = chatroom.Login("otheruser");

            Assert.AreEqual(secondL, false);
        }
示例#2
0
        public void Login_With_Non_Existing_User()
        {
            String   dummyPassword = "******";
            Chatroom chatroom      = new Chatroom();
            Random   rnd           = new Random();
            int      appendix      = rnd.Next(1000);

            Assert.IsNull((chatroom.Login("chendoy" + appendix, appendix, dummyPassword)));
            Assert.IsNull(chatroom.Login("Bruce_Wayne" + appendix, appendix, dummyPassword));
            Assert.IsNull(chatroom.Login("clark_kent" + appendix, appendix, dummyPassword));
            Assert.IsNull(chatroom.Login("peter_parker8" + appendix, appendix, dummyPassword));
            Assert.IsNull(chatroom.Login("tony_stark" + appendix, appendix, dummyPassword));
        }
        //tries to login with the nickname typed and show a messageBox if failes
        private void btn_login_Click(object sender, RoutedEventArgs e)
        {
            String nickname = _main.NicknameL;
            String group    = Int32.Parse(_main.GroupL).ToString();

            if (nickname == "" | group == "")
            {
                MessageBox.Show("Please enter a Nickname , a GroupID and Passward");
                return;
            }

            if (!myChatRoom.isLPasswordValid())
            {
                MessageBox.Show("Passward invalid");
                return;
            }

            Boolean login = myChatRoom.Login(nickname, group);

            if (!login)
            {
                MessageBox.Show("User doesn't exist");
            }
            else
            {
                _main.NicknameL = "";
                _main.GroupL    = "24";
                StartProgram();
            }
        }
示例#4
0
        //a function for login or logout. tries to log out and if it fails, askes for nickname for login
        //notifies if nickname is non-exist
        public void loginLogout()
        {
            Console.Clear();
            if (myChatRoom.Logout())
            {
                Console.WriteLine("Your user logout");
                Console.WriteLine("Press ENTER to go back to the menu");
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("Enter your nickname");
                String nickname = Console.ReadLine();
                while ((nickname != "") && (!myChatRoom.Login(nickname)))
                {
                    Console.WriteLine("User non-exist, try again or press ENTER and go back to the menu");
                    nickname = Console.ReadLine();
                }

                if (nickname != "")
                {
                    Console.WriteLine("Your user login");
                    Console.WriteLine("Press ENTER to go back to the menu");
                    Console.ReadLine();
                }
            }
        }
示例#5
0
        public void Logout_test()
        {
            String   dummyPassword = "******";
            Random   rnd           = new Random();
            int      appendix      = rnd.Next(9);
            Chatroom chatroom      = new Chatroom();

            chatroom.Register("chend" + appendix, appendix, dummyPassword);
            chatroom.Login("chend" + appendix, appendix, dummyPassword);
            chatroom.LogOut();
            Assert.IsNull(chatroom.GetLoggedInUser());
            chatroom.Login("chend" + appendix, appendix, dummyPassword);
            chatroom.LogOut();
            Assert.IsNull(chatroom.GetLoggedInUser());
            chatroom.Login("chend" + appendix, appendix, dummyPassword);
            Assert.IsNotNull(chatroom.GetLoggedInUser());
        }
示例#6
0
        public void TestLogin2()
        {
            Chatroom login = new Chatroom();

            login.RestartChatroom();
            login.Start();
            User userOne = new User("userOne");
            User userTwo = new User("userTwo");

            Console.WriteLine("after");
            login.Register(userTwo.Nickname);
            Boolean firstL = login.Login(userTwo.Nickname);

            Assert.AreEqual(firstL, true);
            Boolean secondL = login.Login("otheruser");

            Assert.AreEqual(secondL, false);
        }
示例#7
0
        public void Send_empty_message_OR_more_than_150()
        {
            Chatroom chatroom      = new Chatroom();
            String   dummyPassword = "******";

            chatroom.Register("Chen", 8, dummyPassword);
            chatroom.clearUsersList();
            chatroom.Login("Chen", 8, dummyPassword);

            Assert.IsFalse(chatroom.Send(""));
            Assert.IsFalse(chatroom.Send(" "));
            Assert.IsFalse(chatroom.Send("  "));
            Assert.IsFalse(chatroom.Send("MORE_THEN_150_CHARACTERS_MORE_THEN_150_CHARACTERS_" +
                                         "MORE_THEN_150_CHARACTERS_MORE_THEN_150_CHARACTERS_MORE_THEN_150_CHARACTERS_" +
                                         "MORE_THEN_150_CHARACTERS_MORE_THEN_150_CHARACTERS_MORE_THEN_150_CHARACTERS_"));
        }
示例#8
0
        private void Login_Button_Click(object sender, RoutedEventArgs e)
        {
            string password = loginObserver.Password;

            if (password != null)
            {
                String username = loginObserver.Username;
                int    groupID  = int.Parse(loginObserver.GroupID);
                bool?  checker  = chatroom.Login(username, groupID, password);
                if (checker.HasValue)
                {
                    if (checker.Value)
                    {
                        if (loginObserver.RememberMe) //remember me was ticked - save the user//
                        {
                            SaveRememberedUser(new User(username, groupID, "", -1));
                        }
                        else //wasn't ticked - save a "dummy" user
                        {
                            SaveRememberedUser(new User("", -1, "", -1));
                        }
                        Logger.Instance.Info("User: "******" logged-in successfully, starting chat window");
                        chat_window chat_window = new chat_window(chatroom);
                        chat_window.Show();
                        this.Close();
                    }
                    else
                    {
                        loginObserver.ErrorMessage = "Password is incorrect Please try again";
                        Logger.Instance.Error("User: "******"Typed incorrect Password ");
                    }
                }
                else
                {
                    loginObserver.ErrorMessage = "User not found, Please try again or register";
                    Logger.Instance.Error("User not found when trying to log-in");
                }
            }
        }
示例#9
0
        public void TestLogin()
        {
            chatroom.RestartChatroom();
            Console.WriteLine("after");
            chatroom.Register(userTwo.Nickname, userTwo.GroupID);
            Boolean firstL = chatroom.Login(userTwo.Nickname, userTwo.GroupID);

            Assert.AreEqual(firstL, true);
            Boolean secondL = chatroom.Login("otheruser", "4");

            Assert.AreEqual(secondL, false);
            chatroom.exit();
        }