public void SelectValidator_ShouldReturnTrue_WhenValidSelectWith_PlusAnd(string queryToValidate)
        {
            QueryValidator queryValidator = new QueryValidator();
            bool           result         = queryValidator.ValidateQuery(queryToValidate);

            Assert.True(result);
        }
Example #2
0
        public void ValidateQuery_SelectSuchThat_InvalidQueries(string queryToValidate)
        {
            QueryValidator validator = new QueryValidator();
            var            result    = validator.ValidateQuery(queryToValidate);

            Assert.True(result);
        }
Example #3
0
        public void ValidateWith_ShouldReturnTrue(string queryToValidate)
        {
            QueryValidator validator = new QueryValidator();
            bool           result    = validator.ValidateQuery(queryToValidate);

            Assert.True(result);
        }
Example #4
0
        public void ValidateQuery_ShouldReturnTrue(string queryToValidate)
        {
            QueryValidator validator = new QueryValidator();
            bool           result    = validator.ValidateQuery(queryToValidate);

            Assert.True(result, $"{queryToValidate} should return true");
        }
Example #5
0
        public void ValidateQuery_ShouldReturnTrue_WhenTheSameVariablesDefinedWithLowerAndUpperCase()
        {
            // Can we declare lower and uppercase? (Compare with how PipeTester works)
            QueryValidator validator = new QueryValidator();
            bool           result    = validator.ValidateQuery("Procedure p; While P; Select P");

            Assert.True(result);
        }
Example #6
0
        public void ValidateSelectBoolean_ShouldReturnFalse_WhenModifiesIsAmbiguous()
        {
            // 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
            QueryValidator validator = new QueryValidator();
            bool           result    = validator.ValidateQuery("select boolean such that Modifies (_, \"x\")");

            Assert.False(result);
        }
Example #7
0
        public void ValidateQuery_ShouldReturnFalse_WhenTheSameVariablesAreDefined()
        {
            // arrange
            QueryValidator validator = new QueryValidator();
            // act
            Action act = () => validator.ValidateQuery("Procedure p; While p; Select p");

            // assert
            Assert.Throws <InvalidQueryException>(act);
        }
Example #8
0
        public void ValidateQuery_ShouldReturnFalse_WhenNotExistingDeclarationIsUsed(string queryToValidate)
        {
            // arrange
            QueryValidator validator = new QueryValidator();
            // act
            Action act = () => validator.ValidateQuery(queryToValidate);

            // assert
            Assert.Throws <InvalidQueryException>(act);
        }
Example #9
0
        public static string ProcessQuery(string query)
        {
            try
            {
                QueryValidator queryValidator = new QueryValidator();
                bool           isQueryValid   = queryValidator.ValidateQuery(query);
            }
            catch (Exception e)
            {
                Console.WriteLine("none");
            }

            return("OK");
        }
Example #10
0
        public static string ProcessQuery(string query)
        {
            try
            {
                QueryValidator queryValidator = new QueryValidator();
                bool           isQueryValid   = queryValidator.ValidateQuery(query);
            }
            catch (Exception e)
            {
                //return $"#{e.Message} - {e.GetType()}";
                Console.WriteLine("none");
                //return "none";
            }

            return("OK");
        }