예제 #1
0
        //private static TestMethod CreateMethod(TypeInfo type, object instance, MethodInfo method)
        private static TestMethod CreateMethod(Type type, object instance, MethodInfo method)
        {
            TestMethod test = new TestMethod();
            test.Name = method.Name;

            if (method.GetCustomAttribute<AsyncTestMethodAttribute>(true) != null)
            {
                test.Test = new AsyncTestMethodAsyncAction(instance, method);                
            }
            else
            {
                test.Test = new TestMethodAsyncAction(instance, method);
            }

            ExcludeTestAttribute excluded = method.GetCustomAttribute<ExcludeTestAttribute>(true);
            if (excluded != null)
            {
                test.Exclude(excluded.Reason);
            }

            if (method.GetCustomAttribute<FunctionalTestAttribute>(true) != null)
            {
                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>(true))
            {
                test.Tags.Add(attr.Tag);
            }

            return test;
        }
예제 #2
0
        /// <summary>
        /// Reflect, read and prepare the tags for the method metadata.
        /// Performs the work if this is the first time the metadata has been
        /// seen.
        /// </summary>
        /// <param name="method">The method metadata.</param>
        private void CreateMethodTags(TestMethod method)
        {
            // 1. All the tags from the group
            Tags tags = new Tags(_groupTags);

            // 2. Method.Name
            tags.AddTag(method.Name);

            // 3. Type.FullName + Method.Name
            //tags.AddTag(m.ReflectedType.FullName + "." + method.Name);

            // 4. Type.Name + Method.Name
            //tags.AddTag(method.ReflectedType.Name + "." + method.Name);
            
            // 5. Implicit Inherited tag
            //if (method.ReflectedType != method.DeclaringType)
            //{
            //    tags.AddTag("Inherited");
            //}

            // 6. All [Tag] attributes on the method
            foreach (string tag in method.Tags)
            {
                tags.AddTag(tag);
            }

            // 7. Add priority as a tag
            //if (method.Priority != null)
            //{
            //    tags.AddTag(PriorityTagPrefix + method.Priority.ToString());
            //}

            _methodTags.Add(method, tags);

            // Populate the inverted index
            foreach (string tag in tags)
            {
                List<TestMethod> methods;
                if (!_tagsToMethods.TryGetValue(tag, out methods))
                {
                    methods = new List<TestMethod>();
                    _tagsToMethods[tag] = methods;
                }
                methods.Add(method);
            }
        }
예제 #3
0
 public void EndTest(TestMethod method)
 {
     Dispatcher.BeginInvoke(() =>
     {
         if (method.Excluded)
         {
             _currentTest.Color = Color.FromArgb(0xFF, 0x66, 0x66, 0x66);
         }
         else if (!method.Passed)
         {
             _currentTest.Color = Color.FromArgb(0xFF, 0xFF, 0x00, 0x6E);
         }
         else
         {
             _currentTest.Color = Color.FromArgb(0xFF, 0x2A, 0x9E, 0x39);
         }
         _currentTest = null;
     });
 }
예제 #4
0
        public void StartTest(TestMethod test)
        {
            Dispatcher.BeginInvoke(() =>
            {
                TestDescription testDescription = new TestDescription { Name = test.Name };
                _currentTest = testDescription;
                _currentGroup.Add(_currentTest);

                Dispatcher.BeginInvoke(() =>
                {
                    lstTests.ScrollTo(testDescription);
                });
            });
        }