コード例 #1
0
        /// <summary>
        /// Determine if the method is an NUnit test method.
        /// The method must normally be marked with the test
        /// attribute for this to be true. If the test config
        /// file sets AllowOldStyleTests to true, then any
        /// method beginning "test..." (case-insensitive)
        /// is treated as a test unless it is also marked
        /// as a setup or teardown method.
        /// </summary>
        /// <param name="method">A MethodInfo for the method being used as a test method</param>
        /// <returns>True if the builder can create a test case from this method</returns>
        public override bool CanBuildFrom(MethodInfo method)
        {
            if (Reflect.HasAttribute(method, NUnitFramework.TestAttribute, false))
            {
                return(true);
            }

            if (allowOldStyleTests)
            {
                Regex regex = new Regex("^(?i:test)");
                if (regex.Match(method.Name).Success &&
                    !NUnitFramework.IsSetUpMethod(method) &&
                    !NUnitFramework.IsTearDownMethod(method) &&
                    !NUnitFramework.IsFixtureSetUpMethod(method) &&
                    !NUnitFramework.IsFixtureTearDownMethod(method))
                {
                    return(true);
                }
            }

            return(false);
        }