public void WriteOnCommandExecuting_IsNotEnabled()
        {
            // arrange
            var command = Mock.Of <DbCommand>();

            Mock.Get(command).Protected().SetupGet <DbConnection>("DbConnection").Returns(Mock.Of <DbConnection>());
            var transaction = Mock.Of <DbTransaction>();
            var source      = new DbDiagnosticListener();

            // act
            var operationId = source.OnCommandExecuting(command, transaction, "operation");

            // assert
            Assert.Equal(Guid.Empty, operationId);
        }
        public void WriteOnCommandExecuting()
        {
            // arrange
            var connection = Mock.Of <DbConnection>();
            var command    = Mock.Of <DbCommand>();

            Mock.Get(command).Protected().SetupGet <DbConnection>("DbConnection").Returns(connection);
            var transaction = Mock.Of <DbTransaction>();
            var source      = new DbDiagnosticListener();
            var operationId = Guid.Empty;

            // act
            var(eventName, payload) = DbDiagnosticSession.Execute(source,
                                                                  () => { operationId = source.OnCommandExecuting(command, transaction, "operation"); });

            // assert
            Assert.Equal("System.Data.Common.CommandExecuting", eventName);
            var commandPayload = Assert.IsType <CommandPayload>(payload);

            Assert.Equal(command, commandPayload.Command);
            Assert.Equal(connection.GetGuid(), commandPayload.ConnectionId);
            Assert.Equal(operationId, commandPayload.OperationId);
            Assert.Equal("operation", commandPayload.Operation);
            Assert.Equal(transaction.GetId(), commandPayload.TransactionId);
            Assert.Null(commandPayload.Exception);
        }