public void TestGetLastMessageText_NoPrevious() { string original = @"<html> <body> This is a boring email. </body> </html>"; // Note: it's acceptable to not preserve whitespace / insert empty HTML tags because we're // manipulating HTML, not plain text. As long as the rendered page isn't impacted, all is well string expected = @"<html><head></head><body> This is a boring email. </body></html>"; string actual = EmailBodyProcessingUtils.GetLastMessageText_Html(original); Assert.AreEqual(Normalize(expected), Normalize(actual)); }
public void TestGetLastMessageText_Previous_FromColon() { string original = @"<html> <body> <div class=""wrapppingBothMessageAndReply""> <p class=""customStyling"">This is random text with some custom styling and outlook-generated elements.<o:p></o:p></p> <div> <div style=""border:none;border-top:solid""> <p class=""customStyling""><b>From:</b> someAddress;<br><b>Subject:</b> RE: Build error<o:p></o:p> </p> </div> </div> <p class=""customStyling""> <o:p> </o:p> </p> <p class=""customStyling"">text of the reply </p> </div> <div>Something after the containing div</div> </body> </html>"; // Note: it's acceptable to not preserve whitespace because it's // manipulating HTML, not plain text. As long as the rendered page isn't impacted, all is well // Note that we expect that both // 1. Elements following the latest message are removed // 2. Anything in the same element as the latest message but after the start of the previous should be cleared out string expected = @"<html><head></head><body> <div class=""wrapppingBothMessageAndReply""> <p class=""customStyling"">This is random text with some custom styling and outlook-generated elements.<o:p></o:p></p> <div> <div style=""border:none;border-top:solid""> <p class=""customStyling""><b></b></p></div></div></div></body></html>"; string actual = EmailBodyProcessingUtils.GetLastMessageText_Html(original); Assert.AreEqual(Normalize(expected), Normalize(actual)); }
public void TestGetLastMessageText_EmailClientsSchemas() { const string schemasFolder = "LastMessageSchemas"; foreach (var originalFilename in Directory.GetFiles(schemasFolder, "*.orig")) { Trace.WriteLine(string.Format("Processing email schema file {0}", originalFilename)); var baseFilename = Path.GetFileNameWithoutExtension(originalFilename); var expectedFilename = Path.Combine(schemasFolder, baseFilename + ".expected"); var original = File.ReadAllText(originalFilename); var expected = Normalize(File.ReadAllText(expectedFilename)); var actual = Normalize(EmailBodyProcessingUtils.GetLastMessageText_Html(original)); // Note: it's acceptable to not preserve whitespace because it's // manipulating HTML, not plain text. As long as the rendered page isn't impacted, all is well // Note that we expect that both // 1. Elements following the latest message are removed // 2. Anything in the same element as the latest message but after the start of the previous should be cleared out Assert.AreEqual(expected, actual); } }