private static TestMethod CreateMethod(TypeInfo 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;
        }
 public async void EndTest(TestMethod method)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         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;
     });
 }
        public async void StartTest(TestMethod test)
        {
            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
            {
                _currentTest = new TestDescription { Name = test.Name };
                _currentGroup.Tests.Add(_currentTest);

                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    lstTests.ScrollIntoView(_currentTest);
                });
            });
        }
Exemplo n.º 4
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);
            }
        }