public void FilterByFilterTo_ReturnMessagesThatAreLessThanFilterToTest()
        {
            //Arrenge
            //Create and fill SMS Repository
            SMSStorage sMSStorage = new SMSStorage(FiltersState, ExpectedFilteredMessages1);

            AddMessagesToSMSStorage(sMSStorage);
            //Create Filter Criteria
            FilterTo.Value = FakeDateTime.AddSeconds(2);
            //Create Expected Filtered Messages
            var ExpectedMessages = new List <SMS>();

            ExpectedMessages.Add(new SMS()
            {
                Sender       = "Mom",
                Text         = "test text message #1",
                TimeReceived = FakeDateTime.AddSeconds(1)
            });
            //Act
            FiltersState.Update(_sender, new SMSFormEventArgs(UserSelectedSender, FilterFrom, FilterTo, TextToSearch)
            {
            });
            //Assert
            Assert.AreEqual(1, sMSStorage.FilteredMessages.Count);
            Assert.AreEqual(ExpectedMessages[0].Sender, sMSStorage.FilteredMessages[0].Sender);
            Assert.AreEqual(ExpectedMessages[0].Text, sMSStorage.FilteredMessages[0].Text);
            Assert.AreEqual(ExpectedMessages[0].TimeReceived, sMSStorage.FilteredMessages[0].TimeReceived);
        }
        public void FilterByMultipleFilterCriteria_Test()
        {
            //Arrenge
            //Create and fill SMS Repository
            SMSStorage sMSStorage = new SMSStorage(FiltersState, ExpectedFilteredMessages1);

            AddMessagesToSMSStorage(sMSStorage);
            //Create Filter Criteria
            UserSelectedSender.Items.Add("Mom");
            UserSelectedSender.SelectedIndex = 1;
            FilterFrom.Value  = FakeDateTime.AddSeconds(2);
            FilterTo.Value    = FakeDateTime.AddSeconds(6);
            TextToSearch.Text = "unique";
            //Create Expected Filtered Messages
            var ExpectedMessages = new List <SMS>();

            ExpectedMessages.Add(new SMS()
            {
                Sender       = "Mom",
                Text         = "test unique text message #5",
                TimeReceived = FakeDateTime.AddSeconds(5)
            });
            //Act
            FiltersState.Update(_sender, new SMSFormEventArgs(UserSelectedSender, FilterFrom, FilterTo, TextToSearch)
            {
            });
            //Assert
            Assert.AreEqual(1, sMSStorage.FilteredMessages.Count);
            Assert.AreEqual(ExpectedMessages[0].Sender, sMSStorage.FilteredMessages[0].Sender);
            Assert.AreEqual(ExpectedMessages[0].Text, sMSStorage.FilteredMessages[0].Text);
            Assert.AreEqual(ExpectedMessages[0].TimeReceived, sMSStorage.FilteredMessages[0].TimeReceived);
        }
 private void AddMessagesToSMSStorage(SMSStorage fakeSMSStorage)
 {
     foreach (var message in Messages)
     {
         fakeSMSStorage.AddToStorage(message);
     }
 }
Exemplo n.º 4
0
        public void Test_NewMessageAddedToStorage()
        {
            //Act
            SMSStorage.AddMessage("Message1");

            //Assert
            Assert.IsTrue(SMSStorage.messages.Contains("Message1"));
        }
Exemplo n.º 5
0
        public void Test_MessageRemovedFromStorage()
        {
            //Act
            SMSStorage.RemoveMessage(SMSStorage.messages.Count - 1);

            //Assert
            Assert.IsFalse(SMSStorage.messages.Contains("Message1"));
        }
Exemplo n.º 6
0
        public MessageBoxForm()
        {
            InitializeComponent();
            smsStorage    = new SMSStorage();
            messageFilter = new MessagesFiltering();

            ISMSGeneratingFactory smsGenerateFactory = new SMSGeneratingFactory(recievedMessagesRichTextBox);

            // Creation of smsGenerating using Simple Factory
            smsGenerating = smsGenerateFactory.CreateGeneratingType(GenerateType.smsGeneratingTask);
            // smsGenerating = smsGenerateFactory.CreateGeneratingType(GenerateType.smsGeneratingThread);

            //Create a list of messages
            messages = new List <Message>();

            //Add data to the list of messages
            messages.Add(new Message()
            {
                User = "******", Text = "Today's game was awesome! Thanks for your participation", RecievingTime = new DateTime(2018, 8, 31, 20, 48, 45)
            });
            messages.Add(new Message()
            {
                User = "******", Text = "Hi! How are you doing?", RecievingTime = new DateTime(2020, 1, 3, 16, 32, 7)
            });
            messages.Add(new Message()
            {
                User = "******", Text = "Good morning! Please call me back ASAP", RecievingTime = new DateTime(2020, 4, 13, 9, 10, 6)
            });
            messages.Add(new Message()
            {
                User = "******", Text = "Hello! Christmas sales are coming!", RecievingTime = new DateTime(2019, 12, 15, 9, 20, 3)
            });
            messages.Add(new Message()
            {
                User = "******", Text = "Hello! We have special offer for you!", RecievingTime = new DateTime(2020, 2, 5, 12, 15, 16)
            });

            //Show messages on the form
            ShowMessage(messages);

            //Battery info
            Battery.Charge          = 100;
            chargeProgressBar.Value = 100;
            IChargeFactory chargeFactory = new ChargeFactory(chargeProgressBar);

            // Creation of batteryCharge using Simple Factory
            batteryCharge = chargeFactory.CreateChargeType(ChargeType.chargeTask);
            //batteryCharge = chargeFactory.CreateChargeType(ChargeType.chargeThread);


            //things to do before form closing
            FormClosing += MessageBoxForm_FormClosing;

            //flag to check if SMS generating is running
            smsRecievingIsActive = false;
        }
Exemplo n.º 7
0
 public MobileSimcorp(IBattery battery, Keyboard keyboard, Microphone microphone, SimCard simCard,
                      SMSProvider sMSProvider, SMSStorage sMSStorage)
 {
     Battery     = battery;
     Keyboard    = keyboard;
     Microphone  = microphone;
     SimCard     = simCard;
     SMSProvider = SMSProvider;
     SMSStorage  = SMSStorage;
 }
Exemplo n.º 8
0
 public static string GetSMSStorageString(SMSStorage s)
 {
     switch (s)
     {
         case SMSStorage.memory: return "\"ME\"";
         case SMSStorage.memory_plus_SIM: return "\"MT\"";
         case SMSStorage.SIM_card: return "\"SM\"";
         default: return "\"unknown\"";
     }
 }
Exemplo n.º 9
0
        public void GetAllSMSMessages()
        {
            Output.Clear();
            var messages = SMSStorage.GetAllSMSMessages();

            messages.ForEach(message =>
            {
                Output.WriteMessage(message);
                message.IsRead = true;
            });
            Output.WriteLine($"Successfully read all messages.");
        }
Exemplo n.º 10
0
 public MobileSimcorp(ScreenBase screen, IBattery battery, Keyboard keyboard, Microphone microphone, ISpeaker speaker, SimCard simCard,
                      SMSProvider sMSProvider, SMSStorage sMSStorage)
 {
     Screen      = screen;
     Battery     = battery;
     Keyboard    = keyboard;
     Microphone  = microphone;
     Speaker     = speaker;
     SimCard     = simCard;
     SMSProvider = SMSProvider;
     SMSStorage  = SMSStorage;
 }
Exemplo n.º 11
0
        public void GetAllSMSMessages(SearchConditions conditions)
        {
            Output.Clear();
            var messages = SMSStorage.GetAllSMSMessages(conditions);

            messages.ForEach(message =>
            {
                Output.WriteMessage(message);
                message.IsRead = true;
            });
            Output.WriteLine($"Successfully read all messages with selected conditions.");
        }
Exemplo n.º 12
0
 private void SMSHandler(SMSProvider provider, SMSMessage message)
 {
     try
     {
         SMSStorage.SaveSMSMessage(message);
         var count = SMSStorage.GetNumberOfUnreadMessages();
         Output.WriteLine($"New message from {message.From}, you have {count} unread messages.");
     }
     catch (SMSStorageMemoryOverflow ex)
     {
         Output.WriteLine(ex.Message);
     }
 }
Exemplo n.º 13
0
        public void SMSStorageTest()
        {
            // -- Arrange
            var smsStorage = new SMSStorage();
            var meessage   = "SimCorp";
            var expected   = 1;

            // -- Act
            smsStorage.ReceiveMessage(meessage);
            var actual = smsStorage.MessageList.Count;

            // -- Assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 14
0
        private void InitializeComboBox()
        {
            var smsStorage      = new SMSStorage();
            var receievers      = smsStorage.Receievers;
            var receieversCount = receievers.Count;

            System.Object[] ItemObject = new System.Object[receieversCount + 1];
            for (int i = 0; i < receieversCount; i++)
            {
                ;
                ItemObject[i] = receievers[i];
            }
            ItemObject[receieversCount] = "";
            comboBoxUsers.Items.AddRange(ItemObject);
        }
Exemplo n.º 15
0
        public void AddMessageTest()
        {
            bool           eventWasRaised = false;
            SMSStorage     smsStorage     = new SMSStorage();
            Message        message        = new Message("User", "0001", "Text", Convert.ToDateTime("02-10-2020"));
            List <Message> messages       = new List <Message>();

            messages.Add(message);

            smsStorage.MessageAdded += () => { eventWasRaised = true; };
            smsStorage.AddMessages(messages);

            Assert.IsTrue(eventWasRaised);
            Assert.AreEqual(1, smsStorage.Storage.Count());
        }
Exemplo n.º 16
0
        public void RaiseEventTest()
        {
            // -- Arrange
            var    smsStorage = new SMSStorage();
            var    message    = "SimCorp";
            string actual     = null;

            // -- Act
            smsStorage.SMSProviderService.SMSRecieved += (m) => actual = m;
            smsStorage.SMSProviderService.OnSMSRecieved(message);

            // -- Assert
            Assert.IsNotNull(actual);
            Assert.AreEqual("SimCorp", actual);
        }
        public void FilterBySender_MultipleReturnedMessages_OrderedByTimeReceivedTest()
        {
            //Arrenge
            //Create and fill SMS Repository
            SMSStorage sMSStorage = new SMSStorage(FiltersState, ExpectedFilteredMessages1);

            AddMessagesToSMSStorage(sMSStorage);
            //Create Filter Criteria
            UserSelectedSender.Items.Add("Mom");
            UserSelectedSender.SelectedIndex = 1;
            //Create Expected Filtered Messages
            ExpectedFilteredMessages2 = new List <SMS>();
            ExpectedFilteredMessages2.Add(new SMS()
            {
                Sender       = "Mom",
                Text         = "test text message #1",
                TimeReceived = FakeDateTime.AddSeconds(1)
            });
            ExpectedFilteredMessages2.Add(new SMS()
            {
                Sender       = "Mom",
                Text         = "test text message #4",
                TimeReceived = FakeDateTime.AddSeconds(4)
            });
            ExpectedFilteredMessages2.Add(new SMS()
            {
                Sender       = "Mom",
                Text         = "test unique text message #5",
                TimeReceived = FakeDateTime.AddSeconds(5)
            });
            //Act
            FiltersState.Update(_sender, new SMSFormEventArgs(UserSelectedSender, FilterFrom, FilterTo, TextToSearch)
            {
            });
            //Assert
            Assert.AreEqual(3, sMSStorage.FilteredMessages.Count);
            Assert.AreEqual(ExpectedFilteredMessages2[0].Sender, sMSStorage.FilteredMessages[0].Sender);
            Assert.AreEqual(ExpectedFilteredMessages2[0].Text, sMSStorage.FilteredMessages[0].Text);
            Assert.AreEqual(ExpectedFilteredMessages2[0].TimeReceived, sMSStorage.FilteredMessages[0].TimeReceived);
            Assert.AreEqual(ExpectedFilteredMessages2[1].Sender, sMSStorage.FilteredMessages[1].Sender);
            Assert.AreEqual(ExpectedFilteredMessages2[1].Text, sMSStorage.FilteredMessages[1].Text);
            Assert.AreEqual(ExpectedFilteredMessages2[1].TimeReceived, sMSStorage.FilteredMessages[1].TimeReceived);
            Assert.AreEqual(ExpectedFilteredMessages2[2].Sender, sMSStorage.FilteredMessages[2].Sender);
            Assert.AreEqual(ExpectedFilteredMessages2[2].Text, sMSStorage.FilteredMessages[2].Text);
            Assert.AreEqual(ExpectedFilteredMessages2[2].TimeReceived, sMSStorage.FilteredMessages[2].TimeReceived);
        }
        public void FilterByTextTest()
        {
            //Arrenge
            //Create and fill SMS Repository
            SMSStorage sMSStorage = new SMSStorage(FiltersState, ExpectedFilteredMessages1);

            AddMessagesToSMSStorage(sMSStorage);
            //Create Filter Criteria
            TextToSearch.Text = "#3";
            //Act
            FiltersState.Update(_sender, new SMSFormEventArgs(UserSelectedSender, FilterFrom, FilterTo, TextToSearch)
            {
            });
            //Assert
            Assert.AreEqual(1, sMSStorage.FilteredMessages.Count);
            Assert.AreEqual(ExpectedFilteredMessages3[0].Sender, sMSStorage.FilteredMessages[0].Sender);
            Assert.AreEqual(ExpectedFilteredMessages3[0].Text, sMSStorage.FilteredMessages[0].Text);
            Assert.AreEqual(ExpectedFilteredMessages3[0].TimeReceived, sMSStorage.FilteredMessages[0].TimeReceived);
        }
        internal SimCorpMobileModel(IOutput output, MobileModels mobileModel, Screen screen, Microphone microphone,
                                    Battery battery, Speaker dynamic, int availableSimCardSlots, SMSStorage smsStorage)
        {
            Output                = output;
            Screen                = screen;
            MobileModel           = mobileModel;
            Microphone            = microphone;
            Battery               = battery;
            Speaker               = dynamic;
            AvailableSimCardSlots = availableSimCardSlots;
            SMSStorage            = smsStorage;

            var discharger = new BatteryDischarger(-1);

            discharger.Discharge += Battery.DecreaseChargeLevel;
            discharger.Start();
            var thread = new Thread(CheckBattery);

            thread.Start();
            thread.IsBackground = true;
        }
Exemplo n.º 20
0
 private SMSFormatDelegate SMSFormatDelegate = new SMSFormatDelegate(FormatNone);//default value
 public SMSForm()
 {
     InitializeComponent();
     Output  = new ListView(lvSMS);
     Filter  = new SMSFilterState(FilteredMessages);
     Storage = new SMSStorage(Filter, FilteredMessages);
     #region Background thread
     this.Shown          += BackgroundWorkerSendSMS;
     Storage.SMSSaved    += UpdateGUISenders;
     Storage.SMSRemoved  += UpdateGUIListView;
     Storage.SMSQueued   += UpdateGUIListView;
     Filter.StateUpdated += UpdateGUIListView;
     #endregion
     #region GUI thread
     cboSMSSenderSelector.SelectedIndexChanged += new EventHandler(UpdateGUIFiltersBySender);    //Sender
     dtFilterFromTime.ValueChanged             += new EventHandler(UpdateGUIFiltersByTime);      //FromDate
     dtFilterToTime.ValueChanged                   += new EventHandler(UpdateGUIFiltersByTime);  //ToDate
     tbSearchTextInMessages.TextChanged            += new EventHandler(UpdateGUIFiltersByText);  //SearchText
     cboSMSFormatSelector.SelectionChangeCommitted += new EventHandler(UpdateFormatTextHandler); //Assign Delegate Handler
     cboSMSFormatSelector.SelectionChangeCommitted += new EventHandler(UpdateGUIListView);       //Format
     #endregion
 }
Exemplo n.º 21
0
 public void DeleteSMSMessages(List <Guid> guids)
 {
     SMSStorage.DeleteSMSMessages(guids);
     Output.WriteLine($"Successfully deleted selected messages.");
 }
Exemplo n.º 22
0
 private static void M_OnNewSMSReceived(SMSStorage storage, SMS sms)
 {
     Console.WriteLine("New Message : " + storage);
     Console.WriteLine(sms.Sender + " : " + sms.Message);
     m.SMS_Delete(sms.MessageID);
 }
Exemplo n.º 23
0
 public SMSStorageDetail()
 {
     Storage = SMSStorage.unknown;
     Total = Used = "-1";
 }
Exemplo n.º 24
0
 public void DeleteAllSMSMessages()
 {
     SMSStorage.DeleteAllSMSMessages();
     Output.WriteLine($"Successfully deleted all messages.");
 }