public void ToAttachmentData_Text() { var attachment = new TextAttachment("name", MimeTypes.PlainText, "content"); AttachmentData attachmentData = attachment.ToAttachmentData(); Assert.AreEqual("name", attachmentData.Name); Assert.AreEqual(MimeTypes.PlainText, attachmentData.ContentType); Assert.AreEqual("content", attachmentData.GetText()); Assert.AreEqual(AttachmentContentDisposition.Inline, attachmentData.ContentDisposition); Assert.AreEqual(AttachmentType.Text, attachmentData.Type); }
public void VisitEmbedTag(EmbedTag tag) { AttachmentData attachment = testStepRun.TestLog.GetAttachment(tag.AttachmentName); if (attachment == null) { return; } string src = formatter.GetAttachmentFileInfo(testStepRun.Step.Id, attachment).FullName; writer.Write("<div class=\"logStreamEmbed\">"); if (attachment.ContentType.StartsWith("image/")) { writer.Write("<a href=\""); writer.Write(src); writer.Write("\" class=\"attachmentLink\">"); writer.Write("<img class=\"embeddedImage\" src=\""); WriteHtmlEncoded(writer, src); writer.Write("\" alt=\"Attachment: "); WriteHtmlEncoded(writer, attachment.Name); writer.Write("\" /></a>"); } else if ((attachment.ContentType.StartsWith("text/html") || attachment.ContentType.StartsWith("text/xhtml")) && attachment.IsText) { writer.Write(attachment.GetText()); } else if (attachment.ContentType.StartsWith("text/") && attachment.IsText) { writer.Write("<pre>"); WriteHtmlEncodedWithBreaks(writer, attachment.GetText()); writer.Write("</pre>"); } else if (flashEnabled && attachment.ContentType.StartsWith(MimeTypes.FlashVideo)) { string placeholderId = "video-" + Hash64.CreateUniqueHash(); writer.Write("<div id=\""); writer.Write(placeholderId); writer.Write("\">"); writer.Write("<script type=\"text/javascript\">"); writer.Write("swfobject.embedSWF('"); WriteHtmlEncoded(writer, new Uri(Path.Combine(formatter.jsDir, "player.swf")).ToString()); writer.Write("', '"); writer.Write(placeholderId); writer.Write("', '400', '300', '9.0.98', '"); WriteHtmlEncoded(writer, new Uri(Path.Combine(formatter.jsDir, "expressInstall.swf")).ToString()); writer.Write("', {file: '"); WriteHtmlEncoded(writer, new Uri(src).ToString()); writer.Write("'}, {allowfullscreen: 'true', allowscriptaccess: 'always'}, {id: '"); writer.Write(placeholderId); writer.Write("'})"); writer.Write("</script>"); writer.Write("</div>"); } else { writer.Write("Attachment: <a href=\""); WriteHtmlEncoded(writer, src); writer.Write("\" class=\"attachmentLink\">"); WriteHtmlEncoded(writer, attachment.Name); writer.Write("</a>"); } writer.Write("</div>"); }