Esempio n. 1
0
            public void LogResult_logs_elapsed_time_for_canceled_commands()
            {
                var writer = new StringWriter();
                var logger = new DbCommandLogger(writer.Write);
                var elapsed = GetElapsed(logger);

                var interceptionContext = new DbCommandInterceptionContext<int>();
                interceptionContext.MutableData.TaskStatus = TaskStatus.Canceled;

                logger.LogResult(
                    new Mock<DbCommand>().Object, 77, interceptionContext);

                Assert.Equal(Strings.CommandLogCanceled(elapsed, ""), GetSingleLine(writer));
            }
Esempio n. 2
0
            public void ScalarExecuted_logs()
            {
                var interceptionContext = new DbCommandInterceptionContext<object>();
                interceptionContext.Result = "That Sam-I-am";

                var writer = new StringWriter();
                new DbCommandLogger(writer.Write).ScalarExecuted(CreateCommand(""), interceptionContext);

                Assert.Equal(Strings.CommandLogComplete(0, "That Sam-I-am", ""), GetSingleLine(writer));
            }
Esempio n. 3
0
            public void LogResult_handles_canceled_commands()
            {
                var writer = new StringWriter();

                var interceptionContext = new DbCommandInterceptionContext<DbDataReader>();
                interceptionContext.MutableData.TaskStatus = TaskStatus.Canceled;

                new DbCommandLogger(writer.Write).LogResult(
                    new Mock<DbCommand>().Object,
                    null,
                    interceptionContext);

                Assert.Equal(Strings.CommandLogCanceled(0, ""), GetSingleLine(writer));
            }
Esempio n. 4
0
            public void NonQueryExecuted_logs()
            {
                var interceptionContext = new DbCommandInterceptionContext<int>();
                interceptionContext.Result = 88;
                var writer = new StringWriter();

                new DbCommandLogger(writer.Write).NonQueryExecuted(CreateCommand(""), interceptionContext);

                Assert.Equal(Strings.CommandLogComplete(0, "88", ""), GetSingleLine(writer));
            }
Esempio n. 5
0
            public void ReaderExecuted_logs()
            {
                var dataReader = new Mock<DbDataReader>().Object;
                var interceptionContext = new DbCommandInterceptionContext<DbDataReader>();

                interceptionContext.Result = dataReader;
                var writer = new StringWriter();
                new DbCommandLogger(writer.Write).ReaderExecuted(CreateCommand(""), interceptionContext);

                Assert.Equal(Strings.CommandLogComplete(0, dataReader.GetType().Name, ""), GetSingleLine(writer));
            }
Esempio n. 6
0
 public abstract void ScalarExecuted(DbCommand command, DbCommandInterceptionContext<object> interceptionContext);
 public void ReaderExecuted(
     DbCommand command, DbCommandInterceptionContext<DbDataReader> interceptionContext)
 {
     if (ShouldLog(interceptionContext))
     {
         _log.Add(new CommandLogItem(CommandMethod.ReaderExecuted, command, interceptionContext, interceptionContext.Result));
     }
 }
Esempio n. 8
0
            public override void ScalarExecuting(DbCommand command, DbCommandInterceptionContext<object> interceptionContext)
            {
                Commands.Add(command);

                Assert.Empty(interceptionContext.DbContexts);
                Assert.Empty(interceptionContext.ObjectContexts);
            }
Esempio n. 9
0
            public override void ReaderExecuting(DbCommand command, DbCommandInterceptionContext<DbDataReader> interceptionContext)
            {
                Commands.Add(command);

                Assert.Empty(interceptionContext.DbContexts);
                Assert.Empty(interceptionContext.ObjectContexts);
            }
 /// <inheritdoc />
 public virtual void ReaderExecuted(DbCommand command, DbCommandInterceptionContext<DbDataReader> interceptionContext)
 {
 }
 /// <inheritdoc />
 public virtual void ScalarExecuted(DbCommand command, DbCommandInterceptionContext<object> interceptionContext)
 {
 }
 /// <inheritdoc />
 public virtual void NonQueryExecuted(DbCommand command, DbCommandInterceptionContext<int> interceptionContext)
 {
 }
 public CommandLogItem(
     CommandMethod method, 
     DbCommand command, 
     DbCommandInterceptionContext interceptionContext, 
     object result = null)
 {
     Method = method;
     CommandText = command.CommandText;
     Command = command;
     Exception = interceptionContext.Exception;
     TaskStatus = interceptionContext.TaskStatus;
     IsAsync = interceptionContext.IsAsync;
     Result = result;
 }
 public void ScalarExecuted(DbCommand command, DbCommandInterceptionContext<object> interceptionContext)
 {
     if (ShouldLog(interceptionContext))
     {
         _log.Add(new CommandLogItem(CommandMethod.ScalarExecuted, command, interceptionContext, interceptionContext.Result));
     }
 }
Esempio n. 15
0
 public abstract void NonQueryExecuted(DbCommand command, DbCommandInterceptionContext<int> interceptionContext);
 public override void LogCommand(DbCommand command, DbCommandInterceptionContext interceptionContext)
 {
     Sink(
         string.Format(
             CultureInfo.CurrentCulture,
             "Context '{0}' is executing command '{1}'{2}",
             Context.GetType().Name,
             command.CommandText.CollapseWhitespace(), Environment.NewLine));
 }
Esempio n. 17
0
 public abstract void ReaderExecuted(DbCommand command, DbCommandInterceptionContext<DbDataReader> interceptionContext);
 public override void LogResult(DbCommand command, object result, DbCommandInterceptionContext interceptionContext)
 {
     Sink(
         string.Format(
             CultureInfo.CurrentCulture, "Context '{0}' finished executing command{1}", Context.GetType().Name,
             Environment.NewLine));
 }
Esempio n. 19
0
                public override void NonQueryExecuting(DbCommand command, DbCommandInterceptionContext<int> interceptionContext)
                {
                    CommandTexts.Add(command.CommandText);

                    Assert.Empty(interceptionContext.DbContexts);
                    Assert.Empty(interceptionContext.ObjectContexts);
                }
 public void NonQueryExecuted(DbCommand command, DbCommandInterceptionContext<int> interceptionContext)
 {
     if (ShouldLog(interceptionContext))
     {
         _log.Add(new CommandLogItem(CommandMethod.NonQueryExecuted, command, interceptionContext, interceptionContext.Result));
     }
 }