Exemplo n.º 1
0
        public void TestFilter_OrLogic_Filtered()
        {
            //Arrange
            MyMessage        message;
            List <MyMessage> myReceivedMessages = new List <MyMessage>();
            MyFilter         filter             = new MyFilter();

            for (int i = 0; i < 50; i++)
            {
                message = new MyMessage();
                if (message.Text != null)
                {
                    myReceivedMessages.Add(message);
                }
            }
            string   expectedSubscriber = "+380939873546";
            string   expectedText       = "ao";
            DateTime fromDate           = DateTime.Now.AddDays(-1);
            DateTime toDate             = DateTime.Now.AddDays(1);

            //Act
            List <MyMessage> myFilteredMessages = filter.FilterOr(myReceivedMessages, expectedSubscriber, expectedText, fromDate, toDate);
            List <MyMessage> myExpectedMessages =
                (from m in myReceivedMessages
                 where (m.User == expectedSubscriber || m.Text.Contains(expectedText) || (fromDate <= m.ReceivingTime && toDate > m.ReceivingTime))
                 select m).ToList();

            //Assert
            Assert.IsTrue(myExpectedMessages.SequenceEqual(myFilteredMessages));
        }
Exemplo n.º 2
0
        private void timer_Tick(object sender, EventArgs e)
        {
            //string text = "New SMS received";         //from lab3
            MyMessage      message = new MyMessage();
            FormatDelegate currentFormat;

            currentFormat = Format.FormatType[comboBox1.SelectedIndex];

            //MyMobile.SMSProvider.ReceiveSMS(Format.OnSMSReceived(message.ToString(), currentFormat)); //lab4, task 0, variant 1

            if (message.Text != null)
            {
                myReceivedMessages.Add(message);
                if (!comboBox2.Items.Contains(message.User))
                {
                    comboBox2.Items.Add(message.User);
                }
            }

            List <MyMessage> listToDisplay = new List <MyMessage>();

            listToDisplay = myReceivedMessages;
            MyFilter filter = new MyFilter();

            if (checkBoxAndLogic.Checked == true)
            {
                listToDisplay = filter.FilterAnd(myReceivedMessages, comboBox2.SelectedItem, textBox1.Text, dateTimePicker1.Value, dateTimePicker2.Value);
            }
            if (checkBoxOrLogic.Checked == true)
            {
                listToDisplay = filter.FilterOr(myReceivedMessages, comboBox2.SelectedItem, textBox1.Text, dateTimePicker1.Value, dateTimePicker2.Value);
            }

            ShowMessages(listToDisplay, currentFormat);
            MyMobile.SMSProvider.ReceiveSMS(message);
        }