示例#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_WhenIncorrectVariableName(string queryToValidate)
        {
            DeclarationValidator validator = new DeclarationValidator();
            bool result = validator.ValidateDeclarationQuery(queryToValidate);

            Assert.False(result, $"{queryToValidate} should be in format: LETTER ( LETTER | DIGIT | ‘#’ )* ");
        }
示例#3
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");
        }
示例#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’ ");
        }