public void CheckSortMessagesByAllCriteria_MessagesSorted_ReturnsSortedList()
        {
            //Arrange
            MessageFrame messages1 = new MessageFrame();
            MessageFrame messages2 = new MessageFrame();

            //Act
            for (int i = 0; i <= 50; i++)
            {
                Guid    id = new Guid();
                Message m  = new Message("test" + i, DateTime.Now, id, new User("test" + i, "test", i.ToString()));
                messages1.NewUserMessage(m);
            }
            messages2.messages = messages1.messages;
            List <Message> l2 = messages2.messages.ToList();

            Shuffle(l2);
            var queue = new Queue <Message>(l2);

            messages2.messages = queue;
            messages2.SortingMethods("All Criteria", true);

            //Assert
            Assert.AreEqual(messages1.messages, messages2.messages);
        }
        public void CheckMessageFiltering_MessagesFiltered_ReturnsFilteredList()
        {
            //Arrange
            MessageFrame messages = new MessageFrame();

            String[]  filters = { "18", "test" };
            const int EXPECTED_MESSAGES_COUNT = 20;
            int       correctOutputCounter    = 0;
            var       chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
            Random    rand  = new Random();

            String[]        sortingMethods = { "Username", "Timestamp", "All Criteria" };
            List <String[]> output;

            //Act
            for (int i = 0; i < EXPECTED_MESSAGES_COUNT; i++)
            {
                Guid    id = new Guid();
                Message m  = new Message("test", DateTime.Now, id, new User("test", "test", "18"));
                messages.NewUserMessage(m);
            }

            for (int i = 0; i <= 300; i++)
            {
                Guid    id = new Guid();
                Message m  = new Message("test", DateTime.Now, id, new User("test" + rand.Next(chars.Length), "test", i.ToString()));
                messages.NewUserMessage(m);
            }

            List <Message> messageList = messages.messages.ToList();

            Shuffle(messageList);
            output = messages.DisplayFiltered_Messages(filters, "All Criteria", true);

            foreach (String[] message in output)
            {
                correctOutputCounter = ((message[0] == "test") && (message[3] == "18")) ? correctOutputCounter + 1 : correctOutputCounter;
            }

            //Assert
            Assert.AreEqual(EXPECTED_MESSAGES_COUNT, correctOutputCounter);
        }
        public void CheckNewMessageSaved_MessageSaved_ReturnsMessage()
        {
            MessageFrame messages2 = new MessageFrame();

            for (int i = 0; i <= 50; i++)
            {
                Guid    id = new Guid();
                Message m  = new Message("test" + i, DateTime.Now, id, new User("test", "test", "18"));
                messages2.NewUserMessage(m);
                Assert.AreEqual(m, messages2.messages.Peek());
            }
        }