protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
        {
            Match match = selectRegex.Match(CommandText);

            if (!match.Success)
            {
                throw new NotSupportedException();
            }

            string     className      = Connection.ConnectionString;
            string     methodName     = match.Groups["MethodName"].Value;
            MethodInfo methodToInvoke = MethodFinder.GetMethodToInvoke(className, methodName);

            return(new MSTestCaseDataReader(DefaultTestCaseProvider.Instance.GetTestCases(methodToInvoke)));
        }
Exemplo n.º 2
0
        public override void OnInvoke(MethodInterceptionArgs args)
        {
            TestContext testContext = GetTestContext(args.Instance);

            if (methodToInvoke == null)
            {
                methodToInvoke = MethodFinder.GetMethodToInvoke(args.Method);
            }

            try
            {
                methodToInvoke.Invoke(args.Instance, GetParameterValues(testContext, methodToInvoke.GetParameters()));
            }
            catch (TargetInvocationException exc)
            {
                // fix stacktrace
                FieldInfo remoteStackTraceString = typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic); // MS.Net

                remoteStackTraceString.SetValue(exc.InnerException, exc.InnerException.StackTrace + Environment.NewLine);

                throw exc.InnerException;
            }
        }