public void ErrorMessage_If_From_Address_Is_Missing() { var target = new ElasticemailWebApi(_apiKey); var actual = target.Send(new ElasticemailMessage()); Assert.AreEqual(ResultType.Error, actual.ResultType); Assert.IsTrue(actual.ErrorMessage.Contains("sender address is missing")); }
public void ErrorMessage_If_To_Address_Is_Missing() { var target = new ElasticemailWebApi(_apiKey); var mail = new ElasticemailMessage(); mail.From = new MailAddress("*****@*****.**", "John"); var actual = target.Send(mail); Assert.AreEqual(ResultType.Error, actual.ResultType); Assert.IsTrue(actual.ErrorMessage.Contains("recipient address is missing")); }
public void SendUnauthorized() { var target = new ElasticemailWebApi("invalidApiKey"); var mail = new ElasticemailMessage(); mail.From = new MailAddress("*****@*****.**", "John"); mail.To.Add(new MailAddress("*****@*****.**", "Anna")); var actual = target.Send(mail); Assert.AreEqual(ResultType.Error, actual.ResultType); Assert.IsTrue(actual.ErrorMessage.Contains("Unauthorized")); }
public void Send_Email_Returns_TransactionId() { var target = new ElasticemailWebApi(_apiKey); var mail = new ElasticemailMessage(); mail.To.Add(new MailAddress("*****@*****.**")); mail.From = new MailAddress("*****@*****.**", "Marc"); mail.ReplyTo = new MailAddress("*****@*****.**", "Marc"); mail.Subject = "Test"; mail.Body = "Body"; var actual = target.Send(mail); Assert.AreEqual(ResultType.Success, actual.ResultType); Assert.IsNotNull(actual.TransactionId); }
public void Send_Email_With_Attachment() { var target = new ElasticemailWebApi(_apiKey); var mail = new ElasticemailMessage(); mail.To.Add(new MailAddress("*****@*****.**", "Marc")); mail.From = new MailAddress("*****@*****.**", "Marc"); mail.ReplyTo = new MailAddress("*****@*****.**", "Marc"); mail.Subject = "Test"; mail.Body = "Body"; mail.AddAttachment("file.txt", new byte[100]); mail.AddAttachment("file2.txt", new byte[200]); var actual = target.Send(mail); Assert.AreEqual(ResultType.Success, actual.ResultType); Assert.IsNotNull(actual.TransactionId); }