Exemple #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="diagnosticMessageSink"></param>
 /// <param name="id">Unique identifier of the communication channel between the two processes</param>
 /// <param name="exePath">Location of the remote process</param>
 /// <param name="defaultTestCaseDiscoverer"></param>
 /// <param name="testCaseConverter"></param>
 protected XUnitRemoteTestCaseDiscoverer(IMessageSink diagnosticMessageSink, string id, string exePath, IXunitTestCaseDiscoverer defaultTestCaseDiscoverer, Func <IXunitTestCase, IXunitTestCase> testCaseConverter, Guid?collectionId)
 {
     CollectionId           = collectionId;
     _DiagnosticMessageSink = diagnosticMessageSink;
     _Id      = id;
     _ExePath = exePath;
     _DefaultTestCaseDiscoverer = defaultTestCaseDiscoverer;
     _TestCaseConverter         = testCaseConverter;
 }
        private bool FindTestsForMethodOnAutofacTestClass(ITestMethod testMethod,
                                                          bool includeSourceInformation,
                                                          IMessageBus messageBus,
                                                          ITestFrameworkDiscoveryOptions discoveryOptions)
        {
            var factAttributes = testMethod.Method.GetCustomAttributes(typeof(FactAttribute)).ToList();

            if (factAttributes.Count > 1)
            {
                var message  = $"Test method '{testMethod.TestClass.Class.Name}.{testMethod.Method.Name}' has multiple [Fact]-derived attributes";
                var testCase = new ExecutionErrorTestCase(DiagnosticMessageSink, TestMethodDisplay.ClassAndMethod, TestMethodDisplayOptions.All, testMethod, message);
                return(ReportDiscoveredTestCase(testCase, includeSourceInformation, messageBus));
            }

            var factAttribute = factAttributes.FirstOrDefault();

            if (factAttribute == null)
            {
                return(true);
            }

            var factAttributeType = (factAttribute as IReflectionAttributeInfo)?.Attribute.GetType();

            IXunitTestCaseDiscoverer discoverer = null;

            if (factAttributeType == typeof(FactAttribute))
            {
                discoverer = _autofacFactDiscoverer;
            }
            else if (factAttributeType == typeof(TheoryAttribute))
            {
                discoverer = _autofacTheoryDiscoverer;
            }

            if (discoverer == null)
            {
                return(true);
            }

            foreach (var testCase in discoverer.Discover(discoveryOptions, testMethod, factAttribute))
            {
                if (!ReportDiscoveredTestCase(testCase, includeSourceInformation, messageBus))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #3
0
 public ExtendedDiscoverer(IXunitTestCaseDiscoverer inner)
 {
     this.inner = inner;
     this.DiagnosticMessageSink = new NullMessageSink();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DiscovererWrapper"/> class.
 /// </summary>
 /// <param name="discoverer">The discoverer used to discover test cases</param>
 /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param>
 protected DiscovererWrapper(IXunitTestCaseDiscoverer discoverer, IMessageSink diagnosticMessageSink)
 {
     this.discoverer_            = discoverer;
     this.diagnosticMessageSink_ = diagnosticMessageSink;
 }