Пример #1
0
        public void GetNumberOfUnreadMessagesTest()
        {
            var usedCapacity = _smsStorage.GetTotalCapacity() - _smsStorage.GetRemainingCapacity();

            Assert.AreEqual(usedCapacity, _smsStorage.GetNumberOfUnreadMessages());

            _smsStorage.GetAllSMSMessages().ForEach(message => message.IsRead = true);
            Assert.AreEqual(0, _smsStorage.GetNumberOfUnreadMessages());

            _smsStorage.SaveSMSMessage(new SMSMessage(Guid.NewGuid(), PHONE_NUMBER1, TEXT_MESSAGE, DateTime.Now, _smsProvider1));
            Assert.AreEqual(1, _smsStorage.GetNumberOfUnreadMessages());
        }
Пример #2
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);
     }
 }