Esempio n. 1
0
        /// <summary>
        /// Adds the coverage information of a single line of a file to the report.
        /// </summary>
        /// <param name="analysis">The line analysis.</param>
        public void LineAnalysis(LineAnalysis analysis)
        {
            if (analysis == null)
            {
                throw new ArgumentNullException("analysis");
            }

            this.reportTextWriter.WriteStartElement("LineAnalysis");
            this.reportTextWriter.WriteAttributeString("line", analysis.LineNumber.ToString(CultureInfo.InvariantCulture));
            this.reportTextWriter.WriteAttributeString("visits", analysis.LineVisits.ToString(CultureInfo.InvariantCulture));
            this.reportTextWriter.WriteAttributeString("coverage", analysis.LineVisitStatus.ToString());
            this.reportTextWriter.WriteAttributeString("content", XmlRenderer.ReplaceInvalidXmlChars(analysis.LineContent));
            this.reportTextWriter.WriteEndElement();
        }
Esempio n. 2
0
        /// <summary>
        /// Adds the coverage information of a single line of a file to the report.
        /// </summary>
        /// <param name="fileIndex">The index of the file.</param>
        /// <param name="analysis">The line analysis.</param>
        public void LineAnalysis(int fileIndex, LineAnalysis analysis)
        {
            if (analysis == null)
            {
                throw new ArgumentNullException(nameof(analysis));
            }

            string formattedLine = analysis.LineContent
                                   .Replace(((char)11).ToString(), "  ") // replace tab
                                   .Replace(((char)9).ToString(), "  ")  // replace tab
                                   .Replace("~", " ");                   // replace '~' since this used for the \verb command

            formattedLine = ShortenString(formattedLine);
            formattedLine = XmlRenderer.ReplaceInvalidXmlChars(formattedLine);

            string lineVisitStatus;

            switch (analysis.LineVisitStatus)
            {
            case LineVisitStatus.Covered:
                lineVisitStatus = "green";
                break;

            case LineVisitStatus.NotCovered:
                lineVisitStatus = "red";
                break;

            case LineVisitStatus.PartiallyCovered:
                lineVisitStatus = "orange";
                break;

            default:
                lineVisitStatus = "gray";
                break;
            }

            string row = string.Format(
                CultureInfo.InvariantCulture,
                @"\cellcolor{{{0}}} & {1} & \verb~{2}~ & & \verb~{3}~\\",
                lineVisitStatus,
                analysis.LineVisitStatus != LineVisitStatus.NotCoverable ? analysis.LineVisits.ToString(CultureInfo.InvariantCulture) : string.Empty,
                analysis.LineNumber,
                formattedLine);

            this.reportTextWriter.WriteLine(row);
        }
Esempio n. 3
0
        /// <summary>
        /// Adds the coverage information of a single line of a file to the report.
        /// </summary>
        /// <param name="fileIndex">The index of the file.</param>
        /// <param name="analysis">The line analysis.</param>
        public void LineAnalysis(int fileIndex, LineAnalysis analysis)
        {
            if (analysis == null)
            {
                throw new ArgumentNullException(nameof(analysis));
            }

            this.reportTextWriter.WriteStartElement("LineAnalysis");
            this.reportTextWriter.WriteAttributeString("line", analysis.LineNumber.ToString(CultureInfo.InvariantCulture));
            this.reportTextWriter.WriteAttributeString("visits", analysis.LineVisits.ToString(CultureInfo.InvariantCulture));
            this.reportTextWriter.WriteAttributeString("coverage", analysis.LineVisitStatus.ToString());
            this.reportTextWriter.WriteAttributeString("coveredbranches", analysis.CoveredBranches.HasValue ? analysis.CoveredBranches.Value.ToString(CultureInfo.InvariantCulture) : string.Empty);
            this.reportTextWriter.WriteAttributeString("totalbranches", analysis.TotalBranches.HasValue ? analysis.TotalBranches.Value.ToString(CultureInfo.InvariantCulture) : string.Empty);

            this.reportTextWriter.WriteAttributeString("content", XmlRenderer.ReplaceInvalidXmlChars(analysis.LineContent));
            this.reportTextWriter.WriteEndElement();
        }
Esempio n. 4
0
        /// <summary>
        /// Adds the given metric values to the report.
        /// </summary>
        /// <param name="metric">The metric.</param>
        public void MetricsRow(MethodMetric metric)
        {
            if (metric == null)
            {
                throw new ArgumentNullException("metric");
            }

            this.reportTextWriter.WriteStartElement(XmlRenderer.ReplaceInvalidXmlChars(metric.ShortName));

            foreach (var m in metric.Metrics)
            {
                this.reportTextWriter.WriteStartElement(XmlRenderer.ReplaceInvalidXmlChars(m.Name));
                this.reportTextWriter.WriteValue(m.Value.ToString(CultureInfo.InvariantCulture));
                this.reportTextWriter.WriteEndElement();
            }

            this.reportTextWriter.WriteEndElement();
        }
Esempio n. 5
0
        /// <summary>
        /// Adds a table row with two cells to the report.
        /// </summary>
        /// <param name="key">The text of the first column.</param>
        /// <param name="files">The files.</param>
        public void KeyValueRow(string key, IEnumerable <string> files)
        {
            if (files == null)
            {
                throw new ArgumentNullException("files");
            }

            this.reportTextWriter.WriteStartElement(XmlRenderer.ReplaceInvalidXmlChars(key));

            foreach (var file in files)
            {
                this.reportTextWriter.WriteStartElement("File");
                this.reportTextWriter.WriteValue(file);
                this.reportTextWriter.WriteEndElement();
            }

            this.reportTextWriter.WriteEndElement();
        }
Esempio n. 6
0
 /// <summary>
 /// Adds a header to the report.
 /// </summary>
 /// <param name="text">The text.</param>
 public void Header(string text)
 {
     this.reportTextWriter.WriteStartElement(XmlRenderer.ReplaceInvalidXmlChars(text));
 }
Esempio n. 7
0
 /// <summary>
 /// Adds a table row with two cells to the report.
 /// </summary>
 /// <param name="key">The text of the first column.</param>
 /// <param name="value">The text of the second column.</param>
 public void KeyValueRow(string key, string value)
 {
     this.reportTextWriter.WriteStartElement(XmlRenderer.ReplaceInvalidXmlChars(key));
     this.reportTextWriter.WriteValue(value);
     this.reportTextWriter.WriteEndElement();
 }