Ejemplo n.º 1
0
        private static void AssertMainProgram(OraclePlSqlProgram mainProgram, OracleObjectIdentifier expectedObjectIdentifier)
        {
            mainProgram.Variables.Count.ShouldBe(3);
            mainProgram.Variables[0].Name.ShouldBe("\"TEST_VARIABLE1\"");
            mainProgram.Variables[0].IsConstant.ShouldBe(false);
            mainProgram.Variables[0].Nullable.ShouldBe(true);
            mainProgram.Variables[0].DefaultExpressionNode.ShouldBe(null);
            mainProgram.Variables[0].DataTypeNode.ShouldNotBe(null);
            mainProgram.Variables[0].DataTypeNode.FirstTerminalNode.Id.ShouldBe(Terminals.Number);
            mainProgram.Variables[0].DataTypeNode.LastTerminalNode.Id.ShouldBe(Terminals.Number);
            mainProgram.Variables[1].Name.ShouldBe("\"TEST_VARIABLE2\"");
            mainProgram.Variables[1].IsConstant.ShouldBe(false);
            mainProgram.Variables[1].Nullable.ShouldBe(true);
            mainProgram.Variables[1].DefaultExpressionNode.ShouldBe(null);
            mainProgram.Variables[1].DataTypeNode.ShouldNotBe(null);
            mainProgram.Variables[1].DataTypeNode.FirstTerminalNode.Id.ShouldBe(Terminals.Varchar2);
            mainProgram.Variables[1].DataTypeNode.LastTerminalNode.Id.ShouldBe(Terminals.RightParenthesis);
            mainProgram.Variables[2].Name.ShouldBe("\"TEST_CONSTANT1\"");
            mainProgram.Variables[2].IsConstant.ShouldBe(true);
            mainProgram.Variables[2].Nullable.ShouldBe(false);
            mainProgram.Variables[2].DefaultExpressionNode.ShouldNotBe(null);
            mainProgram.Exceptions.Count.ShouldBe(0);
            mainProgram.PlSqlVariableReferences.Count.ShouldBe(1);
            mainProgram.PlSqlExceptionReferences.Count.ShouldBe(0);
            mainProgram.Types.Count.ShouldBe(2);
            mainProgram.Types[0].Name.ShouldBe("\"TEST_TYPE1\"");
            mainProgram.Types[1].Name.ShouldBe("\"TEST_TABLE_TYPE1\"");
            mainProgram.SubPrograms.Count.ShouldBe(2);
            mainProgram.SqlModels.Count.ShouldBe(2);

            mainProgram.ProgramReferences.Count.ShouldBe(1);
            var programReference = mainProgram.ProgramReferences.First();

            programReference.Name.ShouldBe("put_line");
            programReference.ObjectNode.Token.Value.ShouldBe("dbms_output");
            programReference.ParameterListNode.ShouldNotBe(null);
            programReference.ParameterReferences.Count.ShouldBe(1);
            programReference.ParameterReferences[0].OptionalIdentifierTerminal.Token.Value.ShouldBe("item");
            programReference.ParameterReferences[0].ParameterNode.LastTerminalNode.Token.Value.ShouldBe("test_constant1");

            mainProgram.SubPrograms[0].ObjectIdentifier.ShouldBe(expectedObjectIdentifier);
            mainProgram.SubPrograms[0].Name.ShouldBe("\"TEST_INNER_PROCEDURE\"");
            mainProgram.SubPrograms[0].Parameters.Count.ShouldBe(1);
            mainProgram.SubPrograms[0].Parameters[0].Name.ShouldBe("\"P1\"");
            mainProgram.SubPrograms[0].Parameters[0].Direction.ShouldBe(ParameterDirection.Input);
            mainProgram.SubPrograms[0].ReturnParameter.ShouldBe(null);
            mainProgram.SubPrograms[0].Variables.Count.ShouldBe(1);
            mainProgram.SubPrograms[0].Variables[0].Name.ShouldBe("\"TEST_VARIABLE3\"");
            mainProgram.SubPrograms[0].Variables[0].IsConstant.ShouldBe(false);
            mainProgram.SubPrograms[0].Variables[0].Nullable.ShouldBe(false);
            mainProgram.SubPrograms[0].Variables[0].DefaultExpressionNode.ShouldNotBe(null);
            mainProgram.SubPrograms[0].Exceptions.Count.ShouldBe(0);
            mainProgram.SubPrograms[0].PlSqlVariableReferences.Count.ShouldBe(1);
            mainProgram.SubPrograms[0].PlSqlExceptionReferences.Count.ShouldBe(0);
            mainProgram.SubPrograms[0].Types.Count.ShouldBe(0);
            mainProgram.SubPrograms[0].SubPrograms.Count.ShouldBe(0);
            mainProgram.SubPrograms[0].SqlModels.Count.ShouldBe(0);

            mainProgram.SubPrograms[1].ObjectIdentifier.ShouldBe(expectedObjectIdentifier);
            mainProgram.SubPrograms[1].Name.ShouldBe("\"TEST_INNER_FUNCTION\"");
            mainProgram.SubPrograms[1].Parameters.Count.ShouldBe(1);
            mainProgram.SubPrograms[1].Parameters[0].Name.ShouldBe("\"P1\"");
            mainProgram.SubPrograms[1].Parameters[0].Direction.ShouldBe(ParameterDirection.Input);
            mainProgram.SubPrograms[1].ReturnParameter.ShouldNotBe(null);
            mainProgram.SubPrograms[1].ReturnParameter.DataTypeNode.ShouldNotBe(null);
            mainProgram.SubPrograms[1].ReturnParameter.DefaultExpressionNode.ShouldBe(null);
            mainProgram.SubPrograms[1].ReturnParameter.Nullable.ShouldBe(true);
            mainProgram.SubPrograms[1].ReturnParameter.Direction.ShouldBe(ParameterDirection.ReturnValue);
            mainProgram.SubPrograms[1].Variables.Count.ShouldBe(0);
            mainProgram.SubPrograms[1].Exceptions.Count.ShouldBe(1);
            mainProgram.SubPrograms[1].Exceptions[0].Name.ShouldBe("\"TEST_EXCEPTION1\"");
            mainProgram.SubPrograms[1].PlSqlExceptionReferences.Count.ShouldBe(2);
            mainProgram.SubPrograms[1].PlSqlExceptionReferences.ForEach(r => r.Name.ShouldBe("test_exception1"));
            mainProgram.SubPrograms[1].PlSqlVariableReferences.Count.ShouldBe(0);
            mainProgram.SubPrograms[1].Types.Count.ShouldBe(0);
            mainProgram.SubPrograms[1].SubPrograms.Count.ShouldBe(1);
            mainProgram.SubPrograms[1].SqlModels.Count.ShouldBe(1);

            mainProgram.SubPrograms[1].SubPrograms[0].ObjectIdentifier.ShouldBe(expectedObjectIdentifier);
            mainProgram.SubPrograms[1].SubPrograms[0].Name.ShouldBe("\"TEST_NESTED_PROCEDURE\"");
            mainProgram.SubPrograms[1].SubPrograms[0].Parameters.Count.ShouldBe(1);
            mainProgram.SubPrograms[1].SubPrograms[0].Parameters[0].Name.ShouldBe("\"P1\"");
            mainProgram.SubPrograms[1].SubPrograms[0].Parameters[0].Direction.ShouldBe(ParameterDirection.Input);
            mainProgram.SubPrograms[1].SubPrograms[0].ReturnParameter.ShouldBe(null);
            mainProgram.SubPrograms[1].SubPrograms[0].Variables.Count.ShouldBe(0);
            mainProgram.SubPrograms[1].SubPrograms[0].Exceptions.Count.ShouldBe(0);
            mainProgram.SubPrograms[1].SubPrograms[0].PlSqlVariableReferences.Count.ShouldBe(0);
            mainProgram.SubPrograms[1].SubPrograms[0].PlSqlExceptionReferences.Count.ShouldBe(0);
            mainProgram.SubPrograms[1].SubPrograms[0].Types.Count.ShouldBe(0);
            mainProgram.SubPrograms[1].SubPrograms[0].SubPrograms.Count.ShouldBe(0);
            mainProgram.SubPrograms[1].SubPrograms[0].SqlModels.Count.ShouldBe(1);
        }