コード例 #1
0
ファイル: TestServices.cs プロジェクト: krwq/Testing
        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;
        }
コード例 #2
0
ファイル: TestDiscoverySink.cs プロジェクト: krwq/Testing
 public TestDiscoverySink(ReportingChannel channel)
 {
     _channel = channel;
 }
コード例 #3
0
 public TestHostLoggerProvider(ReportingChannel channel)
 {
     _channel = channel;
 }
コード例 #4
0
 public TestHostLogger(string name, ReportingChannel channel)
 {
     _name = name;
     _channel = channel;
 }
コード例 #5
0
ファイル: TestExecutionSink.cs プロジェクト: krwq/Testing
 public TestExecutionSink(ReportingChannel channel)
 {
     _channel = channel;
 }