Example #1
0
        public ValidationResult Validate(ProcessedStatement currentStatement, IList <ProcessedStatement> contractBlock)
        {
            var validationResult = DoValidate(currentStatement, contractBlock);

            validationResult.SetProcessedStatement(currentStatement);
            return(validationResult);
        }
Example #2
0
        internal void SetProcessedStatement(ProcessedStatement processedStatement)
        {
            Contract.Requires(processedStatement != null);
            Contract.Requires(processedStatement.CSharpStatement == Statement,
                              "Processed statement should have the same CSharpStatement that you passed to the constructor!");

            _processedStatement = processedStatement;
        }
Example #3
0
 protected override ValidationResult DoValidate(ProcessedStatement currentStatement, IList <ProcessedStatement> contractBlock)
 {
     if (currentStatement.ContractStatement == null)
     {
         return(ValidationResult.CreateNoError(currentStatement.CSharpStatement));
     }
     return(_validationFunc(currentStatement.ContractStatement));
 }
Example #4
0
        public ValidatedStatement(ProcessedStatement processedStatement, IList <ValidationResult> validationResults)
        {
            Contract.Requires(processedStatement != null);
            Contract.Requires(validationResults != null);

            _processedStatement = processedStatement;
            _validationResults  = validationResults.Count == 0 ? new[] { ValidationResult.CreateNoError(processedStatement.CSharpStatement) } : validationResults;
        }
Example #5
0
        private static IEnumerable <ValidationResult> ValidateStatement(IList <ValidationRule> validationRules,
                                                                        IList <ProcessedStatement> contractBlock, ProcessedStatement currentStatement)
        {
            Contract.Requires(contractBlock != null);
            Contract.Requires(currentStatement != null);
            Contract.Ensures(Contract.Result <IEnumerable <ValidationResult> >() != null);

            return(validationRules
                   .Select(rule => rule.Validate(currentStatement, contractBlock))
                   .Where(vr => vr.ErrorType != ErrorType.NoError)
                   .ToList());
        }
Example #6
0
 protected abstract ValidationResult DoValidate(ProcessedStatement currentStatement,
                                                IList <ProcessedStatement> contractBlock);