public void GroupingByPhoneNumberTestVeryfyOutputLength()
        {
            SimCorpMobilePhone mob = new SimCorpMobilePhone();

            mob.CleareMessageStorage();
            var messages = new List <Message>
            {
                new Message {
                    UserName = "******", PhoneNumber = 1, ReceivingTime = new DateTime(2014, 1, 1), Text = "Message from Name1"
                },
                new Message {
                    UserName = "******", PhoneNumber = 2, ReceivingTime = new DateTime(2015, 1, 1), Text = "Message from Name2"
                },
                new Message {
                    UserName = "******", PhoneNumber = 3, ReceivingTime = new DateTime(2016, 1, 1), Text = "Message from Name3"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2017, 1, 1), Text = "Message from Name4"
                },
                new Message {
                    UserName = "******", PhoneNumber = 5, ReceivingTime = new DateTime(2018, 1, 1), Text = "Message from Name5"
                },
            };

            foreach (var msg in messages)
            {
                mob.AddMessage(msg);
            }

            var groupedKeys = mob.GroupingByPhoneNumber().ToList();

            Assert.AreEqual(groupedKeys.Count, 5);
        }
        public void FileterOrTestEmptyCase()
        {
            SimCorpMobilePhone mob = new SimCorpMobilePhone();

            mob.CleareMessageStorage();
            var messages = new List <Message>
            {
                new Message {
                    UserName = "******", PhoneNumber = 1, ReceivingTime = new DateTime(2014, 1, 1), Text = "Message from Name1"
                },
                new Message {
                    UserName = "******", PhoneNumber = 2, ReceivingTime = new DateTime(2015, 1, 1), Text = "Message from Name2"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2016, 1, 1), Text = "Message is not from Name3"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2017, 1, 1), Text = "Message from Name4"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2018, 1, 1), Text = "Message from Name4"
                },
            };

            foreach (var msg in messages)
            {
                mob.AddMessage(msg);
            }

            var filteredmessage = mob.FileterOr(44, "Name", new DateTime(2000, 1, 1), new DateTime(2020, 1, 1)).ToList();

            Assert.AreEqual(filteredmessage.Count, 0);
        }
        public void FileterAndTestByDateCaseLengthValidation()
        {
            SimCorpMobilePhone mob = new SimCorpMobilePhone();

            mob.CleareMessageStorage();
            var messages = new List <Message>
            {
                new Message {
                    UserName = "******", PhoneNumber = 1, ReceivingTime = new DateTime(2014, 1, 1), Text = "Message from Name1"
                },
                new Message {
                    UserName = "******", PhoneNumber = 2, ReceivingTime = new DateTime(2015, 1, 1), Text = "Message from Name2"
                },
                new Message {
                    UserName = "******", PhoneNumber = 3, ReceivingTime = new DateTime(2016, 1, 1), Text = "Message from Name3"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2017, 1, 1), Text = "Message from Name4"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2018, 1, 1), Text = "Message from Name4"
                },
            };

            foreach (var msg in messages)
            {
                mob.AddMessage(msg);
            }

            var filteredmessage = mob.FileterAnd(4, "", new DateTime(2017, 1, 1), new DateTime(2018, 1, 1)).ToList();

            Assert.AreEqual(filteredmessage.Count, 2);
        }
        public void FileterOrTestByDateVarifyFirstOutputElement()
        {
            SimCorpMobilePhone mob = new SimCorpMobilePhone();

            mob.CleareMessageStorage();
            var messages = new List <Message>
            {
                new Message {
                    UserName = "******", PhoneNumber = 1, ReceivingTime = new DateTime(2014, 1, 1), Text = "Message from Name1"
                },
                new Message {
                    UserName = "******", PhoneNumber = 2, ReceivingTime = new DateTime(2015, 1, 1), Text = "Message from Name2"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2016, 1, 1), Text = "Message is not from Name3"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2017, 1, 1), Text = "Message from Name4"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2018, 1, 1), Text = "Message from Name4"
                },
            };

            foreach (var msg in messages)
            {
                mob.AddMessage(msg);
            }

            var validfiltredmessage = new List <Message>
            {
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2016, 1, 1), Text = "Message is not from Name3"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2017, 1, 1), Text = "Message from Name4"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2018, 1, 1), Text = "Message from Name4"
                },
            };

            var filteredmessage = mob.FileterOr(4, "is not from Name3", new DateTime(2017, 1, 1), new DateTime(2018, 1, 1)).ToList();

            Assert.AreEqual(filteredmessage.Count, 3);

            for (int i = 0; i < 3; ++i)
            {
                Assert.AreEqual(CompareMessages(filteredmessage[i], validfiltredmessage[i]), true);
            }
            bool checkFlag = CompareMessages(filteredmessage[0], validfiltredmessage[0]) &&
                             CompareMessages(filteredmessage[1], validfiltredmessage[1]) &&
                             CompareMessages(filteredmessage[2], validfiltredmessage[2]);

            Assert.AreEqual(checkFlag, true);
        }
        public void FileterAndTestByDateVerifyOutputElements()
        {
            SimCorpMobilePhone mob = new SimCorpMobilePhone();

            mob.CleareMessageStorage();
            var messages = new List <Message>
            {
                new Message {
                    UserName = "******", PhoneNumber = 1, ReceivingTime = new DateTime(2014, 1, 1), Text = "Message from Name1"
                },
                new Message {
                    UserName = "******", PhoneNumber = 2, ReceivingTime = new DateTime(2015, 1, 1), Text = "Message from Name2"
                },
                new Message {
                    UserName = "******", PhoneNumber = 3, ReceivingTime = new DateTime(2016, 1, 1), Text = "Message from Name3"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2017, 1, 1), Text = "Message from Name4"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2018, 1, 1), Text = "Message from Name4"
                },
            };

            foreach (var msg in messages)
            {
                mob.AddMessage(msg);
            }

            var validfiltredmessage = new List <Message>
            {
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2017, 1, 1), Text = "Message from Name4"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2018, 1, 1), Text = "Message from Name4"
                },
            };

            var filteredmessage = mob.FileterAnd(4, "", new DateTime(2017, 1, 1), new DateTime(2018, 1, 1)).ToList();

            bool checkFlag = CompareMessages(filteredmessage[0], validfiltredmessage[0]) && CompareMessages(filteredmessage[1], validfiltredmessage[1]);

            Assert.AreEqual(checkFlag, true);
        }
        public void GroupingByPhoneNumberTestVerifyOutputElements()
        {
            SimCorpMobilePhone mob = new SimCorpMobilePhone();

            mob.CleareMessageStorage();
            var messages = new List <Message>
            {
                new Message {
                    UserName = "******", PhoneNumber = 1, ReceivingTime = new DateTime(2014, 1, 1), Text = "Message from Name1"
                },
                new Message {
                    UserName = "******", PhoneNumber = 2, ReceivingTime = new DateTime(2015, 1, 1), Text = "Message from Name2"
                },
                new Message {
                    UserName = "******", PhoneNumber = 3, ReceivingTime = new DateTime(2016, 1, 1), Text = "Message from Name3"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2017, 1, 1), Text = "Message from Name4"
                },
                new Message {
                    UserName = "******", PhoneNumber = 5, ReceivingTime = new DateTime(2018, 1, 1), Text = "Message from Name5"
                },
            };

            foreach (var msg in messages)
            {
                mob.AddMessage(msg);
            }

            var groupedKeys = mob.GroupingByPhoneNumber().ToList();

            bool checkFlag = true;

            for (int i = 0; i < 5; ++i)
            {
                checkFlag &= (groupedKeys[i] == i + 1);
            }

            Assert.AreEqual(checkFlag, true);
        }
        public void FileterOrTestByIncludedTextVarifyOutputElement()
        {
            SimCorpMobilePhone mob = new SimCorpMobilePhone();

            mob.CleareMessageStorage();
            var messages = new List <Message>
            {
                new Message {
                    UserName = "******", PhoneNumber = 1, ReceivingTime = new DateTime(2014, 1, 1), Text = "Message from Name1"
                },
                new Message {
                    UserName = "******", PhoneNumber = 2, ReceivingTime = new DateTime(2015, 1, 1), Text = "Message from Name2"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2016, 1, 1), Text = "Message is not from Name3"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2017, 1, 1), Text = "Message from Name4"
                },
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2018, 1, 1), Text = "Message from Name4"
                },
            };

            foreach (var msg in messages)
            {
                mob.AddMessage(msg);
            }

            var validfiltredmessage = new List <Message>
            {
                new Message {
                    UserName = "******", PhoneNumber = 4, ReceivingTime = new DateTime(2016, 1, 1), Text = "Message is not from Name3"
                }
            };

            var filteredmessage = mob.FileterOr(4, "is not from Name3", new DateTime(2019, 1, 1), new DateTime(2020, 1, 1)).ToList();

            Assert.AreEqual(CompareMessages(filteredmessage[0], validfiltredmessage[0]), true);
        }