Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        public void FilterAndAllFiltersTest()
        {
            //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 #5"));
            //Act
            MessageFilter  messageFilter    = new MessageFilter();
            List <Message> filteredMessages = messageFilter.AndAllFilters(messages, "+3802", "#5", new DateTime(2017, 1, 1), new DateTime(2099, 1, 1));

            //Assert
            Assert.AreEqual(expectedResult[0].Text, filteredMessages[0].Text);
        }