/// <summary>
        /// OnMethodBegin callback
        /// </summary>
        /// <typeparam name="TTarget">Type of the target</typeparam>
        /// <param name="instance">Instance value, aka `this` of the instrumented method.</param>
        /// <returns>Calltarget state value</returns>
        public static CallTargetState OnMethodBegin <TTarget>(TTarget instance)
        {
            if (Tracer.Instance.Settings.IsIntegrationEnabled(IntegrationId))
            {
                TestRunnerStruct runnerInstance = instance.As <TestRunnerStruct>();

                // Skip test support
                if (runnerInstance.SkipReason != null)
                {
                    XUnitIntegration.CreateScope(ref runnerInstance, instance.GetType());
                }
            }

            return(CallTargetState.GetDefault());
        }
        /// <summary>
        /// OnMethodBegin callback
        /// </summary>
        /// <typeparam name="TTarget">Type of the target</typeparam>
        /// <param name="instance">Instance value, aka `this` of the instrumented method.</param>
        /// <returns>Calltarget state value</returns>
        internal static CallTargetState OnMethodBegin <TTarget>(TTarget instance)
        {
            if (XUnitIntegration.IsEnabled)
            {
                TestRunnerStruct runnerInstance = instance.DuckCast <TestRunnerStruct>();

                // Skip test support
                if (runnerInstance.SkipReason != null)
                {
                    XUnitIntegration.CreateScope(ref runnerInstance, instance.GetType());
                }
            }

            return(CallTargetState.GetDefault());
        }
        /// <summary>
        /// OnMethodBegin callback
        /// </summary>
        /// <typeparam name="TTarget">Type of the target</typeparam>
        /// <param name="instance">Instance value, aka `this` of the instrumented method.</param>
        /// <returns>Calltarget state value</returns>
        public static CallTargetState OnMethodBegin <TTarget>(TTarget instance)
        {
            if (Tracer.Instance.Settings.IsIntegrationEnabled(IntegrationId))
            {
                return(CallTargetState.GetDefault());
            }

            TestInvokerStruct invokerInstance = instance.As <TestInvokerStruct>();
            TestRunnerStruct  runnerInstance  = new TestRunnerStruct
            {
                Aggregator          = invokerInstance.Aggregator,
                TestCase            = invokerInstance.TestCase,
                TestClass           = invokerInstance.TestClass,
                TestMethod          = invokerInstance.TestMethod,
                TestMethodArguments = invokerInstance.TestMethodArguments
            };

            return(new CallTargetState(XUnitIntegration.CreateScope(ref runnerInstance, instance.GetType())));
        }
Exemple #4
0
        /// <summary>
        /// OnMethodBegin callback
        /// </summary>
        /// <typeparam name="TTarget">Type of the target</typeparam>
        /// <param name="instance">Instance value, aka `this` of the instrumented method.</param>
        /// <returns>Calltarget state value</returns>
        internal static CallTargetState OnMethodBegin <TTarget>(TTarget instance)
        {
            if (!XUnitIntegration.IsEnabled)
            {
                return(CallTargetState.GetDefault());
            }

            TestInvokerStruct invokerInstance = instance.DuckCast <TestInvokerStruct>();
            TestRunnerStruct  runnerInstance  = new TestRunnerStruct
            {
                Aggregator          = invokerInstance.Aggregator,
                TestCase            = invokerInstance.TestCase,
                TestClass           = invokerInstance.TestClass,
                TestMethod          = invokerInstance.TestMethod,
                TestMethodArguments = invokerInstance.TestMethodArguments
            };

            return(new CallTargetState(XUnitIntegration.CreateScope(ref runnerInstance, instance.GetType())));
        }