public void EventSourceFakeTests(
            Type eventSourceType,
            CommandType commandType,
            string commandText,
            bool captureText,
            bool isFailure         = false,
            int sqlExceptionNumber = 0,
            bool enableConnectionLevelAttributes = false)
        {
            using IFakeBehavingSqlEventSource fakeSqlEventSource = (IFakeBehavingSqlEventSource)Activator.CreateInstance(eventSourceType);

            var activityProcessor = new Mock <BaseProcessor <Activity> >();

            using var shutdownSignal = Sdk.CreateTracerProviderBuilder()
                                       .AddProcessor(activityProcessor.Object)
                                       .AddSqlClientInstrumentation(options =>
            {
                options.SetStatementText = captureText;
                options.EnableConnectionLevelAttributes = enableConnectionLevelAttributes;
            })
                                       .Build();

            int objectId = Guid.NewGuid().GetHashCode();

            fakeSqlEventSource.WriteBeginExecuteEvent(objectId, "127.0.0.1", "master", commandType == CommandType.StoredProcedure ? commandText : string.Empty);

            // success is stored in the first bit in compositeState 0b001
            int successFlag = !isFailure ? 1 : 0;

            // isSqlException is stored in the second bit in compositeState 0b010
            int isSqlExceptionFlag = sqlExceptionNumber > 0 ? 2 : 0;

            // synchronous state is stored in the third bit in compositeState 0b100
            int synchronousFlag = false ? 4 : 0;

            int compositeState = successFlag | isSqlExceptionFlag | synchronousFlag;

            fakeSqlEventSource.WriteEndExecuteEvent(objectId, compositeState, sqlExceptionNumber);
            shutdownSignal.Dispose();
            Assert.Equal(5, activityProcessor.Invocations.Count); // SetTracerProvider/OnStart/OnEnd/OnShutdown/Dispose called.

            var activity = (Activity)activityProcessor.Invocations[2].Arguments[0];

            VerifyActivityData(commandText, captureText, isFailure, "127.0.0.1", activity, enableConnectionLevelAttributes);
        }
        public void DefaultCaptureTextFalse(Type eventSourceType)
        {
            using IFakeBehavingSqlEventSource fakeSqlEventSource = (IFakeBehavingSqlEventSource)Activator.CreateInstance(eventSourceType);

            var activityProcessor = new Mock <BaseProcessor <Activity> >();

            using var shutdownSignal = Sdk.CreateTracerProviderBuilder()
                                       .AddProcessor(activityProcessor.Object)
                                       .AddSqlClientInstrumentation()
                                       .Build();

            int objectId = Guid.NewGuid().GetHashCode();

            const string commandText = "TestCommandTest";

            fakeSqlEventSource.WriteBeginExecuteEvent(objectId, "127.0.0.1", "master", commandText);

            // success is stored in the first bit in compositeState 0b001
            int successFlag = 1;

            // isSqlException is stored in the second bit in compositeState 0b010
            int isSqlExceptionFlag = 2;

            // synchronous state is stored in the third bit in compositeState 0b100
            int synchronousFlag = 4;

            int compositeState = successFlag | isSqlExceptionFlag | synchronousFlag;

            fakeSqlEventSource.WriteEndExecuteEvent(objectId, compositeState, 0);
            shutdownSignal.Dispose();
            Assert.Equal(5, activityProcessor.Invocations.Count); // SetTracerProvider/OnStart/OnEnd/OnShutdown/Dispose called.

            var activity = (Activity)activityProcessor.Invocations[2].Arguments[0];

            const bool captureText = false;

            VerifyActivityData(commandText, captureText, false, "127.0.0.1", activity, false);
        }