public void Validate_ValidQuery_ShouldReturnTrue(string query) { var validator = new SelectValidator(_database); var actual = validator.Validate(query); Assert.True(actual); }
public void ValidateSelect_ShouldReturnFalse_WhenCallsSyntaxIsIncorrect(string queryToValidate) { DeclarationsArray declarations = new DeclarationsArray(); SelectValidator validator = new SelectValidator(declarations); bool result = validator.ValidateSelectQuery(queryToValidate); Assert.True(result); }
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); }
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); }
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); }
public void Validate_InvalidQuery_ShouldThrowAnException(string query) { var validator = new SelectValidator(_database); Assert.ThrowsAny <Exception>(() => validator.Validate(query)); }