public void FilterOrAllFiltersTest()
        {
            //Arrange
            List <Message> messages = new List <Message>();

            messages.Add(new Message("+3801", "+38 777", $"Message #1"));
            messages.Add(new Message("+3802", "+38 777", $"Message #2"));
            messages.Add(new Message("+3802", "+38 777", $"Message #22"));
            messages.Add(new Message("+3803", "+38 777", $"Message #4"));
            messages.Add(new Message("+3802", "+38 777", $"Message #5"));
            List <Message> expectedResult = new List <Message>();

            expectedResult.Add(new Message("+3802", "+38 777", $"Message #2"));
            expectedResult.Add(new Message("+3802", "+38 777", $"Message #22"));
            expectedResult.Add(new Message("+3803", "+38 777", $"Message #5"));
            expectedResult.Add(new Message("+3802", "+38 777", $"Message #4"));
            //Act
            MessageFilter  messageFilter    = new MessageFilter();
            List <Message> filteredMessages = messageFilter.OrAllFilters(messages, "+3802", "#4", new DateTime(2017, 1, 1), new DateTime(2017, 1, 1));

            //Assert
            for (int i = 0; i < 4; i++)
            {
                Assert.AreEqual(expectedResult[i].Text, filteredMessages[i].Text);
            }
        }
Exemplo n.º 2
0
        private void ApplyFilterButton_Click(object sender, System.EventArgs e)
        {
            List <MobilePhoneClassLib.Message> messages = MsgStorage.GetAllMessages();
            List <MobilePhoneClassLib.Message> filteredMessages;
            MessageFilter messageFilter = new MessageFilter();

            if (OrCheckBox.Checked)
            {
                filteredMessages = messageFilter.OrAllFilters(messages, SMSNumberComboBox.Text.ToUpper(), SMSTextTextBox.Text.ToUpper(), FromDateTimePicker.Value, ToDateTimePicker.Value);
                ShowMessages(filteredMessages);
            }
            else
            {
                filteredMessages = messageFilter.AndAllFilters(messages, SMSNumberComboBox.Text.ToUpper(), SMSTextTextBox.Text.ToUpper(), FromDateTimePicker.Value, ToDateTimePicker.Value);
                ShowMessages(filteredMessages);
            }
        }