Exemple #1
0
 //clears the messages panel and populates it with the right messages as given from the chatroom
 private void NewView()
 {
     _main.Messages.Clear();
     foreach (String s in chatroom.GetAllMessages(true))
     {
         _main.Messages.Add(s);
     }
 }
        public void TestSortByName()
        {
            String        first  = "message of userOne";
            String        second = "message of userTwo";
            String        third  = "message of userThree";
            String        fourth = "message of userFour";
            List <String> test   = new List <String>(4)
            {
                fourth,
                first,
                third,
                second
            };

            chatroom.RestartChatroom();

            chatroom.Register(userThree.Nickname, userThree.GroupID);
            chatroom.Login(userThree.Nickname, userThree.GroupID);
            chatroom.WriteMessage(third);
            chatroom.Logout();

            chatroom.Register(userFour.Nickname, userFour.GroupID);
            chatroom.Login(userFour.Nickname, userFour.GroupID);
            chatroom.WriteMessage(fourth);
            chatroom.Logout();

            chatroom.Register(userOne.Nickname, userOne.GroupID);
            chatroom.Login(userOne.Nickname, userOne.GroupID);
            chatroom.WriteMessage(first);
            chatroom.Logout();

            chatroom.Register(userTwo.Nickname, userTwo.GroupID);
            chatroom.Login(userTwo.Nickname, userTwo.GroupID);
            chatroom.WriteMessage(second);

            chatroom.SetFilterAndSort(1, 0, true, "", "");
            List <String> messages = chatroom.GetAllMessages();
            int           i        = 0;

            foreach (String mess in messages)
            {
                Assert.AreEqual(mess.Contains(test[i]), true);
                i++;
            }

            chatroom.SetFilterAndSort(1, 0, false, "", "");
            messages = chatroom.GetAllMessages();
            i        = 3;
            foreach (String mess in messages)
            {
                Assert.AreEqual(mess.Contains(test[i]), true);
                i--;
            }
        }