private static TestMethod CreateMethod(Type type, object instance, MethodInfo method)
        {
            TestMethod test = new TestMethod()
            {
                Name = method.Name
            };

            if (method.GetCustomAttributes <AsyncTestMethodAttribute>().Any())
            {
                test.Test = new AsyncTestMethodAsyncAction(instance, method);
            }
            else
            {
                test.Test = new TestMethodAsyncAction(instance, method);
            }

            ExcludeTestAttribute excluded = method.GetCustomAttribute <ExcludeTestAttribute>();

            if (excluded != null)
            {
                test.Exclude(excluded.Reason);
            }

            if (method.GetCustomAttributes <FunctionalTestAttribute>().Any())
            {
                test.Tags.Add("Functional");
            }

            test.Tags.Add(type.FullName + "." + method.Name);
            test.Tags.Add(type.Name + "." + method.Name);
            foreach (TagAttribute attr in method.GetCustomAttributes <TagAttribute>())
            {
                test.Tags.Add(attr.Tag);
            }

            return(test);
        }
예제 #2
0
        private static TestMethod CreateMethod(Type type, object instance, MethodInfo method)
        {
            TestMethod test = new TestMethod();

            test.Name = method.Name;

            if (method.GetCustomAttributes(true).Where(a => a.GetType() == typeof(AsyncTestMethodAttribute)).Any())
            {
                test.Test = new AsyncTestMethodAsyncAction(instance, method);
            }
            else
            {
                test.Test = new TestMethodAsyncAction(instance, method);
            }

            ExcludeTestAttribute excluded = (ExcludeTestAttribute)method.GetCustomAttributes(true).Where(a => a.GetType() == typeof(ExcludeTestAttribute)).FirstOrDefault();

            if (excluded != null)
            {
                test.Exclude(excluded.Reason);
            }

            if (method.GetCustomAttributes(true).Where(a => a.GetType() == typeof(FunctionalTestAttribute)).Any())
            {
                test.Tags.Add("Functional");
            }

            test.Tags.Add(type.FullName + "." + method.Name);
            test.Tags.Add(type.Name + "." + method.Name);
            foreach (TagAttribute attr in method.GetCustomAttributes(true).Where(a => a.GetType() == typeof(TagAttribute)))
            {
                test.Tags.Add(attr.Tag);
            }

            return(test);
        }