예제 #1
0
        private void AddAll(Type testCaseType)
        {
            var methods = testCaseType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            foreach (MethodInfo m in methods)
            {
                var attributes = m.GetCustomAttributes(typeof(UUnitTestAttribute), false);
                if (attributes.Length > 0)
                {
                    ConstructorInfo constructor = testCaseType.GetConstructors()[0];
                    UUnitTestCase   newTestCase = (UUnitTestCase)constructor.Invoke(null);
                    newTestCase.SetTest(m.Name);
                    Add(newTestCase);
                }
            }
        }
예제 #2
0
 private void AddAll(TypeInfo testCaseType)
 {
     foreach (MethodInfo m in testCaseType.DeclaredMethods)
     {
         var attributes = m.GetCustomAttributes(typeof(UUnitTestAttribute), false);
         foreach (var attr in attributes)
         {
             var constructors = testCaseType.DeclaredConstructors;
             foreach (var constructor in constructors)
             {
                 UUnitTestCase newTestCase = (UUnitTestCase)constructor.Invoke(null);
                 newTestCase.SetTest(m.Name);
                 Add(newTestCase);
                 break; // We only want 1 constructor, if relevant
             }
             break;     // We only want 1 attribute, if relevant
         }
     }
 }