Ejemplo n.º 1
0
        public void BasicTest()
        {
            var databaseModel = OracleDatabaseModel.GetDatabaseModel(ConnectionString, "DebuggerTestConnection");

            databaseModel.Initialize().Wait();
            var connectionAdapter = (OracleConnectionAdapter)databaseModel.CreateConnectionAdapter();

            OracleConfiguration.Configuration.StartupScript = "ALTER SESSION SET plsql_debug = true";

            const string sql =
                @"DECLARE
	var1 NUMBER NOT NULL := 1;
	var2 VARCHAR2(30);
	var3 SYS.ODCIVARCHAR2LIST := SYS.ODCIVARCHAR2LIST('value 1', 'value 2');
BEGIN
	var1 := var1 + 1;
	var2 := 'Dummy test';
END;";

            var statement = OracleSqlParser.Instance.Parse(sql).Single();

            statement.ParseStatus.ShouldBe(ParseStatus.Success);
            var validationModel = _validator.BuildValidationModel(_validator.BuildSemanticModel(sql, statement, databaseModel));

            var batchModel =
                new StatementBatchExecutionModel
            {
                Statements =
                    new []
                {
                    new StatementExecutionModel
                    {
                        StatementText   = sql,
                        ValidationModel = validationModel,
                        BindVariables   = new BindVariableModel[0]
                    }
                },
                EnableDebug = true
            };

            var task = connectionAdapter.ExecuteStatementAsync(batchModel, CancellationToken.None);

            task.Wait();

            connectionAdapter.DebuggerSession.ShouldNotBeNull();

            connectionAdapter.DebuggerSession.Attached += DebuggerSessionAttachedHandler;
            connectionAdapter.DebuggerSession.Start(CancellationToken.None);

            _resetEvent.WaitOne();

            connectionAdapter.DebuggerSession.ShouldBeNull();
        }
 public IDatabaseModel CreateDatabaseModel(ConnectionStringSettings connectionString, string identifier)
 {
     return(OracleDatabaseModel.GetDatabaseModel(connectionString, identifier));
 }