Esempio n. 1
0
        private List<string> GetMethodHtmlParts(ComparedClass comparedClass, string methodTemplate)
        {
            var methodHtmlParts = new List<string>();
            foreach (var comparedMethod in comparedClass.ComparedMethods)
            {
                var lineNumbersHtml = new StringBuilder();
                var codeLinesHtml = new StringBuilder();
                foreach (var comparedLine in comparedMethod.ComparedLines)
                {
                    var spanModifer = "";
                    if (comparedLine.State == LineState.Covered)
                        spanModifer = " class=\"covered\"";
                    else if (comparedLine.State == LineState.Uncovered)
                        spanModifer = " class=\"uncovered\"";

                    codeLinesHtml.AppendLine(string.Format
                                                 (@"<span{0}>{1}</span>", spanModifer, comparedLine.
                                                 LineNumber));
                    lineNumbersHtml.AppendLine(string.Format(
                                                   @"<span{0}>{1}</span>", spanModifer, comparedLine.CurrentLine.
                                                   Code));
                }
                methodHtmlParts.Add(methodTemplate
                    .Replace("$LINE_NUMBERS$", lineNumbersHtml.ToString())
                    .Replace("$CODE_LINES$", codeLinesHtml.ToString()));
            }
            return methodHtmlParts;
        }
Esempio n. 2
0
        public ComparedMethod(ComparedClass parentClass, CoverageMethod currentMethod, CoverageMethod prevMethod)
        {
            ParentClass = parentClass;
            CurrentMethod = currentMethod;
            PrevMethod = prevMethod;

            if (PrevMethod != null)
                ComparedLines = from m in CurrentMethod.Lines
                                  select new ComparedLine(this, m, PrevMethod[m.LineNumber]);
        }