public void TestInit() { this.mockTestPlatformEventSource = new Mock <ITestPlatformEventSource>(); this.discoveryResultCache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { }); this.discovererEnumerator = new DiscovererEnumerator(this.discoveryResultCache, this.mockTestPlatformEventSource.Object); TestDiscoveryExtensionManager.Destroy(); }
public void TestInit() { this.mockTestPlatformEventSource = new Mock <ITestPlatformEventSource>(); this.discoveryResultCache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { }); this.mockRequestData = new Mock <IRequestData>(); this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection()); this.discovererEnumerator = new DiscovererEnumerator(this.mockRequestData.Object, this.discoveryResultCache, this.mockTestPlatformEventSource.Object); TestDiscoveryExtensionManager.Destroy(); }
public DiscovererEnumeratorTests() { this.mockTestPlatformEventSource = new Mock <ITestPlatformEventSource>(); this.discoveryResultCache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { }); this.mockRequestData = new Mock <IRequestData>(); this.mockMetricsCollection = new Mock <IMetricsCollection>(); this.mockAssemblyProperties = new Mock <IAssemblyProperties>(); this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object); this.discovererEnumerator = new DiscovererEnumerator(this.mockRequestData.Object, this.discoveryResultCache, this.mockTestPlatformEventSource.Object, this.mockAssemblyProperties.Object, this.cancellationTokenSource.Token); this.runSettingsMock = new Mock <IRunSettings>(); this.messageLoggerMock = new Mock <IMessageLogger>(); TestPluginCacheTests.SetupMockExtensions(new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, () => { }); TestDiscoveryExtensionManager.Destroy(); }
/// <summary> /// Returns executor Vs sources list /// </summary> private Dictionary <Tuple <Uri, string>, IEnumerable <string> > GetExecutorVsSourcesList(IMessageLogger logger) { var result = new Dictionary <Tuple <Uri, string>, IEnumerable <string> >(); var verifiedExtensionSourceMap = new Dictionary <string, IEnumerable <string> >(); // Validate the sources foreach (var kvp in this.adapterSourceMap) { var verifiedSources = DiscoveryManager.GetValidSources(kvp.Value, logger); if (verifiedSources.Any()) { verifiedExtensionSourceMap.Add(kvp.Key, kvp.Value); } } // No valid source is found => no executor vs source map if (!verifiedExtensionSourceMap.Any()) { return(result); } foreach (var kvp in verifiedExtensionSourceMap) { Dictionary <LazyExtension <ITestDiscoverer, ITestDiscovererCapabilities>, IEnumerable <string> > discovererToSourcesMap = DiscovererEnumerator.GetDiscovererToSourcesMap( kvp.Key, kvp.Value, logger); // Warning is logged by the inner layer if (discovererToSourcesMap == null || discovererToSourcesMap.Count == 0) { continue; } foreach (var discoverer in discovererToSourcesMap.Keys) { var executorUri = discoverer.Metadata.DefaultExecutorUri; if (executorUri == null) { string errorMessage = string.Format( CultureInfo.CurrentUICulture, CrossPlatEngineResources.IgnoringExecutorAsNoDefaultExecutorUriAttribute, discoverer.Value); logger.SendMessage(TestMessageLevel.Warning, errorMessage); continue; } var executorUriExtensionTuple = new Tuple <Uri, string>(executorUri, kvp.Key); if (!result.ContainsKey(executorUriExtensionTuple)) { result.Add(executorUriExtensionTuple, discovererToSourcesMap[discoverer]); } else { string errorMessage = string.Format( CultureInfo.CurrentUICulture, CrossPlatEngineResources.DuplicateAdaptersFound, executorUri, discoverer.Value); logger.SendMessage(TestMessageLevel.Warning, errorMessage); } } } return(result); }