void Find(Predicate <ITestCaseDiscoveryMessage> filter, bool includeSourceInformation, IMessageSink messageSink) { try { XmlNode assemblyXml = null; using (var handler = new XmlNodeCallbackHandler(xml => { assemblyXml = xml; return(true); })) executor.EnumerateTests(handler); foreach (XmlNode method in assemblyXml.SelectNodes("//method")) { var testCase = method.ToTestCase(assemblyFileName); if (testCase != null) { if (includeSourceInformation) { testCase.SourceInformation = sourceInformationProvider.GetSourceInformation(testCase); } testCase.TestCollection = testCollection; var message = new TestCaseDiscoveryMessage(testCase); if (filter(message)) { messageSink.OnMessage(message); } } } } finally { messageSink.OnMessage(new DiscoveryCompleteMessage(new string[0])); } }
private ITestCase UpdateTestCaseWithSourceInfo(XunitTestCase testCase, bool includeSourceInformation) { if (includeSourceInformation && sourceProvider != null) { testCase.SourceInformation = sourceProvider.GetSourceInformation(testCase); } return(testCase); }
public SourceInformation GetSourceData(string className, string methodName) { var type = _assembly.DefinedTypes.FirstOrDefault(t => t.FullName == className); var method = type?.DeclaredMethods.FirstOrDefault(m => m.Name == methodName); if (method == null) { return(null); } return(_provider.GetSourceInformation(method)); }