diff --git a/Mailosaur.Test/EmailsTests.cs b/Mailosaur.Test/EmailsTests.cs index 68ef7c2..e90182d 100644 --- a/Mailosaur.Test/EmailsTests.cs +++ b/Mailosaur.Test/EmailsTests.cs @@ -527,6 +527,11 @@ private void ValidateHtml(Message email) Assert.Equal("http://invalid/", email.Html.Links[2].Href); Assert.Equal("invalid", email.Html.Links[2].Text); + // Html.Codes + Assert.Equal(2, email.Html.Codes.Count); + Assert.Equal("123456", email.Html.Codes[0].Value); + Assert.Equal("G3H1Y2", email.Html.Codes[1].Value); + // Html.Images Assert.StartsWith("cid:", email.Html.Images[1].Src); Assert.Equal("Inline image 1", email.Html.Images[1].Alt); @@ -543,6 +548,11 @@ private void ValidateText(Message email) Assert.Equal(email.Text.Links[0].Href, email.Text.Links[0].Text); Assert.Equal("https://mailosaur.com/", email.Text.Links[1].Href); Assert.Equal(email.Text.Links[1].Href, email.Text.Links[1].Text); + + // Text.Codes + Assert.Equal(2, email.Text.Codes.Count); + Assert.Equal("654321", email.Text.Codes[0].Value); + Assert.Equal("5H0Y2", email.Text.Codes[1].Value); } private void ValidateHeaders(Message email) diff --git a/Mailosaur.Test/Mailer.cs b/Mailosaur.Test/Mailer.cs index 0636219..05aea26 100644 --- a/Mailosaur.Test/Mailer.cs +++ b/Mailosaur.Test/Mailer.cs @@ -18,15 +18,16 @@ public static class Mailer private static readonly string s_VerifiedDomain = Environment.GetEnvironmentVariable("MAILOSAUR_VERIFIED_DOMAIN") ?? "mailosaur.net"; private static Random s_Random = new Random(); - public static void SendEmails(MailosaurClient client, string server, int quantity) { - for (var i = 0; i < quantity; i++) + public static void SendEmails(MailosaurClient client, string server, int quantity) + { + for (var i = 0; i < quantity; i++) SendEmail(client, server); } public static void SendEmail(MailosaurClient client, string server, string sendToAddress = null) { var host = Environment.GetEnvironmentVariable("MAILOSAUR_SMTP_HOST") ?? "mailosaur.net"; - var port = Environment.GetEnvironmentVariable("MAILOSAUR_SMTP_PORT") ?? "25"; + var port = Environment.GetEnvironmentVariable("MAILOSAUR_SMTP_PORT") ?? "25"; var message = new MailMessage(); @@ -41,36 +42,36 @@ public static void SendEmail(MailosaurClient client, string server, string sendT message.To.Add($"{randomString} {randomString} <{randomToAddress}>"); // Text body - message.Body = s_Text.Replace("REPLACED_DURING_TEST", randomString); - message.IsBodyHtml = false; - message.BodyEncoding = Encoding.UTF8; + message.Body = s_Text.Replace("REPLACED_DURING_TEST", randomString); + message.IsBodyHtml = false; + message.BodyEncoding = Encoding.UTF8; - // Html body + // Html body var htmlString = s_Html.Replace("REPLACED_DURING_TEST", randomString); - var htmlView = AlternateView.CreateAlternateViewFromString(htmlString, + var htmlView = AlternateView.CreateAlternateViewFromString(htmlString, new ContentType(MediaTypeNames.Text.Html)); - htmlView.TransferEncoding = TransferEncoding.Base64; - message.AlternateViews.Add(htmlView); + htmlView.TransferEncoding = TransferEncoding.Base64; + message.AlternateViews.Add(htmlView); - var image = new LinkedResource(Path.Combine("Resources", "cat.png")); - image.ContentId = "ii_1435fadb31d523f6"; + var image = new LinkedResource(Path.Combine("Resources", "cat.png")); + image.ContentId = "ii_1435fadb31d523f6"; image.ContentType = new ContentType("image/png"); htmlView.LinkedResources.Add(image); var attachment = new System.Net.Mail.Attachment(Path.Combine("Resources", "dog.png")); attachment.ContentType = new ContentType("image/png"); - message.Attachments.Add(attachment); + message.Attachments.Add(attachment); - var smtp = new SmtpClient(); - smtp.Host = host; - smtp.Port = int.Parse(port); + var smtp = new SmtpClient(); + smtp.Host = host; + smtp.Port = int.Parse(port); - smtp.Send(message); + smtp.Send(message); } - private static string RandomString() + private static string RandomString() { - const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; return new string(Enumerable.Repeat(chars, 10) .Select(s => s[s_Random.Next(s.Length)]).ToArray()); } diff --git a/Mailosaur.Test/Resources/testEmail.html b/Mailosaur.Test/Resources/testEmail.html index abce10b..60379d7 100644 --- a/Mailosaur.Test/Resources/testEmail.html +++ b/Mailosaur.Test/Resources/testEmail.html @@ -17,6 +17,14 @@ +
Codes { get; set; }
public IList Images { get; set; }
public string Body { get; set; }