Exemplo n.º 1
0
        public static FileInfo GetHtmlFormattedReport(string sessionId, bool condensed)
        {
            IDiskCacheGroup group     = GetReportCacheGroup(sessionId);
            string          directory = condensed ? "Condensed" : "Full";

            FileInfo htmlReportFile = group.GetFileInfo(Path.Combine(directory, HtmlReportFileName));

            if (!htmlReportFile.Exists)
            {
                Report report = LoadSerializedReport(sessionId);
                if (report == null)
                {
                    return(null);
                }

                group.CreateSubdirectory(directory);
                IReportManager            reportManager   = RuntimeAccessor.ServiceLocator.Resolve <IReportManager>();
                FileSystemReportContainer reportContainer = new FileSystemReportContainer(htmlReportFile.DirectoryName, ReportBaseName);
                IReportWriter             reportWriter    = reportManager.CreateReportWriter(report, reportContainer);
                var reportFormatterOptions = new ReportFormatterOptions();
                reportManager.Format(reportWriter, condensed ? "Html-Condensed" : "Html", reportFormatterOptions, NullProgressMonitor.CreateInstance());
            }

            return(htmlReportFile);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the report page size.
        /// </summary>
        /// <param name="options">The formatter options.</param>
        /// <returns>The report page size.</returns>
        protected int GetReportPageSize(ReportFormatterOptions options)
        {
            int    value;
            string field = options.Properties.GetValue(ReportPageSizeOption);

            return((field != null) && Int32.TryParse(field, out value) ? value : -1);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Parses the key/value array of property strings and build an option bag for the report formatter from them.
        /// </summary>
        /// <param name="properties">Key/value array of property strings</param>
        /// <returns>The report formatter options.</returns>
        protected static ReportFormatterOptions ParseOptions(string[] properties)
        {
            var options = new ReportFormatterOptions();

            foreach (string option in properties)
            {
                KeyValuePair <string, string> pair = StringUtils.ParseKeyValuePair(option);
                options.AddProperty(pair.Key, pair.Value);
            }

            return(options);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a launcher with default options and no test assemblies specified.
 /// </summary>
 public TestLauncher()
 {
     filePatterns            = new List <string>();
     testProject             = new TestProject();
     testRunnerOptions       = new TestRunnerOptions();
     testExplorationOptions  = new TestExplorationOptions();
     testExecutionOptions    = new TestExecutionOptions();
     reportFormats           = new List <string>();
     reportFormatterOptions  = new ReportFormatterOptions();
     progressMonitorProvider = NullProgressMonitorProvider.Instance;
     logger = NullLogger.Instance;
 }
Exemplo n.º 5
0
        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);
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Generates reports of the desired forms.
        /// </summary>
        /// <remarks>
        /// <para>
        /// This method adds the paths of the generated report documents to <see cref="ReportDocumentPaths" />.
        /// </para>
        /// </remarks>
        /// <param name="reportDirectory">The report directory.</param>
        /// <param name="reportName">The report name.</param>
        /// <param name="reportArchive">Determines whether to enclose the resulting test report in a compressed archive file.</param>
        /// <param name="reportFormats">The report formats to generate.</param>
        /// <param name="reportFormatOptions">The report formatter options.</param>
        /// <param name="reportManager">The report manager.</param>
        /// <param name="progressMonitor">A progress monitor for the operation.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="reportDirectory"/>,
        /// <paramref name="reportName"/>, <paramref name="reportFormats"/>, <paramref name="reportFormatOptions"/>,
        /// <paramref name="reportManager"/>, or <paramref name="progressMonitor"/> is null.</exception>
        public void GenerateReports(string reportDirectory, string reportName, ReportArchive reportArchive, IList <string> reportFormats,
                                    ReportFormatterOptions reportFormatOptions, IReportManager reportManager, IProgressMonitor progressMonitor)
        {
            if (reportDirectory == null)
            {
                throw new ArgumentNullException("reportDirectory");
            }
            if (reportName == null)
            {
                throw new ArgumentNullException("reportName");
            }
            if (reportFormats == null)
            {
                throw new ArgumentNullException("reportFormats");
            }
            if (reportFormatOptions == null)
            {
                throw new ArgumentNullException("reportFormatOptions");
            }
            if (reportManager == null)
            {
                throw new ArgumentNullException("reportManager");
            }
            if (progressMonitor == null)
            {
                throw new ArgumentNullException("progressMonitor");
            }

            var factory = new ReportContainerFactory(new FileSystem(), reportDirectory, reportName);

            using (progressMonitor.BeginTask("Generating reports.", reportFormats.Count))
                using (IReportContainer reportContainer = factory.MakeForSaving(reportArchive))
                {
                    IReportWriter reportWriter = reportManager.CreateReportWriter(report, reportContainer);

                    // Delete the report if it exists already.
                    reportContainer.DeleteReport();

                    // Format the report in all of the desired ways.
                    foreach (string reportFormat in reportFormats)
                    {
                        using (IProgressMonitor subProgressMonitor = progressMonitor.CreateSubProgressMonitor(1))
                            reportManager.Format(reportWriter, reportFormat, reportFormatOptions, subProgressMonitor);
                    }

                    // Save the full paths of the documents.
                    foreach (string reportDocumentPath in reportWriter.ReportDocumentPaths)
                    {
                        AddReportDocumentPath(Path.Combine(reportDirectory, reportDocumentPath));
                    }
                }
        }
Exemplo n.º 7
0
        public void FormatWritesTheReportWithTheDefaultAttachmentContentDispositionIfNoneSpecified()
        {
            IProgressMonitor progressMonitor = Mocks.Stub <IProgressMonitor>();
            IReportWriter    writer          = Mocks.StrictMock <IReportWriter>();

            using (Mocks.Record())
            {
                writer.SaveReport(AttachmentContentDisposition.Absent, progressMonitor);
            }

            using (Mocks.Playback())
            {
                XmlReportFormatter formatter = new XmlReportFormatter();
                var reportFormatterOptions   = new ReportFormatterOptions();

                formatter.Format(writer, reportFormatterOptions, progressMonitor);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Gets the attachment content disposition.
        /// </summary>
        /// <param name="options">The formatter options.</param>
        /// <returns>The attachment content disposition.</returns>
        protected AttachmentContentDisposition GetAttachmentContentDisposition(ReportFormatterOptions options)
        {
            string contentDisposition = options.Properties.GetValue(AttachmentContentDispositionOption);

            if (contentDisposition != null)
            {
                try
                {
                    return((AttachmentContentDisposition)Enum.Parse(typeof(AttachmentContentDisposition), contentDisposition, true));
                }
                catch (ArgumentException)
                {
                    // Ignore parse error.
                }
            }

            return(DefaultAttachmentContentDisposition);
        }
Exemplo n.º 9
0
        public string SaveReportAs(Report report, string fileName, string format, IProgressMonitor progressMonitor)
        {
            var file = string.Empty;

            using (progressMonitor.BeginTask("Generating report", 100))
            {
                var folderName      = Path.GetDirectoryName(fileName);
                var reportContainer = new FileSystemReportContainer(folderName,
                                                                    Path.GetFileNameWithoutExtension(fileName));
                var reportWriter = reportManager.CreateReportWriter(report, reportContainer);

                if (progressMonitor.IsCanceled)
                {
                    throw new OperationCanceledException();
                }

                // Delete the report if it already exists
                reportContainer.DeleteReport();

                if (progressMonitor.IsCanceled)
                {
                    throw new OperationCanceledException();
                }

                progressMonitor.Worked(10);

                // Format the report
                var reportFormatterOptions = new ReportFormatterOptions();
                using (var subProgressMonitor = progressMonitor.CreateSubProgressMonitor(90))
                    reportManager.Format(reportWriter, format, reportFormatterOptions, subProgressMonitor);

                if (progressMonitor.IsCanceled)
                {
                    throw new OperationCanceledException();
                }

                if (reportWriter.ReportDocumentPaths.Count > 0)
                {
                    file = Path.Combine(folderName, reportWriter.ReportDocumentPaths[0]);
                }
            }
            return(file);
        }
Exemplo n.º 10
0
        public void FormatWritesTheReportWithTheSpecifiedAttachmentContentDisposition()
        {
            IProgressMonitor progressMonitor = Mocks.Stub <IProgressMonitor>();
            IReportWriter    writer          = Mocks.StrictMock <IReportWriter>();

            using (Mocks.Record())
            {
                writer.SaveReport(AttachmentContentDisposition.Link, progressMonitor);
            }

            using (Mocks.Playback())
            {
                XmlReportFormatter     formatter = new XmlReportFormatter();
                ReportFormatterOptions options   = new ReportFormatterOptions();
                options.AddProperty(XmlReportFormatter.AttachmentContentDispositionOption, AttachmentContentDisposition.Link.ToString());

                formatter.Format(writer, options, progressMonitor);
            }
        }
Exemplo n.º 11
0
        /// <inheritdoc />
        public override void Format(IReportWriter reportWriter, ReportFormatterOptions formatterOptions, IProgressMonitor progressMonitor)
        {
            using (progressMonitor.BeginTask("Formatting report.", 10))
            {
                using (MultipartMimeReportContainer archiveContainer = new MultipartMimeReportContainer(reportWriter.ReportContainer))
                {
                    string archivePath = archiveContainer.ReportName + ".mht";
                    reportWriter.AddReportDocumentPath(archivePath);

                    archiveContainer.OpenArchive(archivePath);
                    progressMonitor.Worked(0.5);

                    DefaultReportWriter archiveWriter = new DefaultReportWriter(reportWriter.Report, archiveContainer);
                    using (IProgressMonitor subProgressMonitor = progressMonitor.CreateSubProgressMonitor(9))
                        htmlReportFormatter.Format(archiveWriter, formatterOptions, subProgressMonitor);

                    archiveContainer.CloseArchive();
                    progressMonitor.Worked(0.5);
                }
            }
        }
Exemplo n.º 12
0
        /// <inheritdoc />
        public override void Format(IReportWriter reportWriter, ReportFormatterOptions options, IProgressMonitor progressMonitor)
        {
            AttachmentContentDisposition attachmentContentDisposition = GetAttachmentContentDisposition(options);

            using (progressMonitor.BeginTask("Formatting report.", 10))
            {
                progressMonitor.SetStatus("Applying template.");
                ApplyTemplate(reportWriter, attachmentContentDisposition, options);
                progressMonitor.Worked(3);

                progressMonitor.SetStatus("Copying resources.");
                CopyResources(reportWriter);
                progressMonitor.Worked(2);

                progressMonitor.SetStatus(@"");

                if (attachmentContentDisposition == AttachmentContentDisposition.Link)
                {
                    using (IProgressMonitor subProgressMonitor = progressMonitor.CreateSubProgressMonitor(5))
                        reportWriter.SaveReportAttachments(subProgressMonitor);
                }
            }
        }
Exemplo n.º 13
0
        public void FormatWritesTheArchivedReport()
        {
            IReportWriter    reportWriter        = Mocks.StrictMock <IReportWriter>();
            IReportContainer reportContainer     = Mocks.StrictMock <IReportContainer>();
            IReportFormatter htmlReportFormatter = Mocks.StrictMock <IReportFormatter>();
            IProgressMonitor progressMonitor     = NullProgressMonitor.CreateInstance();
            var reportFormatterOptions           = new ReportFormatterOptions();

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

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

                    Expect.Call(reportContainer.EncodeFileName(null))
                    .Repeat.Any()
                    .IgnoreArguments()
                    .Do((Gallio.Common.GallioFunc <string, string>) delegate(string value) { return(value); });

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

                    Expect.Call(delegate { htmlReportFormatter.Format(null, null, null); })
                    .Constraints(Is.NotNull(), Is.Same(reportFormatterOptions), Is.NotNull())
                    .Do((FormatDelegate) delegate(IReportWriter innerReportWriter, ReportFormatterOptions innerFormatterOptions, IProgressMonitor innerProgressMonitor)
                    {
                        using (StreamWriter contentWriter = new StreamWriter(innerReportWriter.ReportContainer.OpenWrite("Foo.html", MimeTypes.Html, Encoding.UTF8)))
                            contentWriter.Write("<html><body>Some HTML</body></html>");

                        using (StreamWriter contentWriter = new StreamWriter(innerReportWriter.ReportContainer.OpenWrite(
                                                                                 innerReportWriter.ReportContainer.EncodeFileName("Foo\\Attachment 1%.txt"), MimeTypes.PlainText, Encoding.UTF8)))
                            contentWriter.Write("An attachment.");

                        using (StreamWriter contentWriter = new StreamWriter(innerReportWriter.ReportContainer.OpenWrite("Foo.css", null, null)))
                            contentWriter.Write("#Some CSS.");
                    });
                }

                using (Mocks.Playback())
                {
                    MHtmlReportFormatter formatter = new MHtmlReportFormatter(htmlReportFormatter);

                    formatter.Format(reportWriter, reportFormatterOptions, progressMonitor);

                    string reportContents = File.ReadAllText(reportPath);
                    TestLog.AttachPlainText("MHTML Report", reportContents);

                    Assert.Contains(reportContents, "MIME-Version: 1.0");
                    Assert.Contains(reportContents, "Content-Type: multipart/related; type=\"text/html\"; boundary=");
                    Assert.Contains(reportContents, "This is a multi-part message in MIME format.");

                    Assert.Contains(reportContents, "text/html");
                    Assert.Contains(reportContents, "Content-Location: file:///Foo.html");
                    Assert.Contains(reportContents, Convert.ToBase64String(Encoding.UTF8.GetBytes("<html><body>Some HTML</body></html>"), Base64FormattingOptions.InsertLineBreaks));

                    Assert.Contains(reportContents, "text/plain");
                    Assert.Contains(reportContents, "Content-Location: file:///Foo/Attachment_1%25.txt");
                    Assert.Contains(reportContents, Convert.ToBase64String(Encoding.UTF8.GetBytes("An attachment."), Base64FormattingOptions.InsertLineBreaks));

                    Assert.Contains(reportContents, "text/css");
                    Assert.Contains(reportContents, "Content-Location: file:///Foo.css");
                    Assert.Contains(reportContents, Convert.ToBase64String(Encoding.UTF8.GetBytes("#Some CSS."), Base64FormattingOptions.InsertLineBreaks));

                    File.Delete(reportPath);
                }
            }
        }
Exemplo n.º 14
0
 /// <inheritdoc />
 public abstract void Format(IReportWriter reportWriter, ReportFormatterOptions formatterOptions, IProgressMonitor progressMonitor);
Exemplo n.º 15
0
        /// <inheritdoc />
        public override void Format(IReportWriter reportWriter, ReportFormatterOptions options, IProgressMonitor progressMonitor)
        {
            AttachmentContentDisposition attachmentContentDisposition = GetAttachmentContentDisposition(options);

            reportWriter.SaveReport(attachmentContentDisposition, progressMonitor);
        }
Exemplo n.º 16
0
        private VtlReportWriter GetReportWriter(VelocityEngine velocityEngine, VelocityContext velocityContext, IReportWriter reportWriter, FormatHelper helper, ReportFormatterOptions options)
        {
            int pageSize  = GetReportPageSize(options);
            int testCount = (reportWriter.Report.TestPackageRun == null) ? 0 : reportWriter.Report.TestPackageRun.Statistics.TestCount;

            if (pageSize < 0)
            {
                HtmlReportSplitSettings settings = preferenceManager.HtmlReportSplitSettings;
                pageSize = settings.Enabled ? settings.PageSize : 0;
            }

            if (supportSplit && pageSize > 0 && testCount > pageSize)
            {
                return(new MultipleFilesVtlReportWriter(velocityEngine, velocityContext, reportWriter, templatePath, contentType, extension, helper, pageSize));
            }

            return(new SingleFileVtlReportWriter(velocityEngine, velocityContext, reportWriter, templatePath, contentType, extension, helper));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Applies the template to produce a report.
        /// </summary>
        protected virtual void ApplyTemplate(IReportWriter reportWriter, AttachmentContentDisposition attachmentContentDisposition, ReportFormatterOptions options)
        {
            VelocityEngine  velocityEngine  = VelocityEngineFactory.CreateVelocityEngine();
            var             helper          = new FormatHelper();
            VelocityContext velocityContext = VelocityEngineFactory.CreateVelocityContext(reportWriter, helper);
            var             writer          = GetReportWriter(velocityEngine, velocityContext, reportWriter, helper, options);

            reportWriter.WithUpdatedContentPathsAndDisposition(attachmentContentDisposition, writer.Run);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Saves the specified report.
        /// </summary>
        /// <param name="report"></param>
        /// <param name="reportArchive"></param>
        /// <param name="formatterName"></param>
        /// <param name="outputPath"></param>
        /// <param name="getOutputName"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        protected bool SaveReport(Report report, ReportArchive reportArchive, string formatterName, string outputPath, Func <string> getOutputName, ReportFormatterOptions options)
        {
            return(CaptureFileException(() => "The specified output directory is not a valid file path.", () =>
            {
                var factory = new ReportContainerFactory(new FileSystem(), outputPath, getOutputName());

                using (IReportContainer outputContainer = factory.MakeForSaving(reportArchive))
                {
                    IReportWriter reportWriter = reportManager.CreateReportWriter(report, outputContainer);
                    Context.ProgressMonitorProvider.Run(pm => reportManager.Format(reportWriter, formatterName, options, pm));
                    return true;
                }
            }));
        }
Exemplo n.º 19
0
        private FacadeTestRunState Run(IFacadeTestListener testListener, string assemblyPath, Filter <ITestDescriptor> filter, FacadeOptions facadeOptions)
        {
            if (testListener == null)
            {
                throw new ArgumentNullException(@"testListener");
            }
            if (assemblyPath == null)
            {
                throw new ArgumentNullException("assemblyPath");
            }
            if (facadeOptions == null)
            {
                throw new ArgumentNullException("facadeOptions");
            }

            ILogger logger = new FilteredLogger(new TDNetLogger(testListener), LogSeverity.Info);

            try
            {
                RuntimeAccessor.Instance.AddLogListener(logger);
                var filterRules = new List <FilterRule <ITestDescriptor> >();

                switch (facadeOptions.FilterCategoryMode)
                {
                case FacadeFilterCategoryMode.Disabled:
                    filterRules.Add(new FilterRule <ITestDescriptor>(FilterRuleType.Inclusion, filter));
                    break;

                case FacadeFilterCategoryMode.Include:
                    filterRules.Add(new FilterRule <ITestDescriptor>(FilterRuleType.Inclusion,
                                                                     new AndFilter <ITestDescriptor>(new[] { filter, ToCategoryFilter(facadeOptions.FilterCategoryNames) })));
                    break;

                case FacadeFilterCategoryMode.Exclude:
                    filterRules.Add(new FilterRule <ITestDescriptor>(FilterRuleType.Exclusion, ToCategoryFilter(facadeOptions.FilterCategoryNames)));
                    filterRules.Add(new FilterRule <ITestDescriptor>(FilterRuleType.Inclusion, filter));
                    break;
                }

                var filterSet = new FilterSet <ITestDescriptor>(filterRules);
                launcher.Logger = logger;
                launcher.ProgressMonitorProvider           = new LogProgressMonitorProvider(logger);
                launcher.TestExecutionOptions.FilterSet    = filterSet;
                launcher.TestProject.TestRunnerFactoryName = StandardTestRunnerFactoryNames.IsolatedAppDomain;
                launcher.TestProject.AddTestRunnerExtension(new TDNetExtension(testListener)); // This monitor will inform the user in real-time what's going on
                launcher.TestProject.TestPackage.AddFile(new FileInfo(assemblyPath));
                string assemblyDirectory = Path.GetDirectoryName(assemblyPath);
                launcher.TestProject.TestPackage.ApplicationBaseDirectory = new DirectoryInfo(assemblyDirectory);
                launcher.TestProject.TestPackage.WorkingDirectory         = new DirectoryInfo(assemblyDirectory);
                TestLauncherResult result          = RunLauncher(launcher);
                string             reportDirectory = GetReportDirectory(logger);

                if (reportDirectory != null)
                {
                    var reportFormatterOptions = new ReportFormatterOptions();
                    var preferenceManager      = (TDNetPreferenceManager)RuntimeAccessor.ServiceLocator.ResolveByComponentId("TDNetRunner.PreferenceManager");
                    var reportFormat           = preferenceManager.ReportSettings.DetermineReportFormat(result.Report);
                    result.GenerateReports(reportDirectory, Path.GetFileName(assemblyPath), ReportArchive.Normal,
                                           new[] { reportFormat }, reportFormatterOptions,
                                           RuntimeAccessor.ServiceLocator.Resolve <IReportManager>(), NullProgressMonitor.CreateInstance());

                    // This will generate a link to the generated report
                    if (result.ReportDocumentPaths.Count != 0)
                    {
                        Uri    rawUrl     = new Uri(result.ReportDocumentPaths[0]);
                        string displayUrl = "file:///" + rawUrl.LocalPath.Replace(" ", "%20").Replace(@"\", "/");

                        // TDNet just prints the link on its own but it's not always clear to users what it represents.
                        // testListener.TestResultsUrl(displayUrl);
                        testListener.WriteLine("\nTest Report: " + displayUrl, FacadeCategory.Info);
                    }
                }

                // Inform no tests run, if necessary.
                if (result.ResultCode == ResultCode.NoTests)
                {
                    InformNoTestsWereRun(testListener, Resources.MbUnitTestRunner_NoTestsFound);
                }
                else if (result.Statistics.TestCount == 0)
                {
                    InformNoTestsWereRun(testListener, null);
                }

                return(GetTestRunState(result));
            }
            finally
            {
                RuntimeAccessor.Instance.RemoveLogListener(logger);
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// Populates the arguments for the XSL template processing.
 /// </summary>
 protected virtual void PopulateArguments(XsltArgumentList arguments, ReportFormatterOptions options, string reportName)
 {
     arguments.AddParam(@"resourceRoot", @"", reportName);
 }
Exemplo n.º 21
0
        /// <summary>
        /// Applies the transform to produce a report.
        /// </summary>
        protected virtual void ApplyTransform(IReportWriter reportWriter, AttachmentContentDisposition attachmentContentDisposition, ReportFormatterOptions options)
        {
            XsltArgumentList arguments = new XsltArgumentList();

            PopulateArguments(arguments, options, reportWriter.ReportContainer.ReportName);

            XPathDocument document = SerializeReportToXPathDocument(reportWriter, attachmentContentDisposition);

            string reportPath = reportWriter.ReportContainer.ReportName + @"." + extension;

            Encoding             encoding  = new UTF8Encoding(false);
            XslCompiledTransform transform = Transform;
            XmlWriterSettings    settings  = transform.OutputSettings.Clone();

            settings.CheckCharacters = false;
            settings.Encoding        = encoding;
            settings.CloseOutput     = true;
            using (XmlWriter writer = XmlWriter.Create(reportWriter.ReportContainer.OpenWrite(reportPath, contentType, encoding), settings))
                transform.Transform(document, arguments, writer);

            reportWriter.AddReportDocumentPath(reportPath);
        }