public void TestOverride(
            string message,
            string testString,
            List <IExtendedRuleException> expectedruleExceptionResult,
            List <IOverride> expectedOverrideResult)
        {
            var overrideResult = OverrideFinder.GetOverrideList(ParsingUtility.GenerateStreamFromString(testString));

            CollectionAssert.AreEqual(overrideResult, expectedOverrideResult, OverrideComparer, message);

            var ruleExceptionResult = RuleExceptionFinder.GetIgnoredRuleList(ParsingUtility.GenerateStreamFromString(testString));

            CollectionAssert.AreEqual(expectedruleExceptionResult, ruleExceptionResult, RuleExceptionComparer, message);
        }
Ejemplo n.º 2
0
        public void Test(string description, string sql, int expectedOverrideCount)
        {
            var fragmentBuilder = new FragmentBuilder(Constants.DefaultCompatabilityLevel);
            var overrideFider   = new OverrideFinder();

            var sqlStream = ParsingUtility.GenerateStreamFromString(sql);
            var overrides = overrideFider.GetOverrideList(sqlStream);

            var fragment = fragmentBuilder.GetFragment(new StreamReader(sqlStream), out var errors, overrides);

            Assert.AreEqual(expectedOverrideCount, overrides.Count());
            Assert.IsEmpty(errors);
            Assert.IsNotNull(fragment);
        }
Ejemplo n.º 3
0
        public void VisitRules(string sqlPath, IEnumerable <IRuleException> ignoredRules, Stream sqlFileStream)
        {
            var overrides     = overrideFinder.GetOverrideList(sqlFileStream);
            var overrideArray = overrides as IOverride[] ?? overrides.ToArray();

            var sqlFragment = fragmentBuilder.GetFragment(GetSqlTextReader(sqlFileStream), out var errors, overrideArray);

            // notify user of syntax errors
            var ruleExceptions = ignoredRules as IRuleException[] ?? ignoredRules.ToArray();

            if (errors.Any())
            {
                HandleParserErrors(sqlPath, errors, ruleExceptions);
            }

            // lint what can be linted, even if there are errors
            var ruleVisitors = ruleVisitorBuilder.BuildVisitors(sqlPath, ruleExceptions);

            foreach (var visitor in ruleVisitors)
            {
                VisitFragment(sqlFragment, visitor, overrideArray);
            }
        }
Ejemplo n.º 4
0
        public void TestOverride(string message, string testString, List <IOverride> expectedResult)
        {
            var overrides = testOverrideFinder.GetOverrideList(ParsingUtility.GenerateStreamFromString(testString));

            CollectionAssert.AreEqual(overrides, expectedResult, overrideComparer, message);
        }