示例#1
0
 public void TestAuthenticatedNoPort()
 {
     //---------------Set up test pack-------------------
     string[] recipients = { "to", "to2" };
     EmailSender sender = new EmailSender(recipients, "from", "subject", "content", "attach");
     sender.SmtpServerHost = "testhost";
     //---------------Execute Test ----------------------
     try
     {
         sender.SendAuthenticated("username", "password");
         Assert.Fail("Expected to throw an FormatException");
     }
         //---------------Test Result -----------------------
     catch (FormatException ex)
     {
         StringAssert.Contains("The specified string is not in the form required for an e-mail address", ex.Message);
     }
 }
示例#2
0
 public void TestAuthenticatedNoHost()
 {
     //---------------Set up test pack-------------------
     string[] recipients = { "to" };
     EmailSender sender = new EmailSender(recipients, "from", "subject", "content", "attach");
     //---------------Execute Test ----------------------
     try
     {
         sender.SendAuthenticated("username", "password");
         Assert.Fail("Expected to throw an Exception");
     }
         //---------------Test Result -----------------------
     catch (Exception ex)
     {
         StringAssert.Contains("Please specify the SMTP Host Name before attempting to send", ex.Message);
     }
 }