예제 #1
0
        public void ValidateDeclarations_ShouldReturnFalse_WhenVariableMissing()
        {
            DeclarationValidator validator = new DeclarationValidator();
            bool result = validator.ValidateDeclarationQuery("while    ");

            Assert.False(result);
        }
예제 #2
0
        public void ValidateDeclarations_ShouldReturnFalse_WhenKeywordsUsedAsVariable(string queryToValidate)
        {
            DeclarationValidator validator = new DeclarationValidator();
            bool result = validator.ValidateDeclarationQuery(queryToValidate);

            Assert.False(result, $"{queryToValidate} contains keyword as variable");
        }
예제 #3
0
        public void ValidateDeclarations_ShouldReturnFalse_WhenIncorrectVariableName(string queryToValidate)
        {
            DeclarationValidator validator = new DeclarationValidator();
            bool result = validator.ValidateDeclarationQuery(queryToValidate);

            Assert.False(result, $"{queryToValidate} should be in format: LETTER ( LETTER | DIGIT | ‘#’ )* ");
        }
예제 #4
0
        public void ValidateDeclarations_ShouldReturnTrue(string queryToValidate)
        {
            DeclarationValidator validator = new DeclarationValidator();
            bool result = validator.ValidateDeclarationQuery(queryToValidate);

            Assert.True(result, $"{queryToValidate} should return true");
        }
예제 #5
0
        public void ValidateDeclarations_ShouldReturnFalse_WhenIncorrectDesignEntity(string queryToValidate)
        {
            DeclarationValidator validator = new DeclarationValidator();
            bool result = validator.ValidateDeclarationQuery(queryToValidate);

            Assert.False(result, $"{queryToValidate} have incorrect synonyms. " +
                         $"Valid synonyms are ‘procedure’ | ‘stmtLst’ | ‘stmt’ | ‘assign’ | ‘call’ | ‘while’ " +
                         $"| ‘if’ | ‘variable’ | ‘constant’| ‘prog_line’ ");
        }
예제 #6
0
 public QueryValidator()
 {
     DeclarationValidator = new DeclarationValidator();
 }