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)); }
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); }
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()); }
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)); }
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); }
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); }
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()); }
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); }
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); }
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); }
public decimal CalculateScore(Violation v) { return v.SeverityFactor; }