public void ApplyActiveRules_Returns_Expected_Problem()
        {
            IDescribeSql sql = MockRepository.GenerateMock <IDescribeSql>();

            _catalog.AddAssembly(GetType().Assembly.GetName().Name);
            StubbedRule rule = _catalog.Rules.First() as StubbedRule;
            IEnumerable <IDescribeSqlProblem> problems;

            problems = _catalog.ApplyActiveRules(sql);
            Assert.That(problems.Count(), Is.EqualTo(1));
            Assert.That(problems.First(), Is.EqualTo(rule.Problem));
        }
 public IEnumerable<IDescribeSqlProblem> ApplyActiveRules(IDescribeSql sql)
 {
     if(sql == null)
     {
         return Enumerable.Empty<IDescribeSqlProblem>();
     }
     List<IDescribeSqlProblem> results;
     results = new List<IDescribeSqlProblem>();
     foreach(IJudgeSql rule in ActiveRules)
     {
         IEnumerable<IDescribeSqlProblem> ruleResults;
         ruleResults = rule.Judge(sql);
         if(ruleResults == null)
         {
             continue;
         }
         results.AddRange(ruleResults);
     }
     return results;
 }
示例#3
0
        public IEnumerable <IDescribeSqlProblem> Run(string sql)
        {
            if (sql == null)
            {
                throw new ArgumentNullException("sql");
            }
            List <IDescribeSqlProblem> results;

            results = new List <IDescribeSqlProblem>();
            foreach (IParseSql parser in _parsers)
            {
                IDescribeSql sqlDescription = parser.Parse(sql);
                IEnumerable <IDescribeSqlProblem> ruleResults;
                ruleResults = _rules.ApplyActiveRules(sqlDescription);
                if (ruleResults != null)
                {
                    results.AddRange(ruleResults);
                }
            }
            return(results);
        }
 public abstract IEnumerable<IDescribeSqlProblem> Judge(IDescribeSql description);
 public override IEnumerable <IDescribeSqlProblem> Judge(IDescribeSql description)
 {
     return(new List <IDescribeSqlProblem> {
         _problem
     });
 }
 public IEnumerable<IDescribeSqlProblem> ApplyActiveRules(IDescribeSql sql)
 {
     return _catalog.ApplyActiveRules(sql);
 }
示例#7
0
 private void CreateEngineAndSuccessfulParsers()
 {
     CreateEngine();
     _parseResult1 = MockRepository.GenerateMock<IDescribeSql>();
     _parseResult2 = MockRepository.GenerateMock<IDescribeSql>();
     _parser1.Stub(p => p.Parse(null))
             .IgnoreArguments()
             .Return(_parseResult1);
     _parser2.Stub(p => p.Parse(null))
             .IgnoreArguments()
             .Return(_parseResult2);
 }
示例#8
0
 public abstract IEnumerable <IDescribeSqlProblem> Judge(IDescribeSql description);
示例#9
0
 public IEnumerable <IDescribeSqlProblem> ApplyActiveRules(IDescribeSql sql)
 {
     return(_catalog.ApplyActiveRules(sql));
 }