Ejemplo n.º 1
0
        public void TestDemoStatisticsTimeIO()
        {
            GetConnection  u = new GetConnection();
            GetBatches     b = new GetBatches();
            GetBatchResult r = new GetBatchResult();
            GetSqlInfo     s = new GetSqlInfo();

            string constring_1 = u.GetConnectionString("AdventureWorks2014");

            string[] batches = b.GetFileContent(@"..\\..\\..\\SabinIO.Performance.StatisticsTimeIO\\Demos\\DemoStatisticsTimeIO.sql");

            SqlConnection _conn = new SqlConnection(constring_1);

            _conn.InfoMessage += new SqlInfoMessageEventHandler(s.Message);


            for (int i = 0; i < batches.Length; i++)
            {
                _conn.Open();
                SqlCommand cmd_1 = new SqlCommand(batches[i], _conn);
                cmd_1.ExecuteNonQuery();
                _conn.Close();
            }

            MatchCollection q = Regex.Matches(s.SqlInfoMessages[1], @"\d+");

            Assert.IsTrue(Convert.ToInt32(q[1].ToString()) <= 1246);

            MatchCollection w = Regex.Matches(s.SqlInfoMessages[2], @"\d+");

            Assert.IsTrue(Convert.ToInt32(q[0].ToString()) <= 200);
        }
Ejemplo n.º 2
0
        public void TestTruncateDeleteDemo1()
        {
            GetConnection  u = new GetConnection();
            GetBatches     b = new GetBatches();
            GetBatchResult r = new GetBatchResult();
            GetSqlInfo     s = new GetSqlInfo();

            string constring_1 = u.GetConnectionString("SabinIO.Performance.TruncateDelete");

            string[] batches = b.GetFileContent(@"..\\..\\..\\SabinIO.Performance.TruncateDelete\\Demos\\TruncateDeleteDemo1.sql");

            SqlConnection _conn = new SqlConnection(constring_1);

            _conn.InfoMessage += new SqlInfoMessageEventHandler(s.Message);

            for (int i = 0; i < batches.Length; i++)
            {
                _conn.Open();
                SqlCommand cmd_1 = new SqlCommand(batches[i], _conn);
                cmd_1.CommandTimeout = 60;
                cmd_1.ExecuteNonQuery();
                _conn.Close();
            }

            MatchCollection q = Regex.Matches(s.SqlInfoMessages[1], @"\d+");

            Assert.IsTrue(Convert.ToInt32(q[0].ToString()) <= 10);
            Assert.IsTrue(Convert.ToInt32(q[1].ToString()) <= 10);

            MatchCollection w = Regex.Matches(s.SqlInfoMessages[2], @"\d+");

            Assert.IsTrue(Convert.ToInt32(w[0].ToString()) <= 10);
            Assert.IsTrue(Convert.ToInt32(w[1].ToString()) <= 22);
            Assert.IsTrue(Convert.ToInt32(w[2].ToString()) <= 10);
            Assert.IsTrue(Convert.ToInt32(w[3].ToString()) <= 10);
            Assert.IsTrue(Convert.ToInt32(w[4].ToString()) <= 10);
            Assert.IsTrue(Convert.ToInt32(w[5].ToString()) <= 10);
            Assert.IsTrue(Convert.ToInt32(w[6].ToString()) <= 10);
        }