protected override bool FindTestsForType(ITestClass testClass, bool includeSourceInformation, IMessageBus messageBus, ITestFrameworkDiscoveryOptions discoveryOptions)
        {
            var methodDisplay = discoveryOptions.MethodDisplayOrDefault();

            var hasAttribute = testClass.Class.GetCustomAttributes(typeof(UseAutofacTestFrameworkAttribute)).Any();

            if (!hasAttribute)
            {
                return(true);
            }

            foreach (var method in testClass.Class.GetMethods(includePrivateMethods: true))
            {
                if (!method.GetCustomAttributes(typeof(FactAttribute)).Any())
                {
                    continue;
                }

                var testMethod = new TestMethod(testClass, method);
                var testCase   = new AutofacTestCase(methodDisplay, testMethod);

                if (!ReportDiscoveredTestCase(testCase, includeSourceInformation, messageBus))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
 public AutofacTest(AutofacTestCase testCase, string displayName)
 {
     TestCase    = testCase;
     DisplayName = displayName;
 }