Пример #1
0
        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 XUnitReporter();
            _doc = report.GenerateXml(results);
        }
        public void TestThatMultipleViolationsPerTestCaseArePointedOut()
        {
            var tc1 = TestHelper.FindTestCase<IntegerCalculatorExpectationTest>(x => x.TestAddWithConditionalExpectationViolations());
            var rule = new LocalExpectationRule();
            var scorer = Substitute.For<IViolationScorer>();
            scorer.CalculateScore(null).ReturnsForAnyArgs(1m);

            var results = AnalysisResults.Create(new[] { tc1 }, new[] { rule }, scorer);
            var report = new XUnitReporter();
            var doc = report.GenerateXml(results);

            var message = doc.XPathSelectElement("//message").Value;
            StringAssert.Contains("2 violations", message);
        }
Пример #3
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());
        }
        public void TestThatTestCasesInTwoClassesResultsInXmlWithTwoClassElements()
        {
            var tc1 = TestHelper.FindTestCase<IntegerCalculatorTest>(x => x.TestAddTwoAsserts());
            var tc2 = TestHelper.FindTestCase<IntegerCalculatorConditionalTest>(x => x.TestAddWithIf());
            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 XUnitReporter();
            var doc = report.GenerateXml(results);

            var raw = Convert.ToInt32(doc.XPathEvaluate("count(/assembly/class)"));
            Assert.AreEqual(2, raw);
        }