public void WithSqlTimings()
        {
            MiniProfiler mp;

            using (BaseTest.GetRequest())
                using (var conn = GetProfiledConnection())
                {
                    mp = MiniProfiler.Current;

                    // one sql in the root timing
                    conn.Query("select 1");

                    using (mp.Step("Child step"))
                    {
                        conn.Query("select 2 where 1 = @one", new { one = 1 });
                    }
                }

            Assert.IsFalse(mp.HasDuplicateSqlTimings);

            AssertSqlTimingsExist(mp.Root, 1);
            var t = mp.Root.Children.Single();

            AssertSqlTimingsExist(t, 1);
            AssertSqlParametersExist(t.SqlTimings.Single(), 1);

            var mp2 = MiniProfiler.Settings.Storage.Load(mp.Id);

            AssertProfilersAreEqual(mp, mp2);
        }
Ejemplo n.º 2
0
        public void DataAdapter()
        {
            MiniProfiler mp;
            var          factory = EFProfiledDbProviderFactory <SqlCeProviderFactory> .Instance;

            using (BaseTest.GetRequest())
                using (var da = factory.CreateDataAdapter())
                {
                    var cmd = factory.CreateCommand();
                    Debug.Assert(cmd != null, "cmd != null");
                    cmd.CommandText = "select 1 as A, 2 as B";
                    Debug.Assert(da != null, "da != null");
                    da.SelectCommand            = cmd;
                    da.SelectCommand.Connection = GetConnection();

                    var ds = new DataSet();
                    da.Fill(ds);

                    Assert.That(((int)ds.Tables[0].Rows[0][0]) == 1);
                    mp = MiniProfiler.Current;
                }

            Assert.That(mp.ExecutedReaders == 1);
            Assert.That(mp.ExecutedScalars == 0);
            Assert.That(mp.ExecutedNonQueries == 0);
        }