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);
 }
Beispiel #2
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());
 }
        public void GivenAReportBasedOnAnalysisOfOneTestCase()
        {
            var tc1 = TestHelper.FindTestCase<IntegerCalculatorTest>(x => x.TestAddTwoAsserts());
            var rule = new LimitAssertsPerTestCaseRule();
            var scorer = Substitute.For<IViolationScorer>();
            scorer.CalculateScore(null).ReturnsForAnyArgs(1m);

            var results = AnalysisResults.Create(new[] { tc1 }, new[] { rule }, scorer);
            var report = new XUnitHtmlReporter();
            _receiver = Substitute.For<IReportReceiver>();
            report.GenerateReport(_receiver, results);
        }
        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());
        }
        public void GivenAReportBasedOnAnalysisOfTwoTestCases()
        {
            var tc1 = TestHelper.FindTestCase<IntegerCalculatorTest>(x => x.TestAddTwoAsserts());
            var tc2 = TestHelper.FindTestCase<IntegerCalculatorTest>(x => x.TestAddBasic());
            var rule = new LimitAssertsPerTestCaseRule();
            var scorer = Substitute.For<IViolationScorer>();
            scorer.CalculateScore(null).ReturnsForAnyArgs(1m);

            var results = AnalysisResults.Create(new[] { tc1, tc2 }, new[] { rule }, scorer);
            var report = new AngularJsReporter();
            _receiver = Substitute.For<IReportReceiver>();
            _receiver.WhenForAnyArgs(r => r.GenerateReport("")).Do(ci => _text = ci.Arg<string>());
            report.GenerateReport(_receiver, results);

            _cq = new CQ(_text);
        }
        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());
        }