public void GivenAViolationCreatedFromAnInstruction()
        {
            var tc = TestHelper.FindTestCase<IntegerCalculatorLocationTest>(t => t.TestAdd());

            _violation = new Violation(new ViolationTest.SomeRule(), tc, 
                tc.TestMethod.Body.Instructions.First(i => i.OpCode != OpCodes.Nop && i.SequencePoint != null));
        }
Пример #2
0
        public void TestThatMessageCanBeCustomized()
        {
            var tc = TestHelper.FindTestCase<IntegerCalculatorTest>(t => t.TestAddBasic());
            var rule = new SomeRule();
            var violation = new Violation(rule, tc, "a message");

            Assert.AreEqual("a message", violation.Message);
        }
Пример #3
0
        public void TestThatCustomizedMessageOccursInToString()
        {
            var tc = TestHelper.FindTestCase<IntegerCalculatorTest>(t => t.TestAddBasic());
            var rule = new SomeRule();
            var violation = new Violation(rule, tc, "a message");

            StringAssert.EndsWith(": a message", violation.ToString());
        }
Пример #4
0
        public void ItShouldTakeSeverityFactorIntoAccount()
        {
            var tc = TestHelper.FindTestCase<IntegerCalculatorTest>(t => t.TestAddBasic());

            var violation = new Violation(Substitute.For<IRule>(), tc, severityFactor: 1.2m);
            var scorer = new ViolationScorer();

            Assert.AreEqual(1.2m, scorer.CalculateScore(violation));
        }
Пример #5
0
        public void TestThatAViolationHasADefaultSeverityFactorOfOne()
        {
            var tc = TestHelper.FindTestCase<IntegerCalculatorTest>(t => t.TestAddBasic());
            var rule = new SomeRule();

            var violation = new Violation(rule, tc);

            Assert.AreEqual(1m, violation.SeverityFactor);
        }
Пример #6
0
        public void TestThatAViolationCanHaveASeverityFactor()
        {
            var tc = TestHelper.FindTestCase<IntegerCalculatorTest>(t => t.TestAddBasic());
            var rule = new SomeRule();

            var violation = new Violation(rule, tc, severityFactor:1.2m);

            Assert.AreEqual(1.2m, violation.SeverityFactor);
        }
Пример #7
0
        public void TestThatToStringWithoutDebugSymbolsIncludesTypeAndMethod()
        {
            var tm = typeof(IntegerCalculatorTest).FindMethod("TestAddBasic()");
            var rule = new SomeRule();

            var violation = new Violation(rule, new TestCase(tm, null));

            const string expected = "TestNess.Target.IntegerCalculatorTest(TestAddBasic()): violation of \"some rule\"";
            Assert.AreEqual(expected, violation.ToString());
        }
Пример #8
0
 public ReportViolation(Violation violation)
 {
     Where = violation.DocumentUrl;
     Location = violation.Location;
     Message = violation.Message;
 }
 public void GivenAViolationCreatedFromAMethod()
 {
     var tc = TestHelper.FindTestCase<IntegerCalculatorLocationTest>(t => t.TestAdd());
     _violation = new Violation(new ViolationTest.SomeRule(), tc);
 }
Пример #10
0
        public void TestThatViolationExposesRule()
        {
            var tc = TestHelper.FindTestCase<IntegerCalculatorTest>(t => t.TestAddBasic());
            var rule = new SomeRule();

            var violation = new Violation(rule, tc);

            Assert.AreSame(rule, violation.Rule);
        }
Пример #11
0
        public void TestThatViolationExposesMessage()
        {
            var tc = TestHelper.FindTestCase<IntegerCalculatorTest>(x => x.TestAddBasic());
            var rule = new SomeRule();
            var violation = new Violation(rule, tc);

            Assert.AreEqual("violation of \"some rule\"", violation.Message);
        }
Пример #12
0
 public decimal CalculateScore(Violation v)
 {
     return v.SeverityFactor;
 }