Exemplo n.º 1
0
 public void GenerateReport(IReportReceiver recv, AnalysisResults results)
 {
     var text = Resources.angular_report;
     var json = JsonConvert.SerializeObject(new Report(results));
     text = text.Replace("@@ANALYSIS_RESULTS@@", json);
     recv.GenerateReport(text);
 }
 public void TestThatEmptyAnalysisResultsIsHandled()
 {
     var results = new AnalysisResults(new TestCaseRuleApplication[0], new TestCase[0]);
     var reporter = new XUnitReporter();
     var receiver = Substitute.For<IReportReceiver>();
     Assert.Throws<ArgumentException>(() => reporter.GenerateReport(receiver, results));
 }
Exemplo n.º 3
0
 private void PrintViolationsToConsole(AnalysisResults results)
 {
     foreach (var v in results.Applications.SelectMany(a => a.Violations))
     {
         Console.WriteLine(v);
     }
 }
Exemplo n.º 4
0
 public void GivenAnalysisResults()
 {
     var rule = new DelayRule();
     var testCase = TestHelper.FindTestCase<IntegerCalculatorTest>(t => t.TestAddTwoAsserts());
     var app = new TestCaseRuleApplication(testCase, rule, new ViolationScorer());
     _results = new AnalysisResults(Enumerable.Repeat(app, 1), new[] { testCase });
 }
Exemplo n.º 5
0
 public override XDocument GenerateXml(AnalysisResults results)
 {
     var gen = new XUnitXmlGenerator(results);
     var tree = BuildTree(results);
     gen.Traverse(tree);
     var elem = gen.GetRootElement();
     return new XDocument(new XDeclaration("1.0", "utf-8", "yes"), elem);
 }
Exemplo n.º 6
0
 public void GenerateReport(IReportReceiver receiver, AnalysisResults results)
 {
     var writer = new StringWriter();
     var xml = GenerateXml(results);
     var xwriter = XmlWriter.Create(writer);
     xml.WriteTo(xwriter);
     xwriter.Flush();
     receiver.GenerateReport(writer.ToString());
 }
Exemplo n.º 7
0
        public void GenerateReport(IReportReceiver recv, AnalysisResults results)
        {
            var xmlReporter = new XUnitReporter();
            var xml = xmlReporter.GenerateXml(results);

            var transform = new XslCompiledTransform();
            transform.Load(new XmlTextReader(new StringReader(Properties.Resources.XUnitHtml_xslt)));

            var writer = new StringWriter();
            var xwriter = XmlWriter.Create(writer);
            transform.Transform(xml.CreateNavigator(), null, xwriter);
            xwriter.Flush();
            recv.GenerateReport(writer.ToString());
        }
Exemplo n.º 8
0
 internal Report(AnalysisResults results)
 {
     TotalTimeMs = 0;
     TotalScore = 0m;
     Applications = new List<ReportApplication>();
     TestCase tc = null;
     foreach (var a in results.Applications)
     {
         Applications.Add(new ReportApplication(a));
         TotalScore += a.Score;
         TotalTimeMs += a.ElapsedTimeInMilliseconds;
         if (tc == null)
         {
             tc = a.TestCase;
         }
     }
     Target = tc != null ? tc.Origin.Assembly.Name.Name : "Unknown";
     When = results.AnalysisTime;
 }
Exemplo n.º 9
0
        public void GenerateReport(IReportReceiver recv, AnalysisResults results)
        {
            var writer = new StringWriter();
            writer.WriteLine("Analysis started at " + results.AnalysisTime);
            writer.WriteLine("Number of test cases analyzed = " + results.TestCaseCount);
            writer.WriteLine("Total analysis time (ms) = " + results.ElapsedTimeInMilliseconds);
            writer.WriteLine("Violations:");
            var score = 0m;
            foreach (var app in results.Applications)
            {
                score += app.Score;
                foreach (var violation in app.Violations)
                {
                    writer.WriteLine("  {0}", violation);
                }
            }

            writer.WriteLine();
            writer.WriteLine("Total score = " + score);
            recv.GenerateReport(writer.ToString());
        }
Exemplo n.º 10
0
 private Graph<XUnitNode> BuildTree(AnalysisResults results)
 {
     var leafNodes = results.Applications.Select(app => new TestCaseNode { Application = app }).ToList();
     if (leafNodes.Count == 0)
     {
         throw new ArgumentException("No analysis results available - cannot generate XUnit report!");
     }
     var ass = leafNodes.First().Application.TestCase.TestMethod.DeclaringType.Module.Assembly;
     return TreeBuilder<XUnitNode>.Create()
         .Group<TestCaseNode>()
         .As(tcn => new TypeNode {Type = tcn.Application.TestCase.TestMethod.DeclaringType})
         .Group<TypeNode>()
         .As(tyn => new NamespaceNode {Namespace = tyn.Type.Namespace})
         .Group<NamespaceNode>()
         .When(nn => nn.Namespace.Contains("."))
         .As(nn => new NamespaceNode {Namespace = nn.ParentNamespace()})
         .Group<NamespaceNode>()
         .When(nn => !nn.Namespace.Contains("."))
         .As(nn => new AssemblyNode {Assembly = ass})
         .Build(leafNodes);
 }
Exemplo n.º 11
0
 public XUnitXmlGenerator(AnalysisResults results)
 {
     _ar = results;
 }
Exemplo n.º 12
0
 public abstract XDocument GenerateXml(AnalysisResults results);