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 SelectOutput(string selectParam, DeclarationsArray declarationsArray) { SuchThat suchThat = new SuchThat(declarationsArray); SelectParam = selectParam; queryResults = new List <MethodResultList>(); //validation completed foreach (var methodToDo in SuchThatValidator.GetMethodsToDo()) { queryResults.Add(suchThat.DoSuchThatMethod(methodToDo.MethodName, methodToDo.Param1, methodToDo.Param2)); } //foreach (var qr in queryResults) //{ // Console.WriteLine($"\n{qr.ListType1}\t{qr.ListType2}"); // for (int i = 0; i < qr.List1.Count; i++) // { // Console.WriteLine($"{((AbstractAuxiliaryGrammar) qr.List1[i]).entry}\t{((AbstractAuxiliaryGrammar) qr.List2[i]).entry}"); // } //} ResultTableRelations resultTableRelations = new ResultTableRelations(); for (int i = 0; i < queryResults.Count; i++) { MethodResultList qr = queryResults[i]; if (qr.ListType1 == typeof(Ident)) { if (qr.ListType2 == typeof(Ident)) { resultTableRelations.AddRelation(qr.QueryParam1, qr.QueryParam2, i); } else //qr.ListType2 == typeof(Ident) { resultTableRelations.AddRelation(qr.QueryParam1, i); } } else //qr.ListType1 != typeof(Ident) { if (qr.ListType2 == typeof(Ident)) { resultTableRelations.AddRelation(qr.QueryParam2, i); } else //qr.ListType2 != typeof(Ident) { resultTableRelations.AddRelation(qr.QueryParam2, qr.QueryParam1, i); } } } MergedResultTableRelations mergedResultTableRelations = new MergedResultTableRelations(resultTableRelations); StackList = mergedResultTableRelations.ExecuteAllMerges(selectParam); }
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 SelectValidator(DeclarationsArray Declarations) { this.Declarations = Declarations; }
public DeclarationValidator() { this.declarationsArray = new DeclarationsArray(); }
public SelectWithValidator(string entry, DeclarationsArray declarations) { this.entry = entry; this.declarations = declarations; }