public static ServiceProvider CreateTestServices( IServiceProvider applicationServices, Project project, ReportingChannel channel) { var services = new ServiceProvider(applicationServices); var loggerFactory = new LoggerFactory(); loggerFactory.AddProvider(new TestHostLoggerProvider(channel)); services.Add(typeof(ILoggerFactory), loggerFactory); var libraryExporter = applicationServices.GetRequiredService<ILibraryExporter>(); var export = libraryExporter.GetExport(project.Name); var projectReference = export.MetadataReferences .OfType<IMetadataProjectReference>() .Where(r => r.Name == project.Name) .FirstOrDefault(); services.Add( typeof(ISourceInformationProvider), new SourceInformationProvider(projectReference, loggerFactory.CreateLogger<SourceInformationProvider>())); services.Add(typeof(ITestDiscoverySink), new TestDiscoverySink(channel)); services.Add(typeof(ITestExecutionSink), new TestExecutionSink(channel)); return services; }
public TestDiscoverySink(ReportingChannel channel) { _channel = channel; }
public TestHostLoggerProvider(ReportingChannel channel) { _channel = channel; }
public TestHostLogger(string name, ReportingChannel channel) { _name = name; _channel = channel; }
public TestExecutionSink(ReportingChannel channel) { _channel = channel; }