public void TheDefaultAttachmentContentDispositionCanBeChanged()
        {
            XsltReportFormatter formatter = new XsltReportFormatter("ext", MimeTypes.PlainText, new DirectoryInfo("content"), "xslt", new string[] { "res1", "res2" });

            formatter.DefaultAttachmentContentDisposition = AttachmentContentDisposition.Inline;
            Assert.AreEqual(AttachmentContentDisposition.Inline, formatter.DefaultAttachmentContentDisposition);
        }
        public void FormatWritesTheTransformedReport()
        {
            string resourcePath = Path.Combine(Path.GetDirectoryName(AssemblyUtils.GetAssemblyLocalPath(GetType().Assembly)), @"..\Reports");

            IReportWriter    reportWriter    = Mocks.StrictMock <IReportWriter>();
            IReportContainer reportContainer = Mocks.StrictMock <IReportContainer>();
            IProgressMonitor progressMonitor = NullProgressMonitor.CreateInstance();

            string reportPath = SpecialPathPolicy.For <XsltReportFormatter>().CreateTempFileWithUniqueName().FullName;

            using (Stream tempFileStream = File.OpenWrite(reportPath))
            {
                using (Mocks.Record())
                {
                    SetupResult.For(reportWriter.ReportContainer).Return(reportContainer);

                    reportWriter.SerializeReport(null, AttachmentContentDisposition.Link);
                    LastCall.Constraints(Is.NotNull(), Is.Equal(AttachmentContentDisposition.Link))
                    .Do((SerializeReportDelegate) delegate(XmlWriter writer, AttachmentContentDisposition contentDisposition)
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.InnerXml    = "<report>The report.</report>";
                        doc.Save(writer);
                    });

                    SetupResult.For(reportContainer.ReportName).Return("Foo");
                    Expect.Call(reportContainer.OpenWrite("Foo.ext", MimeTypes.PlainText, new UTF8Encoding(false)))
                    .Return(tempFileStream);
                    reportWriter.AddReportDocumentPath("Foo.ext");

                    Expect.Call(reportContainer.OpenWrite(@"Foo\MbUnitLogo.png", MimeTypes.Png, null)).Return(new MemoryStream());

                    reportWriter.SaveReportAttachments(null);
                    LastCall.Constraints(Is.NotNull());
                }

                using (Mocks.Playback())
                {
                    XsltReportFormatter formatter = new XsltReportFormatter("ext", MimeTypes.PlainText, new DirectoryInfo(resourcePath), "Diagnostic.xslt", new string[] { "MbUnitLogo.png" });
                    var reportFormatterOptions    = new ReportFormatterOptions();
                    reportFormatterOptions.AddProperty(XsltReportFormatter.AttachmentContentDispositionOption, AttachmentContentDisposition.Link.ToString());

                    formatter.Format(reportWriter, reportFormatterOptions, progressMonitor);

                    string reportContents = File.ReadAllText(reportPath);
                    TestLog.EmbedXml("Diagnostic report contents", reportContents);
                    Assert.Contains(reportContents, "<resourceRoot>Foo</resourceRoot>");
                    Assert.Contains(reportContents, "The report.");

                    File.Delete(reportPath);
                }
            }
        }