Esempio n. 1
0
 public static string SwapOutPhrases(Contact contact, string input)
 {
     return input.Trim()
                 .Replace("[linebreak]", "\n") // looks silly, but AppSettings is wrong..
                 .Replace("[forename]", contact.Forename)
                 .Replace("[surname]", contact.Surname)
                 .Replace("[fullname]", contact.FullName)
                 .Replace("[year]", DateTime.Now.AddYears(1).Year.ToString());
 }
 public void TextMessaging_DoesReturnTrue_WhenSentSuccessfully()
 {
     var contact = new Contact
                   {
                       Forename = "Some",
                       Surname = "User",
                       DateOfBirth = DateTime.Now.AddYears(-1),
                       MobileNumber = "447870150140",
                       Gender = Contact.Sex.Male
                   };
     var service = new TextMessaging(new FakeTextMessagingService(true));
     Assert.True(service.SendTextMessageToContact(contact, "this is some message"));
 }
Esempio n. 3
0
 public bool SendTextMessageToContact(Contact contact, string message)
 {
     try
     {
         var number = DetermineMobileNumber(contact.MobileNumber);
         var text = SwapOutPhrases(contact, message);
         var textMessage = new TextMessage(number, text);
         _textingService.Send(textMessage);
         return true;
     }
     catch (InvalidOperationException)
     {
         return false;
     }
 }