コード例 #1
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);
        }
コード例 #2
0
        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);
        }
コード例 #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 SelectValidator(DeclarationsArray Declarations)
 {
     this.Declarations = Declarations;
 }
コード例 #7
0
 public DeclarationValidator()
 {
     this.declarationsArray = new DeclarationsArray();
 }
コード例 #8
0
ファイル: SelectWithValidator.cs プロジェクト: PawelStp/aisti
 public SelectWithValidator(string entry, DeclarationsArray declarations)
 {
     this.entry        = entry;
     this.declarations = declarations;
 }