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);
        }
Example #2
0
        public void EventMessageTest()
        {
            SimCorpMobilePhone mobile = new SimCorpMobilePhone();

            mobile.SMSProvider.SMSReceived += CheckEventMessage;
            SMSProvider.SMSStartSendingDelegate startDel = mobile.SMSProvider.ReceiveMessage;
            startDel(1);
            var expectedEventMessage = "Message #0 received!";

            Assert.AreEqual(expectedEventMessage, actualEventMessage);
        }
        private void initDelegates()
        {
            vMobPhone = new SimCorpMobilePhone();
            vMobPhone.SetFormatMode(0);
            vMobPhone.SetMessageIsAddedDelegat(OnListViewMessageAdded);
            vMobPhone.SetMessageIsRemoveDelegat(OnListViewMessageRemoved);

            vSmsGenerator = new SMSGenerator(2000, vMobPhone);

            vKickOffSmsGenerator = new EventHandler(OnInitSmsGenerator);
            vKickOffSmsGenerator.Invoke(this, null);
        }
        public void SimCorpMobilePhoneTestChargeBeingDecreaseByTaskVerifyOutputCount()
        {
            var genValueOfCharge   = new List <int>();
            int max_charge         = 1000;
            SimCorpMobilePhone mob = new SimCorpMobilePhone(JobType.Task, currentCharge: max_charge, maxCharge: max_charge);

            mob.SetBatteryChargeChangeDelegat((e) => genValueOfCharge.Add(e));
            int ellapsedTime = 1;//ms - generate uncharge event every 1 ms.

            mob.SetEllapsedTimes(unchargeBatteryTime: ellapsedTime);

            //uncharging is activated automaticly. So invoke mention above delegate;
            //charging is not activated so it is exclude from the charging process.
            Thread.Sleep(5000);

            Assert.AreEqual(genValueOfCharge.Count() > 0, true);
        }
        public void UnofficialiPhoneHeadsetTest()
        {
            var       mobile            = new SimCorpMobilePhone();
            var       consoleOutput     = new ConsoleOutput();
            IPlayback playbackComponent = new UnofficialiPhoneHeadset(consoleOutput);

            mobile.PlaybackComponent = playbackComponent;
            var expected1 = "UnofficialiPhoneHeadset playback selected";
            var actual1   = consoleOutput.textTest;

            Assert.AreEqual(expected1, actual1);
            mobile.Play();
            var expected = "UnofficialiPhoneHeadset sound";
            var actual   = consoleOutput.textTest;

            Assert.AreEqual(expected, actual);
        }
        public void PhoneSpeakerTest()
        {
            var       mobile            = new SimCorpMobilePhone();
            var       consoleOutput     = new ConsoleOutput();
            IPlayback playbackComponent = new PhoneSpeaker(consoleOutput);

            mobile.PlaybackComponent = playbackComponent;
            var expected1 = "PhoneSpeaker playback selected";
            var actual1   = consoleOutput.textTest;

            Assert.AreEqual(expected1, actual1);
            mobile.Play();
            var expected = "PhoneSpeaker sound";
            var actual   = consoleOutput.textTest;

            Assert.AreEqual(expected, actual);
        }
Example #7
0
        public void UnofficialiPhoneChargerTest()
        {
            var     mobile           = new SimCorpMobilePhone();
            var     consoleOutput    = new ConsoleOutput();
            ICharge chargerComponent = new UnofficialiPhoneCharger(consoleOutput);

            mobile.ChargerComponent = chargerComponent;
            var expected1 = "UnofficialiPhoneCharger selected";
            var actual1   = consoleOutput.textTest;

            Assert.AreEqual(expected1, actual1);
            mobile.Charge();
            var expected = "Charging by UnofficialiPhoneCharger";
            var actual   = consoleOutput.textTest;

            Assert.AreEqual(expected, actual);
        }
        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);
        }
Example #9
0
        private void InitializeMobilePhone()
        {
            output        = new WinFormOutput(richTextBox1);
            myMobilePhone = new SimCorpMobilePhone(output);
            playbacks     = new List <object>
            {
                new iPhoneHeadset(output),
                new SamsungHeadset(output),
                new UnofficialHeadset(output),
                new PhoneSpeaker(output)
            };

            chargeUnits = new List <object>
            {
                new iChargeUnit(output),
                new SamsungChargeUnit(output),
                new UnofficialChargeUnit(output)
            };
        }
        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);
        }
        public void SimCorpMobilePhoneTestHighChargeThresholdByTask()
        {
            int max_charge         = 100;
            SimCorpMobilePhone mob = new SimCorpMobilePhone(JobType.Task, currentCharge: max_charge, maxCharge: max_charge);
            int ellapsedTime       = 1;// generate charge event every 1ms

            mob.SetEllapsedTimes(chargeBatteryTime: ellapsedTime, unchargeBatteryTime: 10000000);
            mob.StartCharging();

            //uncharging is activated automaticly but with grate amount of ellapsed time.
            //charging is activated too with period of 1 ms.
            bool checkFlag = true;

            Thread.Sleep(1000 * ellapsedTime);
            checkFlag &= mob.GetCurrentStateOfCharge() <= max_charge;
            Thread.Sleep(2000 * ellapsedTime);
            checkFlag &= mob.GetCurrentStateOfCharge() <= max_charge;
            Thread.Sleep(3000 * ellapsedTime);
            checkFlag &= mob.GetCurrentStateOfCharge() <= max_charge;

            Assert.AreEqual(checkFlag, true);
        }
        public void SimCorpMobilePhoneTestLowChargeThresholdByTask()
        {
            int max_charge         = 100;
            SimCorpMobilePhone mob = new SimCorpMobilePhone(JobType.Task, currentCharge: 0, maxCharge: max_charge);
            int ellapsedTime       = 1000;// generate uncharge event every 1s

            mob.SetEllapsedTimes(unchargeBatteryTime: ellapsedTime);

            //uncharging is activated automaticly.
            //charging is not activated.
            bool checkFlag = true;

            Thread.Sleep(ellapsedTime);
            checkFlag &= mob.GetCurrentStateOfCharge() == 0;
            Thread.Sleep(ellapsedTime);
            checkFlag &= mob.GetCurrentStateOfCharge() == 0;
            Thread.Sleep(ellapsedTime);
            checkFlag &= mob.GetCurrentStateOfCharge() == 0;

            Assert.AreEqual(checkFlag, true);

            mob.Dispose();
        }
Example #14
0
        static void Main(string[] args)
        {
            var mob = new SimCorpMobilePhone();

            Console.WriteLine(mob.ToString());
        }
Example #15
0
        static void Main(string[] args)
        {
            SimCorpMobilePhone mobile = new SimCorpMobilePhone();

            Console.WriteLine(mobile.GetDescription());
        }