Exemple #1
0
        public void TestThatAViolationCannotHaveASeverityFactorOfZero()
        {
            var tc = TestHelper.FindTestCase<IntegerCalculatorTest>(t => t.TestAddBasic());
            var rule = new SomeRule();

            Assert.Catch<ArgumentException>(() => new Violation(rule, tc, severityFactor: 0m));
        }
Exemple #2
0
        public void SomeMatchCondition()
        {
            var rule = new SomeRule(JsonDocument.Parse("[1,2,3]").RootElement,
                                    new StrictEqualsRule(new VariableRule(""), 2));

            JsonAssert.IsTrue(rule.Apply());
        }
Exemple #3
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);
        }
Exemple #4
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());
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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());
        }
Exemple #8
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);
        }
Exemple #9
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);
        }