public void Test_Sandbox()
        {
            using (SqlTraceReader reader = new SqlTraceReader())
            {
                var filterByProcess    = TraceRowFilter.CreateByClientProcess(Process.GetCurrentProcess().Id);
                var filterLikeSqlTrace = TraceRowFilter.CreateLikeApplication("SqlTrace");
                reader.Start(TestEnvironment.MasterConnectionString, TestEnvironment.TracePath, TraceColumns.All, filterByProcess, filterLikeSqlTrace);

                using (SqlConnection con = new SqlConnection(TestEnvironment.DbConnectionString))
                {
                    con.Open();

                    using (SqlCommand cmd = new SqlCommand(SqlBatch, con))
                    {
                        cmd.ExecuteNonQuery();
                    }

                    for (int i = 1; i < 10; i++)
                    {
                        using (SqlCommand cmd = new SqlCommand($"Insert {Table1Name}(id) Values(@i)", con))
                        {
                            cmd.Parameters.Add("@i", i);
                            cmd.ExecuteNonQuery();
                        }
                    }

                    using (SqlCommand cmd = new SqlCommand($"Select * From {Table1Name}", con))
                    {
                        cmd.ExecuteNonQuery();
                    }

                    using (SqlCommand cmd = new SqlCommand("sp_server_info", con))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.ExecuteNonQuery();
                    }
                }

                reader.Stop();
                var rptGroups = reader.ReadGroupsReport <string>(TraceColumns.ClientHost);
                var bySql     = reader.ReadGroupsReport <string>(TraceColumns.Sql);

                var rptSummary = reader.ReadSummaryReport();
                var rpt        = reader.ReadDetailsReport();
                Console.WriteLine("Statements: " + rpt.Count);
                DumpCounters(rpt);

                Console.WriteLine("");
                Console.WriteLine("My Process: " + Process.GetCurrentProcess().Id);
                Console.WriteLine("Summary: " + rptSummary);
                Console.WriteLine("Details Summary " + rpt.Summary);
            }
        }
        public void Single_StoredProcedure_Is_Captured()
        {
            string sql = @"SELECT @@version, @parameter;";

            using (SqlTraceReader reader = new SqlTraceReader())
            {
                reader.Start(TestEnvironment.MasterConnectionString, TestEnvironment.TracePath, TraceColumns.All);

                using (SqlConnection con = new SqlConnection(TestEnvironment.DbConnectionString))
                {
                    con.Open();
                    using (SqlCommand cmd = new SqlCommand(sql, con))
                    {
                        cmd.Parameters.Add("@parameter", SqlDbType.Int).Value = 0;
                        cmd.ExecuteNonQuery();
                    }
                }

                var summary = reader.ReadSummaryReport();
                var groups  = reader.ReadGroupsReport <int>(TraceColumns.ClientProcess);
                var details = reader.ReadDetailsReport();
                DumpCounters(details);
                int idProcess = Process.GetCurrentProcess().Id;
                Console.WriteLine("Trace summary is " + details.Summary);

                bool isCaught = details.Any(x =>
                                            x.SpName == "sp_executesql" &&
                                            x.Sql.IndexOf(sql) >= 0 &&
                                            x.ClientProcess == idProcess);

                if (!isCaught)
                {
                    Assert.Fail("Expected sql proc '{0}' call by process {1}", "sp_executesql", idProcess);
                }
            }
        }