Exemplo n.º 1
0
        public void ValidateDeclarations_ShouldReturnFalse_WhenVariableMissing()
        {
            DeclarationValidator validator = new DeclarationValidator();
            bool result = validator.ValidateDeclarationQuery("while    ");

            Assert.False(result);
        }
Exemplo n.º 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 | ‘#’ )* ");
        }
Exemplo n.º 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");
        }
Exemplo n.º 4
0
        public void ValidateDeclarations_ShouldReturnTrue(string queryToValidate)
        {
            DeclarationValidator validator = new DeclarationValidator();
            bool result = validator.ValidateDeclarationQuery(queryToValidate);

            Assert.True(result, $"{queryToValidate} should return true");
        }
Exemplo n.º 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’ ");
        }