5 implementations of Services
Aspire.Hosting (1)
DistributedApplication.cs (1)
205public IServiceProvider Services => _host.Services;
Microsoft.AspNetCore (1)
WebApplication.cs (1)
44public IServiceProvider Services => _host.Services;
Microsoft.AspNetCore.Mvc.Testing (1)
DeferredHostBuilder.cs (1)
129public IServiceProvider Services => _host.Services;
Microsoft.Extensions.Hosting (1)
Internal\Host.cs (1)
61public IServiceProvider Services { get; }
Microsoft.Extensions.Hosting.Testing (1)
FakeHost.cs (1)
19public IServiceProvider Services => _host.Services;
627 references to Services
Aspire.Azure.AI.OpenAI.Tests (25)
AspireAzureAIOpenAIExtensionsTests.cs (12)
45host.Services.GetRequiredKeyedService<AzureOpenAIClient>("openai") : 46host.Services.GetRequiredService<AzureOpenAIClient>(); 49host.Services.GetRequiredKeyedService<OpenAIClient>("openai") : 50host.Services.GetRequiredService<OpenAIClient>(); 76host.Services.GetRequiredKeyedService<AzureOpenAIClient>("openai") : 77host.Services.GetRequiredService<AzureOpenAIClient>(); 102host.Services.GetRequiredKeyedService<AzureOpenAIClient>("openai") : 103host.Services.GetRequiredService<AzureOpenAIClient>(); 123var client = host.Services.GetRequiredService<AzureOpenAIClient>(); 146var client2 = host.Services.GetRequiredKeyedService<AzureOpenAIClient>("openai2"); 147var client3 = host.Services.GetRequiredKeyedService<AzureOpenAIClient>("openai3"); 191var options = host.Services.GetRequiredService<IOptionsMonitor<AzureOpenAIClientOptions>>().Get(useKeyed ? "openai" : "Default");
AspireConfigurableOpenAIExtensionsTests.cs (13)
59host.Services.GetRequiredKeyedService<OpenAIClient>("openai") : 60host.Services.GetRequiredService<OpenAIClient>(); 86host.Services.GetRequiredKeyedService<OpenAIClient>("openai") : 87host.Services.GetRequiredService<OpenAIClient>(); 113host.Services.GetRequiredKeyedService<OpenAIClient>("openai") : 114host.Services.GetRequiredService<OpenAIClient>(); 133var openAiClient = host.Services.GetRequiredService<OpenAIClient>(); 159host.Services.GetRequiredKeyedService<OpenAIClient>("openai") : 160host.Services.GetRequiredService<OpenAIClient>(); 186host.Services.GetRequiredKeyedService<OpenAIClient>("openai") : 187host.Services.GetRequiredService<OpenAIClient>(); 213host.Services.GetRequiredKeyedService<OpenAIClient>("openai") : 214host.Services.GetRequiredService<OpenAIClient>();
Aspire.Azure.Data.Tables.Tests (10)
AspireTablesExtensionsTests.cs (10)
37host.Services.GetRequiredKeyedService<TableServiceClient>("tables") : 38host.Services.GetRequiredService<TableServiceClient>(); 64host.Services.GetRequiredKeyedService<TableServiceClient>("tables") : 65host.Services.GetRequiredService<TableServiceClient>(); 94host.Services.GetRequiredKeyedService<TableServiceClient>("tables") : 95host.Services.GetRequiredService<TableServiceClient>(); 122host.Services.GetRequiredKeyedService<TableServiceClient>("tables") : 123host.Services.GetRequiredService<TableServiceClient>(); 146var client2 = host.Services.GetRequiredKeyedService<TableServiceClient>("tables2"); 147var client3 = host.Services.GetRequiredKeyedService<TableServiceClient>("tables3");
Aspire.Azure.Messaging.EventHubs.Tests (2)
AspireEventHubsExtensionsTests.cs (2)
465host.Services.GetRequiredKeyedService(s_clientTypes[clientIndex], key) : 466host.Services.GetRequiredService(s_clientTypes[clientIndex]);
Aspire.Azure.Messaging.ServiceBus.Tests (11)
AspireServiceBusExtensionsTests.cs (11)
37host.Services.GetRequiredKeyedService<ServiceBusClient>("sb") : 38host.Services.GetRequiredService<ServiceBusClient>(); 64host.Services.GetRequiredKeyedService<ServiceBusClient>("sb") : 65host.Services.GetRequiredService<ServiceBusClient>(); 94host.Services.GetRequiredKeyedService<ServiceBusClient>("sb") : 95host.Services.GetRequiredService<ServiceBusClient>(); 122host.Services.GetRequiredKeyedService<ServiceBusClient>("sb") : 123host.Services.GetRequiredService<ServiceBusClient>(); 146var client2 = host.Services.GetRequiredKeyedService<ServiceBusClient>("sb2"); 147var client3 = host.Services.GetRequiredKeyedService<ServiceBusClient>("sb3"); 173var client = host.Services.GetRequiredService<ServiceBusClient>();
Aspire.Azure.Messaging.WebPubSub.Tests (12)
AspireWebPubSubExtensionsTests.cs (12)
38host.Services.GetRequiredKeyedService<WebPubSubServiceClient>("wps") : 39host.Services.GetRequiredService<WebPubSubServiceClient>(); 73host.Services.GetRequiredKeyedService<WebPubSubServiceClient>("wps") : 74host.Services.GetRequiredService<WebPubSubServiceClient>(); 104host.Services.GetRequiredKeyedService<WebPubSubServiceClient>("wps") : 105host.Services.GetRequiredService<WebPubSubServiceClient>(); 133host.Services.GetRequiredKeyedService<WebPubSubServiceClient>("wps") : 134host.Services.GetRequiredService<WebPubSubServiceClient>(); 151var ex = Assert.Throws<InvalidOperationException>(host.Services.GetRequiredService<WebPubSubServiceClient>); 176var client = host.Services.GetRequiredKeyedService<WebPubSubServiceClient>("key"); 195var client1 = host.Services.GetRequiredKeyedService<WebPubSubServiceClient>("hub1"); 198var client2 = host.Services.GetRequiredKeyedService<WebPubSubServiceClient>("hub2");
Aspire.Azure.Search.Documents.Tests (6)
AspireAzureSearchExtensionsTests.cs (6)
38host.Services.GetRequiredKeyedService<SearchIndexClient>("search") : 39host.Services.GetRequiredService<SearchIndexClient>(); 65host.Services.GetRequiredKeyedService<SearchIndexClient>("search") : 66host.Services.GetRequiredService<SearchIndexClient>(); 90var client2 = host.Services.GetRequiredKeyedService<SearchIndexClient>("search2"); 91var client3 = host.Services.GetRequiredKeyedService<SearchIndexClient>("search3");
Aspire.Azure.Security.KeyVault.Tests (6)
AspireKeyVaultExtensionsTests.cs (6)
40host.Services.GetRequiredKeyedService<SecretClient>("secrets") : 41host.Services.GetRequiredService<SecretClient>(); 70host.Services.GetRequiredKeyedService<SecretClient>("secrets") : 71host.Services.GetRequiredService<SecretClient>(); 193var client2 = host.Services.GetRequiredKeyedService<SecretClient>("secrets2"); 194var client3 = host.Services.GetRequiredKeyedService<SecretClient>("secrets3");
Aspire.Azure.Storage.Blobs.Tests (10)
AspireBlobStorageExtensionsTests.cs (10)
37host.Services.GetRequiredKeyedService<BlobServiceClient>("blob") : 38host.Services.GetRequiredService<BlobServiceClient>(); 64host.Services.GetRequiredKeyedService<BlobServiceClient>("blob") : 65host.Services.GetRequiredService<BlobServiceClient>(); 94host.Services.GetRequiredKeyedService<BlobServiceClient>("blob") : 95host.Services.GetRequiredService<BlobServiceClient>(); 122host.Services.GetRequiredKeyedService<BlobServiceClient>("blob") : 123host.Services.GetRequiredService<BlobServiceClient>(); 146var client2 = host.Services.GetRequiredKeyedService<BlobServiceClient>("blob2"); 147var client3 = host.Services.GetRequiredKeyedService<BlobServiceClient>("blob3");
Aspire.Azure.Storage.Queues.Tests (10)
AspireQueueStorageExtensionsTests.cs (10)
37host.Services.GetRequiredKeyedService<QueueServiceClient>("queue") : 38host.Services.GetRequiredService<QueueServiceClient>(); 64host.Services.GetRequiredKeyedService<QueueServiceClient>("queue") : 65host.Services.GetRequiredService<QueueServiceClient>(); 94host.Services.GetRequiredKeyedService<QueueServiceClient>("queue") : 95host.Services.GetRequiredService<QueueServiceClient>(); 122host.Services.GetRequiredKeyedService<QueueServiceClient>("queue") : 123host.Services.GetRequiredService<QueueServiceClient>(); 146var client2 = host.Services.GetRequiredKeyedService<QueueServiceClient>("queue2"); 147var client3 = host.Services.GetRequiredKeyedService<QueueServiceClient>("queue3");
Aspire.Components.Common.Tests (21)
ConformanceTests.cs (21)
108HealthCheckService? healthCheckService = host.Services.GetService<HealthCheckService>(); 123HealthCheckService healthCheckService = host.Services.GetRequiredService<HealthCheckService>(); 146TracerProvider? tracer = host.Services.GetService<TracerProvider>(); 160MeterProvider? meter = host.Services.GetService<MeterProvider>(); 178using (IServiceScope scope1 = host.Services.CreateScope()) 183using (IServiceScope scope2 = host.Services.CreateScope()) 226TService serviceForKey1 = host.Services.GetRequiredKeyedService<TService>(key1); 227TService serviceForKey2 = host.Services.GetRequiredKeyedService<TService>(key2); 247Assert.NotNull(host.Services.GetKeyedService<TService>(key)); 248Assert.Null(host.Services.GetService<TService>()); 249Assert.Throws<InvalidOperationException>(host.Services.GetRequiredService<TService>); 280? host.Services.GetRequiredService<TService>() 281: host.Services.GetRequiredKeyedService<TService>(key); 282TestLoggerFactory loggerFactory = (TestLoggerFactory)host.Services.GetRequiredService<ILoggerFactory>(); 311HealthCheckService healthCheckService = host.Services.GetRequiredService<HealthCheckService>(); 369? host.Services.GetRequiredService<TService>() 370: host.Services.GetRequiredKeyedService<TService>(key)); 392Assert.Null(host.Services.GetService<TracerProvider>()); 414Assert.Null(host.Services.GetService<HealthCheckService>()); 439? host.Services.GetRequiredService<TService>() 440: host.Services.GetRequiredKeyedService<TService>(key);
Aspire.Confluent.Kafka.Tests (28)
ConsumerConfigurationTests.cs (9)
39? host.Services.GetRequiredKeyedService(ReflectionHelpers.ConsumerConnectionFactoryStringKeyStringValueType.Value, "messaging") 40: host.Services.GetRequiredService(ReflectionHelpers.ConsumerConnectionFactoryStringKeyStringValueType.Value); 72? host.Services.GetRequiredKeyedService(ReflectionHelpers.ConsumerConnectionFactoryStringKeyStringValueType.Value, "messaging") 73: host.Services.GetRequiredService(ReflectionHelpers.ConsumerConnectionFactoryStringKeyStringValueType.Value); 105? host.Services.GetRequiredKeyedService(ReflectionHelpers.ConsumerConnectionFactoryStringKeyStringValueType.Value, "messaging") 106: host.Services.GetRequiredService(ReflectionHelpers.ConsumerConnectionFactoryStringKeyStringValueType.Value); 184? host.Services.GetRequiredKeyedService(ReflectionHelpers.ConsumerConnectionFactoryStringKeyStringValueType.Value, "messaging") 185: host.Services.GetRequiredService(ReflectionHelpers.ConsumerConnectionFactoryStringKeyStringValueType.Value); 253var connectionFactory = host.Services.GetRequiredService(ReflectionHelpers.ConsumerConnectionFactoryStringKeyStringValueType.Value);
ConsumerConformanceTests.cs (3)
109var client1 = host.Services.GetRequiredService<IConsumer<string, string>>(); 110var client2 = host.Services.GetRequiredKeyedService<IConsumer<string, string>>("messaging2"); 111var client3 = host.Services.GetRequiredKeyedService<IConsumer<string, string>>("messaging3");
MetricsTests.cs (4)
44object metricsChannel = host.Services.GetRequiredService(ReflectionHelpers.MetricsChannelType.Value!); 46IMeterFactory meterFactory = host.Services.GetRequiredService<IMeterFactory>(); 161object metricsChannel = host.Services.GetRequiredService(ReflectionHelpers.MetricsChannelType.Value!); 163IMeterFactory meterFactory = host.Services.GetRequiredService<IMeterFactory>();
ProducerConfigurationTests.cs (9)
36host.Services.GetRequiredKeyedService(ReflectionHelpers.ProducerConnectionFactoryStringKeyStringValueType.Value, "messaging") : 37host.Services.GetRequiredService(ReflectionHelpers.ProducerConnectionFactoryStringKeyStringValueType.Value); 66host.Services.GetRequiredKeyedService(ReflectionHelpers.ProducerConnectionFactoryStringKeyStringValueType.Value, "messaging") : 67host.Services.GetRequiredService(ReflectionHelpers.ProducerConnectionFactoryStringKeyStringValueType.Value); 98host.Services.GetRequiredKeyedService(ReflectionHelpers.ProducerConnectionFactoryStringKeyStringValueType.Value, "messaging") : 99host.Services.GetRequiredService(ReflectionHelpers.ProducerConnectionFactoryStringKeyStringValueType.Value); 174host.Services.GetRequiredKeyedService(ReflectionHelpers.ProducerConnectionFactoryStringKeyStringValueType.Value, "messaging") : 175host.Services.GetRequiredService(ReflectionHelpers.ProducerConnectionFactoryStringKeyStringValueType.Value); 242var connectionFactory = host.Services.GetRequiredService(ReflectionHelpers.ProducerConnectionFactoryStringKeyStringValueType.Value);
ProducerConformanceTests.cs (3)
100var client1 = host.Services.GetRequiredService<IProducer<string, string>>(); 101var client2 = host.Services.GetRequiredKeyedService<IProducer<string, string>>("messaging2"); 102var client3 = host.Services.GetRequiredKeyedService<IProducer<string, string>>("messaging3");
Aspire.Elastic.Clients.Elasticsearch.Tests (8)
AspireElasticClientExtensionsTest.cs (8)
57var healthCheckService = host.Services.GetRequiredService<HealthCheckService>(); 90var healthCheckService = host.Services.GetService<HealthCheckService>(); 111var client1 = host.Services.GetRequiredService<ElasticsearchClient>(); 112var client2 = host.Services.GetRequiredKeyedService<ElasticsearchClient>("elasticsearch2"); 113var client3 = host.Services.GetRequiredKeyedService<ElasticsearchClient>("elasticsearch3"); 135var client1 = host.Services.GetRequiredService<ElasticsearchClient>(); 136var client2 = host.Services.GetRequiredKeyedService<ElasticsearchClient>("elasticsearch2"); 157var elasticsearchClient = host.Services.GetRequiredService<ElasticsearchClient>();
Aspire.Hosting (6)
DistributedApplication.cs (6)
205public IServiceProvider Services => _host.Services; 349var beforeStartEvent = new BeforeStartEvent(_host.Services, _host.Services.GetRequiredService<DistributedApplicationModel>()); 350var eventing = _host.Services.GetRequiredService<IDistributedApplicationEventing>(); 353var lifecycleHooks = _host.Services.GetServices<IDistributedApplicationLifecycleHook>(); 354var appModel = _host.Services.GetRequiredService<DistributedApplicationModel>();
Aspire.Hosting.Azure.Tests (7)
AzureCosmosDBEmulatorFunctionalTests.cs (4)
103using var cosmosClient = host.Services.GetRequiredService<CosmosClient>(); 104using var dbContext = host.Services.GetRequiredService<EFCoreCosmosDbContext>(); 179using var cosmosClient = host.Services.GetRequiredService<CosmosClient>(); 225using var cosmosClient = host.Services.GetRequiredService<CosmosClient>();
AzureEventHubsExtensionsTests.cs (2)
85var producerClient = host.Services.GetRequiredService<EventHubProducerClient>(); 86var consumerClient = host.Services.GetRequiredService<EventHubConsumerClient>();
AzureStorageEmulatorFunctionalTests.cs (1)
84var serviceClient = host.Services.GetRequiredService<BlobServiceClient>();
Aspire.Hosting.Elasticsearch.Tests (3)
ElasticsearchFunctionalTests.cs (3)
59var elasticsearchClient = host.Services.GetRequiredService<ElasticsearchClient>(); 121var elasticsearchClient = host.Services.GetRequiredService<ElasticsearchClient>(); 165var elasticsearchClient = host.Services.GetRequiredService<ElasticsearchClient>();
Aspire.Hosting.Garnet.Tests (3)
GarnetFunctionalTests.cs (3)
86var redisClient = host.Services.GetRequiredService<IConnectionMultiplexer>(); 167var redisClient = host.Services.GetRequiredService<IConnectionMultiplexer>(); 218var redisClient = host.Services.GetRequiredService<IConnectionMultiplexer>();
Aspire.Hosting.Kafka.Tests (4)
KafkaFunctionalTests.cs (4)
96var producer = host.Services.GetRequiredService<IProducer<string, string>>(); 103var consumer = host.Services.GetRequiredService<IConsumer<string, string>>(); 182var producer = host.Services.GetRequiredService<IProducer<string, string>>(); 238var consumer = host.Services.GetRequiredService<IConsumer<string, string>>();
Aspire.Hosting.Milvus.Tests (3)
MilvusFunctionalTests.cs (3)
44var milvusClient = host.Services.GetRequiredService<MilvusClient>(); 118var milvusClient = host.Services.GetRequiredService<MilvusClient>(); 166var milvusClient = host.Services.GetRequiredService<MilvusClient>();
Aspire.Hosting.MongoDB.Tests (5)
MongoDbFunctionalTests.cs (5)
99var mongoDatabase = host.Services.GetRequiredService<IMongoDatabase>(); 159var mongoDatabase = host.Services.GetRequiredService<IMongoDatabase>(); 206var mongoDatabase = host.Services.GetRequiredService<IMongoDatabase>(); 325var mongoDatabase = host.Services.GetRequiredService<IMongoDatabase>(); 329var mongoDatabase = host.Services.GetRequiredService<IMongoDatabase>();
Aspire.Hosting.MySql.Tests (11)
MySqlFunctionalTests.cs (11)
103using var connection = host.Services.GetRequiredService<MySqlConnection>(); 178using var connection = host.Services.GetRequiredService<MySqlConnection>(); 185using var connection = host.Services.GetRequiredService<MySqlConnection>(); 248using var connection = host.Services.GetRequiredService<MySqlConnection>(); 255using var connection = host.Services.GetRequiredService<MySqlConnection>(); 354using var connection = host.Services.GetRequiredService<MySqlConnection>(); 361using var connection = host.Services.GetRequiredService<MySqlConnection>(); 424var dbContext = host.Services.GetRequiredService<TestDbContext>(); 432var dbContext = host.Services.GetRequiredService<TestDbContext>(); 439var dbContext = host.Services.GetRequiredService<TestDbContext>(); 446var dbContext = host.Services.GetRequiredService<TestDbContext>();
Aspire.Hosting.Nats.Tests (5)
NatsFunctionalTests.cs (5)
55var jetStream = host.Services.GetRequiredService<INatsJSContext>(); 99var natsConnection = host.Services.GetRequiredService<INatsConnection>(); 147var natsConnection = host.Services.GetRequiredService<INatsConnection>(); 206var jetStream = host.Services.GetRequiredService<INatsJSContext>(); 253var jetStream = host.Services.GetRequiredService<INatsJSContext>();
Aspire.Hosting.Oracle.Tests (4)
OracleFunctionalTests.cs (4)
60var dbContext = host.Services.GetRequiredService<TestDbContext>(); 143using var dbContext = host.Services.GetRequiredService<TestDbContext>(); 204using var dbContext = host.Services.GetRequiredService<TestDbContext>(); 320var dbContext = host.Services.GetRequiredService<TestDbContext>();
Aspire.Hosting.PostgreSQL.Tests (5)
PostgresFunctionalTests.cs (5)
134using var connection = host.Services.GetRequiredService<NpgsqlConnection>(); 250using var connection = host.Services.GetRequiredService<NpgsqlConnection>(); 311using var connection = host.Services.GetRequiredService<NpgsqlConnection>(); 404using var connection = host.Services.GetRequiredService<NpgsqlConnection>(); 411using var connection = host.Services.GetRequiredService<NpgsqlConnection>();
Aspire.Hosting.Qdrant.Tests (3)
QdrantFunctionalTests.cs (3)
57var qdrantClient = host.Services.GetRequiredService<QdrantClient>(); 141var qdrantClient = host.Services.GetRequiredService<QdrantClient>(); 186var qdrantClient = host.Services.GetRequiredService<QdrantClient>();
Aspire.Hosting.RabbitMQ.Tests (3)
RabbitMQFunctionalTests.cs (3)
81var connection = host.Services.GetRequiredService<IConnection>(); 143var connection = host.Services.GetRequiredService<IConnection>(); 200var connection = host.Services.GetRequiredService<IConnection>();
Aspire.Hosting.Redis.Tests (7)
RedisFunctionalTests.cs (7)
114var redisClient = host.Services.GetRequiredService<IConnectionMultiplexer>(); 325var redisClient = host.Services.GetRequiredService<IConnectionMultiplexer>(); 361var redisClient = host.Services.GetRequiredService<IConnectionMultiplexer>(); 411var redisClient = host.Services.GetRequiredService<IConnectionMultiplexer>(); 446var redisClient = host.Services.GetRequiredService<IConnectionMultiplexer>(); 495var redisClient = host.Services.GetRequiredService<IConnectionMultiplexer>(); 525var redisClient = host.Services.GetRequiredService<IConnectionMultiplexer>();
Aspire.Hosting.SqlServer.Tests (6)
SqlServerFunctionalTests.cs (6)
93var conn = host.Services.GetRequiredService<SqlConnection>(); 107var dbContext = host.Services.GetRequiredService<TestDbContext>(); 196var conn = host1.Services.GetRequiredService<SqlConnection>(); 220var conn = host1.Services.GetRequiredService<SqlConnection>(); 278var conn = host2.Services.GetRequiredService<SqlConnection>(); 286var conn = host2.Services.GetRequiredService<SqlConnection>();
Aspire.Hosting.Valkey.Tests (3)
ValkeyFunctionalTests.cs (3)
47var redisClient = host.Services.GetRequiredService<IConnectionMultiplexer>(); 108var redisClient = host.Services.GetRequiredService<IConnectionMultiplexer>(); 159var redisClient = host.Services.GetRequiredService<IConnectionMultiplexer>();
Aspire.Keycloak.Authentication.Tests (8)
AspireKeycloakExtensionTests.cs (8)
30host.Services.GetRequiredService<IOptionsMonitor<JwtBearerOptions>>() 50host.Services.GetRequiredService<IOptionsMonitor<JwtBearerOptions>>().Get(scheme)); 70var options = host.Services.GetRequiredService<IOptionsMonitor<JwtBearerOptions>>() 92var options = host.Services.GetRequiredService<IOptionsMonitor<JwtBearerOptions>>() 111host.Services.GetRequiredService<IOptionsMonitor<OpenIdConnectOptions>>() 131host.Services.GetRequiredService<IOptionsMonitor<OpenIdConnectOptions>>().Get(scheme)); 152var options = host.Services.GetRequiredService<IOptionsMonitor<OpenIdConnectOptions>>() 175var options = host.Services.GetRequiredService<IOptionsMonitor<OpenIdConnectOptions>>()
Aspire.Microsoft.Azure.Cosmos.Tests (3)
ConformanceTests.cs (3)
92var client1 = host.Services.GetRequiredService<CosmosClient>(); 93var client2 = host.Services.GetRequiredKeyedService<CosmosClient>("cosmosdb2"); 94var client3 = host.Services.GetRequiredKeyedService<CosmosClient>("cosmosdb3");
Aspire.Microsoft.Data.SqlClient.Tests (9)
AspireSqlServerSqlClientExtensionsTests.cs (9)
37host.Services.GetRequiredKeyedService<SqlConnection>("sqlconnection") : 38host.Services.GetRequiredService<SqlConnection>(); 65host.Services.GetRequiredKeyedService<SqlConnection>("sqlconnection") : 66host.Services.GetRequiredService<SqlConnection>(); 97host.Services.GetRequiredKeyedService<SqlConnection>("sqlconnection") : 98host.Services.GetRequiredService<SqlConnection>(); 121var connection1 = host.Services.GetRequiredService<SqlConnection>(); 122var connection2 = host.Services.GetRequiredKeyedService<SqlConnection>("sqlconnection2"); 123var connection3 = host.Services.GetRequiredKeyedService<SqlConnection>("sqlconnection3");
Aspire.Microsoft.EntityFrameworkCore.Cosmos.Tests (12)
AspireAzureEfCoreCosmosDBExtensionsTests.cs (5)
36var context = host.Services.GetRequiredService<TestDbContext>(); 73var context = host.Services.GetRequiredService<TestDbContext>(); 113var context = host.Services.GetRequiredService<TestDbContext>(); 144var context = host.Services.GetRequiredService<TestDbContext>(); 145var context2 = host.Services.GetRequiredService<TestDbContext2>();
ConformanceTests.cs (2)
84IDbContextPool<TestDbContext>? pool = host.Services.GetService<IDbContextPool<TestDbContext>>(); 94TestDbContext? dbContext = host.Services.GetService<TestDbContext>();
EnrichCosmosDbTests.cs (5)
68var context = host.Services.GetRequiredService<TestDbContext>(); 97var context = host.Services.GetRequiredService<ITestDbContext>() as TestDbContext; 118var context = host.Services.GetRequiredService<ITestDbContext>() as TestDbContext; 135var exception = Assert.Throws<InvalidOperationException>(host.Services.GetRequiredService<TestDbContext>); 157var tracerProvider = host.Services.GetService<TracerProvider>();
Aspire.Microsoft.EntityFrameworkCore.SqlServer.Tests (21)
AspireSqlServerEFCoreSqlClientExtensionsTests.cs (9)
31var context = host.Services.GetRequiredService<TestDbContext>(); 47var context = host.Services.GetRequiredService<TestDbContext>(); 67var context = host.Services.GetRequiredService<TestDbContext>(); 94var context = host.Services.GetRequiredService<TestDbContext>(); 138var context = host.Services.GetRequiredService<TestDbContext>(); 179var context = host.Services.GetRequiredService<TestDbContext>(); 214var context = host.Services.GetRequiredService<TestDbContext>(); 245var context = host.Services.GetRequiredService<TestDbContext>(); 246var context2 = host.Services.GetRequiredService<TestDbContext2>();
ConformanceTests.cs (2)
102IDbContextPool<TestDbContext>? pool = host.Services.GetService<IDbContextPool<TestDbContext>>(); 112TestDbContext? dbContext = host.Services.GetService<TestDbContext>();
EnrichSqlServerTests.cs (10)
74var context = host.Services.GetRequiredService<TestDbContext>(); 109var exception = Assert.Throws<InvalidOperationException>(host.Services.GetRequiredService<TestDbContext>); 129var context = host.Services.GetRequiredService<TestDbContext>(); 172var context = host.Services.GetRequiredService<TestDbContext>(); 210var context = host.Services.GetRequiredService<TestDbContext>(); 238var context = host.Services.GetRequiredService<ITestDbContext>() as TestDbContext; 259var context = host.Services.GetRequiredService<ITestDbContext>() as TestDbContext; 276var context = host.Services.GetRequiredService<TestDbContext>(); 304var exception = Assert.Throws<InvalidOperationException>(host.Services.GetRequiredService<TestDbContext>); 321var context = host.Services.GetRequiredService<TestDbContext>();
Aspire.Milvus.Client.Tests (11)
AspireMilvusExtensionTests.cs (8)
50host.Services.GetRequiredKeyedService<MilvusClient>(DefaultKeyName) : 51host.Services.GetRequiredService<MilvusClient>(); 74host.Services.GetRequiredKeyedService<MilvusClient>(DefaultKeyName) : 75host.Services.GetRequiredService<MilvusClient>(); 104host.Services.GetRequiredKeyedService<MilvusClient>(DefaultKeyName) : 105host.Services.GetRequiredService<MilvusClient>(); 135var healthCheckService = host.Services.GetRequiredService<HealthCheckService>(); 168var healthCheckService = host.Services.GetService<HealthCheckService>();
ConformanceTests.cs (3)
120var client1 = host.Services.GetRequiredService<MilvusClient>(); 121var client2 = host.Services.GetRequiredKeyedService<MilvusClient>("milvus2"); 122var client3 = host.Services.GetRequiredKeyedService<MilvusClient>("milvus3");
Aspire.MongoDB.Driver.Tests (13)
AspireMongoDBDriverExtensionsTests.cs (11)
40var mongoClient = host.Services.GetRequiredService<IMongoClient>(); 58var mongoDatabase = host.Services.GetService<IMongoDatabase>(); 86var mongoClient = host.Services.GetRequiredKeyedService<IMongoClient>(key); 105var mongoDatabase = host.Services.GetKeyedService<IMongoDatabase>(key); 132var healthCheckService = host.Services.GetRequiredService<HealthCheckService>(); 154var healthCheckService = host.Services.GetService<HealthCheckService>(); 176var healthCheckService = host.Services.GetRequiredService<HealthCheckService>(); 198var healthCheckService = host.Services.GetService<HealthCheckService>(); 219var connection1 = host.Services.GetRequiredService<IMongoDatabase>(); 220var connection2 = host.Services.GetRequiredKeyedService<IMongoDatabase>("mongodb2"); 221var connection3 = host.Services.GetRequiredKeyedService<IMongoDatabase>("mongodb3");
ConformanceTests.cs (2)
120T? Resolve<T>() => key is null ? host.Services.GetService<T>() : host.Services.GetKeyedService<T>(key);
Aspire.MySqlConnector.Tests (11)
AspireMySqlConnectorExtensionsTests.cs (9)
45host.Services.GetRequiredKeyedService<MySqlDataSource>("mysql") : 46host.Services.GetRequiredService<MySqlDataSource>(); 73host.Services.GetRequiredKeyedService<MySqlDataSource>("mysql") : 74host.Services.GetRequiredService<MySqlDataSource>(); 105host.Services.GetRequiredKeyedService<MySqlDataSource>("mysql") : 106host.Services.GetRequiredService<MySqlDataSource>(); 129var connection1 = host.Services.GetRequiredService<MySqlDataSource>(); 130var connection2 = host.Services.GetRequiredKeyedService<MySqlDataSource>("mysql2"); 131var connection3 = host.Services.GetRequiredKeyedService<MySqlDataSource>("mysql3");
ConformanceTests.cs (2)
123T? Resolve<T>() => key is null ? host.Services.GetService<T>() : host.Services.GetKeyedService<T>(key);
Aspire.NATS.Net.Tests (14)
AspireNatsClientExtensionsTests.cs (14)
52host.Services.GetRequiredKeyedService<INatsConnection>("nats") : 53host.Services.GetRequiredService<INatsConnection>(); 79host.Services.GetRequiredKeyedService<INatsConnection>("nats") : 80host.Services.GetRequiredService<INatsConnection>(); 110host.Services.GetRequiredKeyedService<INatsConnection>("nats") : 111host.Services.GetRequiredService<INatsConnection>(); 142host.Services.GetRequiredKeyedService<INatsConnection>("nats") : 143host.Services.GetRequiredService<INatsConnection>(); 169var healthCheckService = host.Services.GetRequiredService<HealthCheckService>(); 202var healthCheckService = host.Services.GetService<HealthCheckService>(); 223var nats = host.Services.GetRequiredService<INatsConnection>(); 251var connection1 = host.Services.GetRequiredService<INatsConnection>(); 252var connection2 = host.Services.GetRequiredKeyedService<INatsConnection>("nats2"); 253var connection3 = host.Services.GetRequiredKeyedService<INatsConnection>("nats3");
Aspire.Npgsql.EntityFrameworkCore.PostgreSQL.Tests (22)
AspireEFPostgreSqlExtensionsTests.cs (9)
39var context = host.Services.GetRequiredService<TestDbContext>(); 57var context = host.Services.GetRequiredService<TestDbContext>(); 77var context = host.Services.GetRequiredService<TestDbContext>(); 104var context = host.Services.GetRequiredService<TestDbContext>(); 146var context = host.Services.GetRequiredService<TestDbContext>(); 187var context = host.Services.GetRequiredService<TestDbContext>(); 221var context = host.Services.GetRequiredService<TestDbContext>(); 252var context = host.Services.GetRequiredService<TestDbContext>(); 253var context2 = host.Services.GetRequiredService<TestDbContext2>();
ConformanceTests.cs (2)
119IDbContextPool<TestDbContext>? pool = host.Services.GetService<IDbContextPool<TestDbContext>>(); 129TestDbContext? dbContext = host.Services.GetService<TestDbContext>();
EnrichNpgsqlTests.cs (11)
76var context = host.Services.GetRequiredService<TestDbContext>(); 112var exception = Assert.Throws<InvalidOperationException>(host.Services.GetRequiredService<TestDbContext>); 133var context = host.Services.GetRequiredService<TestDbContext>(); 177var context = host.Services.GetRequiredService<TestDbContext>(); 216var context = host.Services.GetRequiredService<TestDbContext>(); 246var context = host.Services.GetRequiredService<ITestDbContext>() as TestDbContext; 268var context = host.Services.GetRequiredService<ITestDbContext>() as TestDbContext; 286var context = host.Services.GetRequiredService<TestDbContext>(); 315var exception = Assert.Throws<InvalidOperationException>(host.Services.GetRequiredService<TestDbContext>); 333var context = host.Services.GetRequiredService<TestDbContext>(); 367var tracerProvider = host.Services.GetService<TracerProvider>();
Aspire.Npgsql.Tests (13)
AspirePostgreSqlNpgsqlExtensionsTests.cs (11)
37host.Services.GetRequiredKeyedService<NpgsqlDataSource>("npgsql") : 38host.Services.GetRequiredService<NpgsqlDataSource>(); 65host.Services.GetRequiredKeyedService<NpgsqlDataSource>("npgsql") : 66host.Services.GetRequiredService<NpgsqlDataSource>(); 97host.Services.GetRequiredKeyedService<NpgsqlDataSource>("npgsql") : 98host.Services.GetRequiredService<NpgsqlDataSource>(); 129host.Services.GetRequiredKeyedService<NpgsqlDataSource>("npgsql") : 130host.Services.GetRequiredService<NpgsqlDataSource>(); 151var connection1 = host.Services.GetRequiredService<NpgsqlDataSource>(); 152var connection2 = host.Services.GetRequiredKeyedService<NpgsqlDataSource>("npgsql2"); 153var connection3 = host.Services.GetRequiredKeyedService<NpgsqlDataSource>("npgsql3");
ConformanceTests.cs (2)
125T? Resolve<T>() => key is null ? host.Services.GetService<T>() : host.Services.GetKeyedService<T>(key);
Aspire.OpenAI.Tests (11)
AspireOpenAIExtensionsTests.cs (11)
38host.Services.GetRequiredKeyedService<OpenAIClient>("openai") : 39host.Services.GetRequiredService<OpenAIClient>(); 65host.Services.GetRequiredKeyedService<OpenAIClient>("openai") : 66host.Services.GetRequiredService<OpenAIClient>(); 84var client = host.Services.GetRequiredService<OpenAIClient>(); 103var exception = Assert.Throws<InvalidOperationException>(host.Services.GetRequiredService<OpenAIClient>); 127var client1 = host.Services.GetRequiredService<OpenAIClient>(); 128var client2 = host.Services.GetRequiredKeyedService<OpenAIClient>("openai2"); 129var client3 = host.Services.GetRequiredKeyedService<OpenAIClient>("openai3"); 174var options = host.Services.GetRequiredService<IOptions<OpenAIClientOptions>>().Value; 194var options = host.Services.GetRequiredService<IOptions<OpenAIClientOptions>>().Value;
Aspire.Oracle.EntityFrameworkCore.Tests (25)
AspireOracleEFCoreDatabaseExtensionsTests.cs (11)
32var context = host.Services.GetRequiredService<TestDbContext>(); 48var context = host.Services.GetRequiredService<TestDbContext>(); 68var context = host.Services.GetRequiredService<TestDbContext>(); 95var context = host.Services.GetRequiredService<TestDbContext>(); 139var context = host.Services.GetRequiredService<TestDbContext>(); 180var context = host.Services.GetRequiredService<TestDbContext>(); 215var context = host.Services.GetRequiredService<TestDbContext>(); 246var context = host.Services.GetRequiredService<TestDbContext>(); 247var context2 = host.Services.GetRequiredService<TestDbContext2>(); 314var context = host.Services.GetRequiredService<TestDbContext>(); 330var context = host.Services.GetRequiredService<TestDbContext>();
ConformanceTests.cs (3)
114IDbContextPool<TestDbContext>? pool = host.Services.GetService<IDbContextPool<TestDbContext>>(); 125TestDbContext? dbContext = host.Services.GetService<TestDbContext>(); 164var service = host.Services.GetRequiredService<TestDbContext>();
EnrichOracleDatabaseTests.cs (11)
75var context = host.Services.GetRequiredService<TestDbContext>(); 110var exception = Assert.Throws<InvalidOperationException>(host.Services.GetRequiredService<TestDbContext>); 130var context = host.Services.GetRequiredService<TestDbContext>(); 173var context = host.Services.GetRequiredService<TestDbContext>(); 211var context = host.Services.GetRequiredService<TestDbContext>(); 239var context = host.Services.GetRequiredService<ITestDbContext>() as TestDbContext; 260var context = host.Services.GetRequiredService<ITestDbContext>() as TestDbContext; 277var context = host.Services.GetRequiredService<TestDbContext>(); 305var exception = Assert.Throws<InvalidOperationException>(host.Services.GetRequiredService<TestDbContext>); 322var context = host.Services.GetRequiredService<TestDbContext>(); 355var tracerProvider = host.Services.GetService<TracerProvider>();
Aspire.Pomelo.EntityFrameworkCore.MySql.Tests (20)
AspireEFMySqlExtensionsTests.cs (7)
44var context = host.Services.GetRequiredService<TestDbContext>(); 63var context = host.Services.GetRequiredService<TestDbContext>(); 85var context = host.Services.GetRequiredService<TestDbContext>(); 113var context = host.Services.GetRequiredService<TestDbContext>(); 156var context = host.Services.GetRequiredService<TestDbContext>(); 199var context = host.Services.GetRequiredService<TestDbContext>(); 237var context = host.Services.GetRequiredService<TestDbContext>();
ConformanceTests.cs (2)
116IDbContextPool<TestDbContext>? pool = host.Services.GetService<IDbContextPool<TestDbContext>>(); 125TestDbContext? dbContext = host.Services.GetService<TestDbContext>();
EnrichMySqlTests.cs (11)
88var context = host.Services.GetRequiredService<TestDbContext>(); 123var exception = Assert.Throws<InvalidOperationException>(host.Services.GetRequiredService<TestDbContext>); 143var context = host.Services.GetRequiredService<TestDbContext>(); 186var context = host.Services.GetRequiredService<TestDbContext>(); 224var context = host.Services.GetRequiredService<TestDbContext>(); 252var context = host.Services.GetRequiredService<ITestDbContext>() as TestDbContext; 273var context = host.Services.GetRequiredService<ITestDbContext>() as TestDbContext; 290var context = host.Services.GetRequiredService<TestDbContext>(); 318var exception = Assert.Throws<InvalidOperationException>(host.Services.GetRequiredService<TestDbContext>); 335var context = host.Services.GetRequiredService<TestDbContext>(); 368var tracerProvider = host.Services.GetService<TracerProvider>();
Aspire.Qdrant.Client.Tests (5)
AspireQdrantClientExtensionsTest.cs (5)
49var healthCheckService = host.Services.GetRequiredService<HealthCheckService>(); 82var healthCheckService = host.Services.GetService<HealthCheckService>(); 103var client1 = host.Services.GetRequiredService<QdrantClient>(); 104var client2 = host.Services.GetRequiredKeyedService<QdrantClient>("qdrant2"); 105var client3 = host.Services.GetRequiredKeyedService<QdrantClient>("qdrant3");
Aspire.RabbitMQ.Client.Tests (13)
AspireRabbitMQExtensionsTests.cs (10)
47host.Services.GetRequiredKeyedService<IConnection>("messaging") : 48host.Services.GetRequiredService<IConnection>(); 76host.Services.GetRequiredKeyedService<IConnection>("messaging") : 77host.Services.GetRequiredService<IConnection>(); 107host.Services.GetRequiredKeyedService<IConnection>("messaging") : 108host.Services.GetRequiredService<IConnection>(); 149var connectionFactory = (ConnectionFactory)host.Services.GetRequiredService<IConnectionFactory>(); 182var connection1 = host.Services.GetRequiredService<IConnection>(); 183var connection2 = host.Services.GetRequiredKeyedService<IConnection>("messaging2"); 184var connection3 = host.Services.GetRequiredKeyedService<IConnection>("messaging3");
AspireRabbitMQLoggingTests.cs (3)
57using var connection = host.Services.GetRequiredService<IConnection>(); 81host.Services.GetRequiredService<RabbitMQEventSourceLogForwarder>().Start(); 110host.Services.GetRequiredService<RabbitMQEventSourceLogForwarder>().Start();
Aspire.StackExchange.Redis.DistributedCaching.Tests (1)
AspireRedisDistributedCacheExtensionsTests.cs (1)
22var cache = host.Services.GetRequiredService<IDistributedCache>();
Aspire.StackExchange.Redis.OutputCaching.Tests (1)
AspireRedisOutputCacheExtensionsTests.cs (1)
21var cacheStore = host.Services.GetRequiredService<IOutputCacheStore>();
Aspire.StackExchange.Redis.Tests (22)
AspireRedisExtensionsTests.cs (22)
49var connection = host.Services.GetRequiredService<IConnectionMultiplexer>(); 76host.Services.GetRequiredKeyedService<IConnectionMultiplexer>("myredis") : 77host.Services.GetRequiredService<IConnectionMultiplexer>(); 105host.Services.GetRequiredKeyedService<IConnectionMultiplexer>("redis") : 106host.Services.GetRequiredService<IConnectionMultiplexer>(); 138host.Services.GetRequiredKeyedService<IConnectionMultiplexer>("redis") : 139host.Services.GetRequiredService<IConnectionMultiplexer>(); 194host.Services.GetRequiredService<IOptionsMonitor<ConfigurationOptions>>().Get("redis") : 195host.Services.GetRequiredService<IOptions<ConfigurationOptions>>().Value; 226var distributedCache = host.Services.GetRequiredService<IDistributedCache>(); 229var cacheStore = host.Services.GetRequiredService<IOutputCacheStore>(); 234var healthCheckService = host.Services.GetRequiredService<HealthCheckService>(); 254var tracerProvider = host.Services.GetRequiredService<TracerProvider>(); 256var connectionMultiplexer = host.Services.GetRequiredKeyedService<IConnectionMultiplexer>("redis"); 319var connection1 = host.Services.GetRequiredService<IConnectionMultiplexer>(); 320var connection2 = host.Services.GetRequiredKeyedService<IConnectionMultiplexer>("redis2"); 321var connection3 = host.Services.GetRequiredKeyedService<IConnectionMultiplexer>("redis3"); 356var connection1 = host.Services.GetRequiredService<IConnectionMultiplexer>(); 357var connection2 = host.Services.GetRequiredKeyedService<IConnectionMultiplexer>("redis2"); 358var distributedCache = host.Services.GetRequiredService<IDistributedCache>(); 359var connection3 = host.Services.GetRequiredKeyedService<IConnectionMultiplexer>("redis3"); 360var outputCache = host.Services.GetRequiredService<IOutputCacheStore>();
Diagnostics.EFCore.FunctionalTests (1)
DatabaseErrorPageMiddlewareTest.cs (1)
174using (var db = server.Services.GetService<BloggingContext>())
Http3SampleApp (1)
Program.cs (1)
120using var httpEventSource = new HttpEventSourceListener(host.Services.GetRequiredService<ILoggerFactory>());
IIS.Tests (1)
Utilities\TestServer.cs (1)
166var lifetime = _host.Services.GetService<IHostApplicationLifetime>();
Interop.FunctionalTests (5)
Http2\Http2RequestTests.cs (3)
40var meterFactory = host.Services.GetRequiredService<IMeterFactory>(); 118var meterFactory = host.Services.GetRequiredService<IMeterFactory>(); 262logger = host.Services.GetRequiredService<ILoggerFactory>().CreateLogger("Test");
Http3\Http3RequestTests.cs (1)
81var meterFactory = host.Services.GetRequiredService<IMeterFactory>();
src\Servers\Kestrel\shared\test\TransportTestHelpers\IHostPortExtensions.cs (1)
30return host.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>().Addresses
Microsoft.AspNetCore (7)
WebApplication.cs (7)
35ApplicationBuilder = new ApplicationBuilder(host.Services, ServerFeatures); 36Logger = host.Services.GetRequiredService<ILoggerFactory>().CreateLogger(Environment.ApplicationName ?? nameof(WebApplication)); 44public IServiceProvider Services => _host.Services; 49public IConfiguration Configuration => _host.Services.GetRequiredService<IConfiguration>(); 54public IWebHostEnvironment Environment => _host.Services.GetRequiredService<IWebHostEnvironment>(); 59public IHostApplicationLifetime Lifetime => _host.Services.GetRequiredService<IHostApplicationLifetime>(); 77internal IFeatureCollection ServerFeatures => _host.Services.GetRequiredService<IServer>().Features;
Microsoft.AspNetCore.Authentication.Negotiate.Test (2)
ServerDeferralTests.cs (2)
20var options = host.Services.GetRequiredService<IOptions<NegotiateOptions>>().Value; 37var options = host.Services.GetRequiredService<IOptions<NegotiateOptions>>().Value;
Microsoft.AspNetCore.Diagnostics.Middleware.Tests (2)
Logging\AcceptanceTests.cs (2)
127var logCollector = host.Services.GetFakeLogCollector(); 131await func(logCollector, client, host.Services).ConfigureAwait(false);
Microsoft.AspNetCore.Hosting.Tests (3)
Fakes\GenericWebHost.cs (1)
22public IServiceProvider Services => _host.Services;
GenericWebHostBuilderTests.cs (2)
25var config = host.Services.GetRequiredService<IConfiguration>(); 38var config = host.Services.GetRequiredService<IConfiguration>();
Microsoft.AspNetCore.Http.Connections.Tests (23)
HttpConnectionDispatcherTests.cs (10)
3251var manager = host.Services.GetRequiredService<HttpConnectionManager>(); 3252var url = host.Services.GetService<IServer>().Features.Get<IServerAddressesFeature>().Addresses.Single(); 3314var manager = host.Services.GetRequiredService<HttpConnectionManager>(); 3315var url = host.Services.GetService<IServer>().Features.Get<IServerAddressesFeature>().Addresses.Single(); 3413var manager = host.Services.GetRequiredService<HttpConnectionManager>(); 3414var url = host.Services.GetService<IServer>().Features.Get<IServerAddressesFeature>().Addresses.Single(); 3463var manager = host.Services.GetRequiredService<HttpConnectionManager>(); 3464var url = host.Services.GetService<IServer>().Features.Get<IServerAddressesFeature>().Addresses.Single(); 3537var manager = host.Services.GetRequiredService<HttpConnectionManager>(); 3538var url = host.Services.GetService<IServer>().Features.Get<IServerAddressesFeature>().Addresses.Single();
MapConnectionHandlerTests.cs (13)
45var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 82var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 109var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 137var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 168var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 197var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 227var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 259var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 297var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 333var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 367var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 396var feature = host.Services.GetService<IServer>().Features.Get<IServerAddressesFeature>(); 415var dataSource = host.Services.GetRequiredService<EndpointDataSource>();
Microsoft.AspNetCore.Identity.FunctionalTests (1)
Infrastructure\ServerFactory.cs (1)
62EnsureDatabaseCreated(result.Services);
Microsoft.AspNetCore.Mvc.Testing (4)
DeferredHostBuilder.cs (2)
129public IServiceProvider Services => _host.Services; 152using var reg2 = _host.Services.GetRequiredService<IHostApplicationLifetime>().ApplicationStarted.UnsafeRegister(_ => _hostStartedTcs.TrySetResult(), null);
WebApplicationFactory.cs (2)
91return _host?.Services ?? _server.Host.Services; 214_server = (TestServer)_host.Services.GetRequiredService<IServer>();
Microsoft.AspNetCore.Routing.FunctionalTests (16)
Benchmarks\EndpointRoutingBenchmarkTest.cs (1)
28var configuration = _host.Services.GetService<IConfiguration>();
Benchmarks\RouterBenchmarkTest.cs (1)
29var configuration = _host.Services.GetService<IConfiguration>();
MinimalFormTests.cs (14)
50var antiforgery = host.Services.GetRequiredService<IAntiforgery>(); 51var antiforgeryOptions = host.Services.GetRequiredService<IOptions<AntiforgeryOptions>>(); 110var antiforgery = host.Services.GetRequiredService<IAntiforgery>(); 111var antiforgeryOptions = host.Services.GetRequiredService<IOptions<AntiforgeryOptions>>(); 471var antiforgery = host.Services.GetRequiredService<IAntiforgery>(); 472var antiforgeryOptions = host.Services.GetRequiredService<IOptions<AntiforgeryOptions>>(); 530var antiforgery = host.Services.GetRequiredService<IAntiforgery>(); 531var antiforgeryOptions = host.Services.GetRequiredService<IOptions<AntiforgeryOptions>>(); 582var antiforgery = host.Services.GetRequiredService<IAntiforgery>(); 583var antiforgeryOptions = host.Services.GetRequiredService<IOptions<AntiforgeryOptions>>(); 634var antiforgery = host.Services.GetRequiredService<IAntiforgery>(); 635var antiforgeryOptions = host.Services.GetRequiredService<IOptions<AntiforgeryOptions>>(); 683var antiforgery = host.Services.GetRequiredService<IAntiforgery>(); 684var antiforgeryOptions = host.Services.GetRequiredService<IOptions<AntiforgeryOptions>>();
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (3)
DelegateTests.cs (2)
30var server = host.Services.GetRequiredService<IServer>(); 31var delegationFeature = host.Services.GetRequiredService<IServerDelegationFeature>();
Utilities.cs (1)
106var options = host.Services.GetRequiredService<IOptions<HttpSysOptions>>();
Microsoft.AspNetCore.Server.IISIntegration.Tests (2)
IISMiddlewareTests.cs (2)
320var configuration = host.Services.GetService<IConfiguration>(); 349var configuration = host.Services.GetService<IConfiguration>();
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests (1)
src\Servers\Kestrel\shared\test\TransportTestHelpers\IHostPortExtensions.cs (1)
30return host.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>().Addresses
Microsoft.AspNetCore.SignalR.Tests (9)
MapSignalRTests.cs (9)
84var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 117var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 156var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 185var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 214var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 246var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 278var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 317var dataSource = host.Services.GetRequiredService<EndpointDataSource>(); 348var dataSource = host.Services.GetRequiredService<EndpointDataSource>();
Microsoft.AspNetCore.SignalR.Tests.Utils (3)
src\Shared\SignalR\InProcessTestServer.cs (3)
59public override IServiceProvider Services => _host.Services; 129_url = _host.Services.GetService<IServer>().Features.Get<IServerAddressesFeature>().Addresses.Single(); 131_lifetime = _host.Services.GetRequiredService<IHostApplicationLifetime>();
Microsoft.AspNetCore.StaticFiles.FunctionalTests (5)
FallbackStaticFileTest.cs (2)
56var environment = host.Services.GetRequiredService<IWebHostEnvironment>(); 105var environment = host.Services.GetRequiredService<IWebHostEnvironment>();
Helpers.cs (1)
15return server.Services.GetService<IServer>().Features.Get<IServerAddressesFeature>().Addresses.First();
StaticFileMiddlewareTests.cs (2)
154var hostingEnvironment = host.Services.GetService<IWebHostEnvironment>(); 196var hostingEnvironment = host.Services.GetService<IWebHostEnvironment>();
Microsoft.AspNetCore.TestHost (1)
HostBuilderTestServerExtensions.cs (1)
23return (TestServer)host.Services.GetRequiredService<IServer>();
Microsoft.AspNetCore.TestHost.Tests (1)
TestServerTests.cs (1)
87Assert.IsType<NoopHostLifetime>(host.Services.GetService<IHostLifetime>());
Microsoft.AspNetCore.Testing (3)
ServiceFakesHostExtensions.cs (3)
40var uri = GetListenUris(host.Services.GetRequiredService<IServer>()).FirstOrDefault(addressFilter) 45var certificate = host.Services.GetService<IOptions<FakeCertificateOptions>>()?.Value.Certificate; 65return GetListenUris(Throw.IfNull(host).Services.GetRequiredService<IServer>());
Microsoft.AspNetCore.Testing.Tests (6)
FakesExtensionsTests.cs (6)
56var certificate = host.Services.GetRequiredService<IOptions<FakeCertificateOptions>>().Value.Certificate; 137var services = Mock.Get(hostMock.Object.Services); 184var services = Mock.Get(hostMock.Object.Services); 197hostMock.Object.Services.GetRequiredService<IServer>().Features[typeof(IServerAddressesFeature)] = null; 199var services = Mock.Get(hostMock.Object.Services); 250hostMock.SetupGet(x => x.Services).Returns(serviceProviderMock.Object);
Microsoft.AspNetCore.WebSockets.Tests (1)
IHostPortExtensions.cs (1)
26return host.Services.GetService<IServer>().Features.Get<IServerAddressesFeature>().Addresses
Microsoft.Extensions.AmbientMetadata.Application.Tests (2)
AcceptanceTests.cs (2)
59await func(host.Services.GetRequiredService<IOptions<ApplicationMetadata>>().Value, 60host.Services.GetRequiredService<IHostEnvironment>());
Microsoft.Extensions.Diagnostics.Probes.Tests (18)
KubernetesProbesExtensionsTests.cs (6)
36var hostedServices = host.Services.GetServices<IHostedService>().Where(service => service.GetType().Name == "TcpEndpointProbesService"); 37var configurations = host.Services.GetServices<IOptionsMonitor<TcpEndpointProbesOptions>>(); 80var hostedServices = host.Services.GetServices<IHostedService>().Where(service => service.GetType().Name == "TcpEndpointProbesService"); 81var configurations = host.Services.GetServices<IOptionsMonitor<TcpEndpointProbesOptions>>(); 108var hostedServices = host.Services.GetServices<IHostedService>().Where(service => service.GetType().Name == "TcpEndpointProbesService"); 109var configurations = host.Services.GetServices<IOptionsMonitor<TcpEndpointProbesOptions>>();
TcpEndpointProbesExtensionsTests.cs (12)
36var hostedServices = host.Services.GetServices<IHostedService>().Where(x => x is TcpEndpointProbesService); 55var hostedServices = host.Services.GetServices<IHostedService>().Where(x => x is TcpEndpointProbesService); 56var configurations = host.Services.GetServices<IOptions<TcpEndpointProbesOptions>>(); 73var hostedServices = host.Services.GetServices<IHostedService>().Where(x => x is TcpEndpointProbesService); 92var hostedServices = host.Services.GetServices<IHostedService>().Where(x => x is TcpEndpointProbesService); 93var configurations = host.Services.GetServices<IOptionsMonitor<TcpEndpointProbesOptions>>(); 118var hostedServices = host.Services.GetServices<IHostedService>().Where(x => x is TcpEndpointProbesService); 119var configurations = host.Services.GetServices<IOptions<TcpEndpointProbesOptions>>(); 143var hostedServices = host.Services.GetServices<IHostedService>().Where(x => x is TcpEndpointProbesService); 144var configurations = host.Services.GetServices<IOptionsMonitor<TcpEndpointProbesOptions>>(); 164var hostedServices = host.Services.GetServices<IHostedService>().Where(x => x is TcpEndpointProbesService); 165var configurations = host.Services.GetServices<IOptionsMonitor<TcpEndpointProbesOptions>>();
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests (12)
Linux\AcceptanceTest.cs (4)
236meterScope = host.Services.GetRequiredService<IMeterFactory>(); 237var tracker = host.Services.GetService<IResourceMonitor>(); 320meterScope = host.Services.GetRequiredService<IMeterFactory>(); 321var tracker = host.Services.GetService<IResourceMonitor>();
ResourceMonitoringExtensionsTests.cs (8)
103var tracker = host.Services.GetService<IResourceMonitor>(); 104var options = host.Services.GetService<IOptions<ResourceMonitoringOptions>>(); 105var provider = host.Services.GetService<ISnapshotProvider>(); 106var publisher = host.Services.GetService<IResourceUtilizationPublisher>(); 135var options = host.Services.GetService<IOptions<ResourceMonitoringOptions>>(); 175var options = host.Services.GetService<IOptions<ResourceMonitoringOptions>>(); 196var trackers = host.Services.GetServices<IResourceMonitor>().ToArray(); 197var backgrounds = host.Services.GetServices<IHostedService>().Where(x => x is ResourceMonitorService).ToArray();
Microsoft.Extensions.Hosting (2)
HostBuilder.cs (1)
74/// subsequent operations, as well as in <see cref="IHost.Services"/>.
HostingHostBuilderExtensions.cs (1)
140/// subsequent operations, as well as in <see cref="IHost.Services"/>.
Microsoft.Extensions.Hosting.Abstractions (2)
HostingAbstractionsHostExtensions.cs (1)
92IHostApplicationLifetime applicationLifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
IHostBuilder.cs (1)
33/// subsequent operations, as well as in <see cref="IHost.Services"/>.
Microsoft.Extensions.Hosting.Testing (3)
FakeHost.cs (1)
19public IServiceProvider Services => _host.Services;
FakeHostingExtensions.cs (2)
55return host.Services.GetFakeLogCollector(); 67return host.Services.GetFakeRedactionCollector();
Microsoft.Extensions.Hosting.Testing.Tests (7)
FakeHostBuilderTests.cs (4)
29var hostBuilderServices = new FakeHostBuilder(new FakeHostOptions { }).Build().Services; 38var hostBuilderServices = new FakeHostBuilder(new FakeHostOptions()).Build().Services; 45var hostBuilderServices = new FakeHostBuilder(new FakeHostOptions()).Build().Services; 54var hostBuilderServices = new FakeHostBuilder(new FakeHostOptions { FakeLogging = false }).Build().Services;
FakeHostTests.cs (2)
22Assert.Contains(host.Services.GetServices<ILoggerProvider>(), x => x is FakeLoggerProvider); 36Assert.Throws<ObjectDisposedException>(() => host.Services.GetService<IHost>());
HostingFakesExtensionsTests.cs (1)
321var logger = host.Services.GetRequiredService<ILogger>();
Microsoft.Extensions.Options.Contextual.Tests (1)
AcceptanceTests.cs (1)
93.Services
Microsoft.Extensions.Telemetry.Tests (10)
Enrichment\ApplicationEnricherExtensionsTests.cs (5)
42Assert.NotNull(host.Services.GetRequiredService<IStaticLogEnricher>()); 61Assert.NotNull(host.Services.GetRequiredService<IStaticLogEnricher>()); 62var options = host.Services.GetRequiredService<IOptions<ApplicationLogEnricherOptions>>().Value; 85var enricher = host.Services.GetRequiredService<IStaticLogEnricher>(); 88var options = host.Services.GetRequiredService<IOptions<ApplicationLogEnricherOptions>>().Value;
Enrichment\ProcessEnricherExtensionsTests.cs (5)
45Assert.NotNull(host.Services.GetRequiredService<ILogEnricher>()); 62Assert.NotNull(host.Services.GetRequiredService<ILogEnricher>()); 63var options = host.Services.GetRequiredService<IOptions<ProcessLogEnricherOptions>>().Value; 83var enricher = host.Services.GetRequiredService<ILogEnricher>(); 86var options = host.Services.GetRequiredService<IOptions<ProcessLogEnricherOptions>>().Value;
Sockets.BindTests (5)
src\Servers\Kestrel\shared\test\TransportTestHelpers\IHostPortExtensions.cs (1)
30return host.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>().Addresses
src\Servers\Kestrel\test\BindTests\AddressRegistrationTests.cs (4)
330var options = ((IOptions<KestrelServerOptions>)host.Services.GetService(typeof(IOptions<KestrelServerOptions>))).Value; 632var serverAddresses = host.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>().Addresses; 677var serverAddresses = host.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>().Addresses; 717var serverAddresses = host.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>().Addresses;
Sockets.FunctionalTests (1)
src\Servers\Kestrel\shared\test\TransportTestHelpers\IHostPortExtensions.cs (1)
30return host.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>().Addresses
Wasm.Performance.Driver (1)
Program.cs (1)
328return testApp.Services.GetRequiredService<IServer>()