public void GivenAnApplicationOfARuleToAnInappropriateTestCase()
        {
            var tc = TestHelper.FindTestCase<IntegerCalculatorTest>(t => t.TestAddTwoAsserts());
            var rule = new LimitAssertsPerTestCaseRule();
            var scorer = Substitute.For<IViolationScorer>();
            scorer.CalculateScore(Arg.Any<Violation>()).Returns(1);

            _app = new TestCaseRuleApplication(tc, rule, scorer);
        }
Example #2
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 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 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);
        }
        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);
        }