Пример #1
0
        public void Validate_ValidQuery_ShouldReturnTrue(string query)
        {
            var validator = new SelectValidator(_database);

            var actual = validator.Validate(query);

            Assert.True(actual);
        }
Пример #2
0
        public void ValidateSelect_ShouldReturnFalse_WhenCallsSyntaxIsIncorrect(string queryToValidate)
        {
            DeclarationsArray declarations = new DeclarationsArray();
            SelectValidator   validator    = new SelectValidator(declarations);
            bool result = validator.ValidateSelectQuery(queryToValidate);

            Assert.True(result);
        }
Пример #3
0
        public void ValidateSelectBoolean_ShouldReturnFalse_WhenModifiesIsAmbiguous()
        {
            DeclarationsArray declarations = new DeclarationsArray();
            // Use of underscore must not lead to ambiguities. For example, the following query should be rejected
            // as incorrect as it is not clear if underscore refers to a statement or to a procedure
            SelectValidator validator = new SelectValidator(declarations);
            bool            result    = validator.ValidateSelectQuery("select boolean such that Modifies (_, \"x\")");

            Assert.False(result);
        }
Пример #4
0
        public void ValidateSelectBoolean_ShouldReturnTrue_WhenModifies(string queryToValidate)
        {
            DeclarationsArray declarations = new DeclarationsArray();
            // Modifies design entity relationships:
            // Modifies(procedure, variable)
            // Modifies(stmt, variable)
            SelectValidator validator = new SelectValidator(declarations);
            bool            result    = validator.ValidateSelectQuery(queryToValidate);

            Assert.True(result);
        }
Пример #5
0
        public void ValidateSelect_ShouldReturnFalse_WhenSuchThatUsedIncorrectly(string queryToValidate)
        {
            DeclarationsArray declarations = new DeclarationsArray();
            // **such that grammar rules** //
            // suchthat - cl : ‘such that’ relCond
            // relCond : relRef( ‘and’ relRef) *
            // relRef: ModifiesP | ModifiesS | UsesP | UsesS | Calls | CallsT | Parent | ParentT |
            //          Follows | FollowsT | Next | NextT | Affects | AffectsT
            SelectValidator validator = new SelectValidator(declarations);
            bool            result    = validator.ValidateSelectQuery(queryToValidate);

            Assert.True(result);
        }
Пример #6
0
        public void Validate_InvalidQuery_ShouldThrowAnException(string query)
        {
            var validator = new SelectValidator(_database);

            Assert.ThrowsAny <Exception>(() => validator.Validate(query));
        }