private static bool CheckTestMethodSignature(TestMethodExtension testMethod, ParameterSet parms)
        {
            if (testMethod.Method.IsAbstract)
            {
                testMethod.RunState = RunState.NotRunnable;
                testMethod.IgnoreReason = "Method is abstract";
                return false;
            }

            if (!testMethod.Method.IsPublic)
            {
                testMethod.RunState = RunState.NotRunnable;
                testMethod.IgnoreReason = "Method is not public";
                return false;
            }

            ParameterInfo[] parameters = testMethod.Method.GetParameters();
            int argsNeeded = parameters.Length;

            object[] arglist = null;
            int argsProvided = 0;

            if (parms != null)
            {
                testMethod.arguments = parms.Arguments;
                testMethod.hasExpectedResult = parms.HasExpectedResult;
                if (testMethod.hasExpectedResult)
                    testMethod.expectedResult = parms.Result;
                testMethod.RunState = parms.RunState;
                testMethod.IgnoreReason = parms.IgnoreReason;
                testMethod.BuilderException = parms.ProviderException;

                arglist = parms.Arguments;

                if (arglist != null)
                    argsProvided = arglist.Length;

                if (testMethod.RunState != RunState.Runnable)
                    return false;
            }

#if CLR_2_0 || CLR_4_0
	        bool isAsyncMethod = Reflect.IsAsyncMethod(testMethod.Method);
			bool hasMeaningfulReturnType = isAsyncMethod ? testMethod.Method.ReturnType.IsGenericType : testMethod.Method.ReturnType != typeof(void);
#else
            bool hasMeaningfulReturnType = testMethod.Method.ReturnType != typeof(void);
#endif

            if (hasMeaningfulReturnType && (parms == null || !parms.HasExpectedResult && parms.ExpectedExceptionName == null))
                return MarkAsNotRunnable(testMethod, "Test method has non-void return type, but no result is expected");
            if (!hasMeaningfulReturnType && parms != null && parms.HasExpectedResult)
                return MarkAsNotRunnable(testMethod, "Test method has void return type, but a result is expected");

            if (argsProvided > 0 && argsNeeded == 0)
                return MarkAsNotRunnable(testMethod, "Arguments provided for method not taking any");

            if (argsProvided == 0 && argsNeeded > 0)
                return MarkAsNotRunnable(testMethod, "No arguments were provided");

            if (argsProvided != argsNeeded)
            {
                testMethod.RunState = RunState.NotRunnable;
                testMethod.IgnoreReason = "Wrong number of arguments provided";
                return false;
            }

#if CLR_2_0 || CLR_4_0
            if (testMethod.Method.IsGenericMethodDefinition)
            {
                Type[] typeArguments = GetTypeArgumentsForMethod(testMethod.Method, arglist);
                foreach (object o in typeArguments)
                    if (o == null)
                    {
                        testMethod.RunState = RunState.NotRunnable;
                        testMethod.IgnoreReason = "Unable to determine type arguments for fixture";
                        return false;
                    }

                testMethod.method = testMethod.Method.MakeGenericMethod(typeArguments);
                parameters = testMethod.Method.GetParameters();

                for (int i = 0; i < parameters.Length; i++)
                {
                    if (arglist[i].GetType() != parameters[i].ParameterType && arglist[i] is IConvertible)
                    {
                        try
                        {
                            arglist[i] = Convert.ChangeType(arglist[i], parameters[i].ParameterType);
                        }
                        catch (Exception)
                        {
                            // Do nothing - the incompatible argument will be reported below
                        }
                    }
                }
            }
#endif


            return true;
        }
        private static bool CheckTestMethodSignature(TestMethodExtension testMethod, ParameterSet parms)
        {
            if (testMethod.Method.IsAbstract)
            {
                testMethod.RunState     = RunState.NotRunnable;
                testMethod.IgnoreReason = "Method is abstract";
                return(false);
            }

            if (!testMethod.Method.IsPublic)
            {
                testMethod.RunState     = RunState.NotRunnable;
                testMethod.IgnoreReason = "Method is not public";
                return(false);
            }

            ParameterInfo[] parameters = testMethod.Method.GetParameters();
            int             argsNeeded = parameters.Length;

            object[] arglist      = null;
            int      argsProvided = 0;

            if (parms != null)
            {
                testMethod.arguments         = parms.Arguments;
                testMethod.hasExpectedResult = parms.HasExpectedResult;
                if (testMethod.hasExpectedResult)
                {
                    testMethod.expectedResult = parms.Result;
                }
                testMethod.RunState         = parms.RunState;
                testMethod.IgnoreReason     = parms.IgnoreReason;
                testMethod.BuilderException = parms.ProviderException;

                arglist = parms.Arguments;

                if (arglist != null)
                {
                    argsProvided = arglist.Length;
                }

                if (testMethod.RunState != RunState.Runnable)
                {
                    return(false);
                }
            }

#if CLR_2_0 || CLR_4_0
            bool isAsyncMethod           = Reflect.IsAsyncMethod(testMethod.Method);
            bool hasMeaningfulReturnType = isAsyncMethod ? testMethod.Method.ReturnType.IsGenericType : testMethod.Method.ReturnType != typeof(void);
#else
            bool hasMeaningfulReturnType = testMethod.Method.ReturnType != typeof(void);
#endif

            if (hasMeaningfulReturnType && (parms == null || !parms.HasExpectedResult && parms.ExpectedExceptionName == null))
            {
                return(MarkAsNotRunnable(testMethod, "Test method has non-void return type, but no result is expected"));
            }
            if (!hasMeaningfulReturnType && parms != null && parms.HasExpectedResult)
            {
                return(MarkAsNotRunnable(testMethod, "Test method has void return type, but a result is expected"));
            }

            if (argsProvided > 0 && argsNeeded == 0)
            {
                return(MarkAsNotRunnable(testMethod, "Arguments provided for method not taking any"));
            }

            if (argsProvided == 0 && argsNeeded > 0)
            {
                return(MarkAsNotRunnable(testMethod, "No arguments were provided"));
            }

            if (argsProvided != argsNeeded)
            {
                testMethod.RunState     = RunState.NotRunnable;
                testMethod.IgnoreReason = "Wrong number of arguments provided";
                return(false);
            }

#if CLR_2_0 || CLR_4_0
            if (testMethod.Method.IsGenericMethodDefinition)
            {
                Type[] typeArguments = GetTypeArgumentsForMethod(testMethod.Method, arglist);
                foreach (object o in typeArguments)
                {
                    if (o == null)
                    {
                        testMethod.RunState     = RunState.NotRunnable;
                        testMethod.IgnoreReason = "Unable to determine type arguments for fixture";
                        return(false);
                    }
                }

                testMethod.method = testMethod.Method.MakeGenericMethod(typeArguments);
                parameters        = testMethod.Method.GetParameters();

                for (int i = 0; i < parameters.Length; i++)
                {
                    if (arglist[i].GetType() != parameters[i].ParameterType && arglist[i] is IConvertible)
                    {
                        try
                        {
                            arglist[i] = Convert.ChangeType(arglist[i], parameters[i].ParameterType);
                        }
                        catch (Exception)
                        {
                            // Do nothing - the incompatible argument will be reported below
                        }
                    }
                }
            }
#endif


            return(true);
        }
        public TestMethodExtension BuildSingleTestMethod(MethodInfo method, Test parentSuite, ParameterSet parms, ScreenCapture screenCapture, IDictionary properties)
        {
            //TODO : Here it doesn't support  Async Await Method, BTW, the Async Await just be supported from .net 4.5
            TestMethodExtension testMethod = new TestMethodExtension(method, screenCapture);

            string prefix = method.ReflectedType.FullName;

            if (parentSuite != null)
            {
                testMethod.Properties = properties;
                prefix = parentSuite.TestName.FullName;
                testMethod.TestName.FullName = prefix + "." + testMethod.TestName.Name;
            }

            if (CheckTestMethodSignature(testMethod, parms))
            {
                if (parms == null)
                    NUnitFramework.ApplyCommonAttributes(method, testMethod);
                NUnitFramework.ApplyExpectedExceptionAttribute(method, testMethod);
            }

            if (parms != null)
            {
                method = testMethod.Method;

                if (parms.TestName != null)
                {
                    testMethod.TestName.Name = parms.TestName;
                    testMethod.TestName.FullName = prefix + "." + parms.TestName;
                }
                else if (parms.OriginalArguments != null)
                {
                    string name = MethodHelper.GetDisplayName(method, parms.OriginalArguments);
                    testMethod.TestName.Name = name;
                    testMethod.TestName.FullName = prefix + "." + name;
                }

                if (parms.Ignored)
                {
                    testMethod.RunState = RunState.Ignored;
                    testMethod.IgnoreReason = parms.IgnoreReason;
                }
                else if (parms.Explicit)
                {
                    testMethod.RunState = RunState.Explicit;
                }

                foreach (string key in parms.Properties.Keys)
                    testMethod.Properties[key] = parms.Properties[key];

                if (parms.Description != null)
                    testMethod.Description = parms.Description;
            }

            if (parentSuite != null)
            {
                if (parentSuite.RunState == RunState.NotRunnable && testMethod.RunState != RunState.NotRunnable)
                {
                    testMethod.RunState = RunState.NotRunnable;
                    testMethod.IgnoreReason = parentSuite.IgnoreReason;
                }

                if (parentSuite.RunState == RunState.Ignored && testMethod.RunState != RunState.Ignored && testMethod.RunState != RunState.NotRunnable)
                {
                    testMethod.RunState = RunState.Ignored;
                    testMethod.IgnoreReason = parentSuite.IgnoreReason;
                }
            }

            return testMethod;
        }
        public TestMethodExtension BuildSingleTestMethod(MethodInfo method, Test parentSuite, ParameterSet parms, ScreenCapture screenCapture, IDictionary properties)
        {
            //TODO : Here it doesn't support  Async Await Method, BTW, the Async Await just be supported from .net 4.5
            TestMethodExtension testMethod = new TestMethodExtension(method, screenCapture);

            string prefix = method.ReflectedType.FullName;

            if (parentSuite != null)
            {
                testMethod.Properties = properties;
                prefix = parentSuite.TestName.FullName;
                testMethod.TestName.FullName = prefix + "." + testMethod.TestName.Name;
            }

            if (CheckTestMethodSignature(testMethod, parms))
            {
                if (parms == null)
                {
                    NUnitFramework.ApplyCommonAttributes(method, testMethod);
                }
                NUnitFramework.ApplyExpectedExceptionAttribute(method, testMethod);
            }

            if (parms != null)
            {
                method = testMethod.Method;

                if (parms.TestName != null)
                {
                    testMethod.TestName.Name     = parms.TestName;
                    testMethod.TestName.FullName = prefix + "." + parms.TestName;
                }
                else if (parms.OriginalArguments != null)
                {
                    string name = MethodHelper.GetDisplayName(method, parms.OriginalArguments);
                    testMethod.TestName.Name     = name;
                    testMethod.TestName.FullName = prefix + "." + name;
                }

                if (parms.Ignored)
                {
                    testMethod.RunState     = RunState.Ignored;
                    testMethod.IgnoreReason = parms.IgnoreReason;
                }
                else if (parms.Explicit)
                {
                    testMethod.RunState = RunState.Explicit;
                }

                foreach (string key in parms.Properties.Keys)
                {
                    testMethod.Properties[key] = parms.Properties[key];
                }

                if (parms.Description != null)
                {
                    testMethod.Description = parms.Description;
                }
            }

            if (parentSuite != null)
            {
                if (parentSuite.RunState == RunState.NotRunnable && testMethod.RunState != RunState.NotRunnable)
                {
                    testMethod.RunState     = RunState.NotRunnable;
                    testMethod.IgnoreReason = parentSuite.IgnoreReason;
                }

                if (parentSuite.RunState == RunState.Ignored && testMethod.RunState != RunState.Ignored && testMethod.RunState != RunState.NotRunnable)
                {
                    testMethod.RunState     = RunState.Ignored;
                    testMethod.IgnoreReason = parentSuite.IgnoreReason;
                }
            }

            return(testMethod);
        }