public void TestThatAViolationCannotHaveASeverityFactorOfZero() { var tc = TestHelper.FindTestCase<IntegerCalculatorTest>(t => t.TestAddBasic()); var rule = new SomeRule(); Assert.Catch<ArgumentException>(() => new Violation(rule, tc, severityFactor: 0m)); }
public void SomeMatchCondition() { var rule = new SomeRule(JsonDocument.Parse("[1,2,3]").RootElement, new StrictEqualsRule(new VariableRule(""), 2)); JsonAssert.IsTrue(rule.Apply()); }
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 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 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); }