Ejemplo n.º 1
0
        public void TraceTest()
        {
            var traceService = new TestTraceService();

            using (Db.EnterTransaction())
            {
                Db.T($"SELECT * FROM testTable").WithTraceService(traceService).ExecuteDataTable();

                var tracing = traceService.Last();

                var logs = tracing.TraceEvents;
                Assert.AreEqual(logs.Count, 3);

                Assert.AreEqual(logs[0].EventName, "OnExecuting");
                Assert.AreEqual(logs[1].EventName, "OnLoadingData");
                Assert.AreEqual(logs[2].EventName, "OnComplete");


                try
                {
                    Db.T($"SELECT * FROM Nothing").WithTraceService(traceService).ExecuteDynamics();
                }
                catch
                {
                }

                tracing = traceService.Last();

                logs = tracing.TraceEvents;
                Assert.AreEqual(logs.Count, 2);

                Assert.AreEqual(logs[0].EventName, "OnExecuting");
                Assert.AreEqual(logs[1].EventName, "OnException");
            }
        }
Ejemplo n.º 2
0
        public void TraceTest()
        {
            db.T("SELECT * FROM testTable").ExecuteDataTable();

            var tracing = traceService.Last();

            var logs = tracing.GetLogEntries();

            Assert.AreEqual(logs.Length, 3);

            Assert.AreEqual(logs[0].Message, "OnExecuting");
            Assert.AreEqual(logs[1].Message, "OnLoadingData");
            Assert.AreEqual(logs[2].Message, "OnComplete");


            try
            {
                db.T("SELECT * FROM Nothing").ExecuteDynamics();
            }
            catch
            {
            }

            tracing = traceService.Last();

            logs = tracing.GetLogEntries();
            Assert.AreEqual(logs.Length, 2);

            Assert.AreEqual(logs[0].Message, "OnExecuting");
            Assert.AreEqual(logs[1].Message, "OnException");
        }
Ejemplo n.º 3
0
        public void TraceTest()
        {
            var traceService = new TestTraceService();

            using (Db.Enter(configure => configure.Services.AddService <IDbTraceService>(traceService)))
            {
                Db.T($"SELECT * FROM testTable").ExecuteDataTable();

                var tracing = traceService.Last();

                var logs = tracing.TraceEvents;
                Assert.AreEqual(logs.Length, 3);

                Assert.AreEqual(logs[0].EventName, "OnExecuting");
                Assert.AreEqual(logs[1].EventName, "OnLoadingData");
                Assert.AreEqual(logs[2].EventName, "OnComplete");


                try
                {
                    Db.T($"SELECT * FROM Nothing").ExecuteDynamics();
                }
                catch
                {
                }

                tracing = traceService.Last();

                logs = tracing.TraceEvents;
                Assert.AreEqual(logs.Length, 2);

                Assert.AreEqual(logs[0].EventName, "OnExecuting");
                Assert.AreEqual(logs[1].EventName, "OnException");
            }
        }