1066 references to Resource
Aspire.Hosting (72)
ResourceBuilderExtensions.cs (39)
164context.EnvironmentVariables[name] = parameter.Resource;
188context.EnvironmentVariables[envVarName] = new ConnectionStringReference(resource.Resource, optional: false);
350var resource = source.Resource;
377ApplyEndpoints(builder, source.Resource);
435var endpointReferenceAnnotation = builder.Resource.Annotations
477var endpoint = builder.Resource.Annotations
491builder.Resource.Annotations.Add(endpoint);
530if (builder.Resource.Annotations.OfType<EndpointAnnotation>().Any(sb => string.Equals(sb.Name, annotation.Name, StringComparisons.EndpointAnnotationName)))
536if (env is not null && builder.Resource is IResourceWithEndpoints resourceWithEndpoints and IResourceWithEnvironment)
601if (!builder.Resource.TryGetAnnotationsOfType<EndpointAnnotation>(out var endpoints))
629return builder.Resource.GetEndpoint(name);
690if (builder.Resource as IResource == dependency.Resource)
692throw new DistributedApplicationException($"The '{builder.Resource.Name}' resource cannot wait for itself.");
695if (builder.Resource is IResourceWithParent resourceWithParent && resourceWithParent.Parent == dependency.Resource)
697throw new DistributedApplicationException($"The '{builder.Resource.Name}' resource cannot wait for its parent '{dependency.Resource.Name}'.");
700if (dependency.Resource is IResourceWithParent dependencyResourceWithParent)
709builder.WithRelationship(dependency.Resource, KnownRelationshipTypes.WaitFor);
711return builder.WithAnnotation(new WaitAnnotation(dependency.Resource, WaitType.WaitUntilHealthy));
745if (builder.Resource as IResource == dependency.Resource)
747throw new DistributedApplicationException($"The '{builder.Resource.Name}' resource cannot wait for itself.");
750if (builder.Resource is IResourceWithParent resourceWithParent && resourceWithParent.Parent == dependency.Resource)
752throw new DistributedApplicationException($"The '{builder.Resource.Name}' resource cannot wait for its parent '{dependency.Resource.Name}'.");
755builder.WithRelationship(dependency.Resource, KnownRelationshipTypes.WaitFor);
757return builder.WithAnnotation(new WaitAnnotation(dependency.Resource, WaitType.WaitForCompletion, exitCode));
801if (builder.Resource.TryGetAnnotationsOfType<HealthCheckAnnotation>(out var annotations) && annotations.Any(a => a.Key == key))
803throw new DistributedApplicationException($"Resource '{builder.Resource.Name}' already has a health check with key '{key}'.");
858var endpoint = builder.Resource.GetEndpoint(endpointName);
864throw new DistributedApplicationException($"The endpoint '{endpointName}' does not exist on the resource '{builder.Resource.Name}'.");
869throw new DistributedApplicationException($"The endpoint '{endpointName}' on resource '{builder.Resource.Name}' was not using the '{desiredScheme}' scheme.");
876builder.ApplicationBuilder.Eventing.Subscribe<BeforeResourceStartedEvent>(builder.Resource, (@event, ct) =>
883var healthCheckKey = $"{builder.Resource.Name}_{endpointName}_{path}_{statusCode}_check";
1002var existingAnnotation = builder.Resource.Annotations.OfType<ResourceCommandAnnotation>().SingleOrDefault(a => a.Name == name);
1005builder.Resource.Annotations.Remove(existingAnnotation);
Aspire.Hosting.Azure (18)
Aspire.Hosting.Azure.ApplicationInsights (1)
Aspire.Hosting.Azure.CognitiveServices (1)
Aspire.Hosting.Azure.CosmosDB (6)
Aspire.Hosting.Azure.EventHubs (12)
Aspire.Hosting.Azure.Functions (7)
Aspire.Hosting.Azure.PostgreSQL (14)
Aspire.Hosting.Azure.Redis (6)
Aspire.Hosting.Azure.ServiceBus (5)
Aspire.Hosting.Azure.Sql (10)
Aspire.Hosting.Azure.Storage (9)
Aspire.Hosting.Azure.Tests (218)
AzureBicepResourceTests.cs (142)
35Assert.Equal("content", bicepResource.Resource.TemplateString);
36Assert.Equal("value1", bicepResource.Resource.Parameters["param1"]);
37Assert.Equal("value2", bicepResource.Resource.Parameters["param2"]);
99if (azureResourceBuilder.Resource is not AzureProvisioningResource bicepResource)
120if (azureResourceBuilder.Resource is not AzureProvisioningResource bicepResource)
138bicepResource.Resource.Outputs["resourceEndpoint"] = "https://myendpoint";
150bicepResource.Resource.SecretOutputs["connectionString"] = "https://myendpoint;Key=43";
229Assert.True(cosmos.Resource.IsContainer());
231var csExpr = cosmos.Resource.ConnectionStringExpression;
237Assert.Equal(cs, await ((IResourceWithConnectionString)cosmos.Resource).GetConnectionStringAsync());
253cosmos.Resource.SecretOutputs["connectionString"] = "mycosmosconnectionstring";
255var manifest = await ManifestUtils.GetManifestWithBicep(cosmos.Resource);
328var connectionStringResource = (IResourceWithConnectionString)cosmos.Resource;
330Assert.Equal("cosmos", cosmos.Resource.Name);
347cosmos.Resource.SecretOutputs["connectionString"] = "mycosmosconnectionstring";
349var manifest = await ManifestUtils.GetManifestWithBicep(cosmos.Resource);
422var connectionStringResource = (IResourceWithConnectionString)cosmos.Resource;
424Assert.Equal("cosmos", cosmos.Resource.Name);
434appConfig.Resource.Outputs["appConfigEndpoint"] = "https://myendpoint";
435Assert.Equal("https://myendpoint", await appConfig.Resource.ConnectionStringExpression.GetValueAsync(default));
437var manifest = await ManifestUtils.GetManifestWithBicep(appConfig.Resource);
439var connectionStringResource = (IResourceWithConnectionString)appConfig.Resource;
501appInsights.Resource.Outputs["appInsightsConnectionString"] = "myinstrumentationkey";
503var connectionStringResource = (IResourceWithConnectionString)appInsights.Resource;
505Assert.Equal("appInsights", appInsights.Resource.Name);
507Assert.Equal("{appInsights.outputs.appInsightsConnectionString}", appInsights.Resource.ConnectionStringExpression.ValueExpression);
509var appInsightsManifest = await ManifestUtils.GetManifestWithBicep(appInsights.Resource);
558appInsights.Resource.Outputs["appInsightsConnectionString"] = "myinstrumentationkey";
560var connectionStringResource = (IResourceWithConnectionString)appInsights.Resource;
562Assert.Equal("appInsights", appInsights.Resource.Name);
564Assert.Equal("{appInsights.outputs.appInsightsConnectionString}", appInsights.Resource.ConnectionStringExpression.ValueExpression);
566var appInsightsManifest = await ManifestUtils.GetManifestWithBicep(appInsights.Resource);
624appInsights.Resource.Outputs["appInsightsConnectionString"] = "myinstrumentationkey";
626var connectionStringResource = (IResourceWithConnectionString)appInsights.Resource;
628Assert.Equal("appInsights", appInsights.Resource.Name);
630Assert.Equal("{appInsights.outputs.appInsightsConnectionString}", appInsights.Resource.ConnectionStringExpression.ValueExpression);
632var appInsightsManifest = await ManifestUtils.GetManifestWithBicep(appInsights.Resource);
681Assert.Equal("logAnalyticsWorkspace", logAnalyticsWorkspace.Resource.Name);
682Assert.Equal("{logAnalyticsWorkspace.outputs.logAnalyticsWorkspaceId}", logAnalyticsWorkspace.Resource.WorkspaceId.ValueExpression);
684var appInsightsManifest = await ManifestUtils.GetManifestWithBicep(logAnalyticsWorkspace.Resource);
723appInsights.Resource.Outputs["appInsightsConnectionString"] = "myinstrumentationkey";
728var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(serviceA.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance);
749var manifest = await ManifestUtils.GetManifest(infrastructure1.Resource);
774var manifest = await ManifestUtils.GetManifest(infrastructure1.Resource);
813var manifest = await ManifestUtils.GetManifest(infrastructure1.Resource);
843Assert.True(redis.Resource.IsContainer());
845Assert.Equal("localhost:12455", await redis.Resource.GetConnectionStringAsync());
847var manifest = await ManifestUtils.GetManifestWithBicep(redis.Resource);
907var manifest = await ManifestUtils.GetManifestWithBicep(mykv.Resource);
969var manifest = await ManifestUtils.GetManifestWithBicep(mykv.Resource);
1031var manifest = await ManifestUtils.GetManifestWithBicep(signalr.Resource);
1106var manifest = await ManifestUtils.GetManifestWithBicep(sql.Resource);
1108Assert.True(sql.Resource.TryGetLastAnnotation<ConnectionStringRedirectAnnotation>(out var connectionStringAnnotation));
1112Assert.Equal("Server=tcp:myserver,1433;Encrypt=True;Authentication=\"Active Directory Default\"", await sql.Resource.GetConnectionStringAsync(default));
1113Assert.Equal("Server=tcp:{sql.outputs.sqlServerFqdn},1433;Encrypt=True;Authentication=\"Active Directory Default\"", sql.Resource.ConnectionStringExpression.ValueExpression);
1200var manifest = await ManifestUtils.GetManifestWithBicep(sql.Resource);
1202Assert.True(sql.Resource.TryGetLastAnnotation<ConnectionStringRedirectAnnotation>(out var connectionStringAnnotation));
1206Assert.Equal("Server=tcp:myserver,1433;Encrypt=True;Authentication=\"Active Directory Default\"", await sql.Resource.GetConnectionStringAsync(default));
1207Assert.Equal("Server=tcp:{sql.outputs.sqlServerFqdn},1433;Encrypt=True;Authentication=\"Active Directory Default\"", sql.Resource.ConnectionStringExpression.ValueExpression);
1286Assert.True(postgres.Resource.TryGetLastAnnotation<ConnectionStringRedirectAnnotation>(out var connectionStringAnnotation));
1290var manifest = await ManifestUtils.GetManifestWithBicep(postgres.Resource);
1295Assert.Equal("myconnectionstring", await postgres.Resource.GetConnectionStringAsync(default));
1404Assert.True(postgres.Resource.TryGetLastAnnotation<ConnectionStringRedirectAnnotation>(out var connectionStringAnnotation));
1408var manifest = await ManifestUtils.GetManifestWithBicep(postgres.Resource);
1413Assert.Equal("myconnectionstring", await postgres.Resource.GetConnectionStringAsync(default));
1514var manifest = await ManifestUtils.GetManifestWithBicep(postgres.Resource);
1520Assert.Equal(expectedConnectionString, await postgres.Resource.GetConnectionStringAsync());
1546var manifest = await ManifestUtils.GetManifest(postgres.Resource);
1566manifest = await ManifestUtils.GetManifest(postgres.Resource);
1585manifest = await ManifestUtils.GetManifest(postgres.Resource);
1614serviceBus.Resource.Outputs["serviceBusEndpoint"] = "mynamespaceEndpoint";
1616var connectionStringResource = (IResourceWithConnectionString)serviceBus.Resource;
1618Assert.Equal("sb", serviceBus.Resource.Name);
1622var manifest = await ManifestUtils.GetManifestWithBicep(serviceBus.Resource);
1707wps.Resource.Outputs["endpoint"] = "https://mywebpubsubendpoint";
1721var connectionStringResource = (IResourceWithConnectionString)wps.Resource;
1724var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource);
1727Assert.Equal("wps1", wps.Resource.Name);
1776wps.Resource.Outputs["endpoint"] = "https://mywebpubsubendpoint";
1791var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource);
1794Assert.Equal("wps1", wps.Resource.Name);
1847Assert.True(storage.Resource.IsContainer());
1854=> new(storage.Resource, new EndpointAnnotation(ProtocolType.Tcp, name: name, targetPort: port));
1860Assert.Equal(blobqs, blob.Resource.ConnectionStringExpression.ValueExpression);
1861Assert.Equal(queueqs, queue.Resource.ConnectionStringExpression.ValueExpression);
1862Assert.Equal(tableqs, table.Resource.ConnectionStringExpression.ValueExpression);
1868Assert.Equal(Resolve(blobqs, "blob", 10000), await ((IResourceWithConnectionString)blob.Resource).GetConnectionStringAsync());
1869Assert.Equal(Resolve(queueqs, "queue", 10001), await ((IResourceWithConnectionString)queue.Resource).GetConnectionStringAsync());
1870Assert.Equal(Resolve(tableqs, "table", 10002), await ((IResourceWithConnectionString)table.Resource).GetConnectionStringAsync());
1889storage.Resource.Outputs["blobEndpoint"] = "https://myblob";
1890storage.Resource.Outputs["queueEndpoint"] = "https://myqueue";
1891storage.Resource.Outputs["tableEndpoint"] = "https://mytable";
1894Assert.Equal("storage", storage.Resource.Name);
1896var storageManifest = await ManifestUtils.GetManifestWithBicep(storage.Resource);
1988var connectionStringBlobResource = (IResourceWithConnectionString)blob.Resource;
1997var blobManifest = await ManifestUtils.GetManifest(blob.Resource);
2003var connectionStringQueueResource = (IResourceWithConnectionString)queue.Resource;
2012var queueManifest = await ManifestUtils.GetManifest(queue.Resource);
2018var connectionStringTableResource = (IResourceWithConnectionString)table.Resource;
2027var tableManifest = await ManifestUtils.GetManifest(table.Resource);
2048storage.Resource.Outputs["blobEndpoint"] = "https://myblob";
2049storage.Resource.Outputs["queueEndpoint"] = "https://myqueue";
2050storage.Resource.Outputs["tableEndpoint"] = "https://mytable";
2053Assert.Equal("storage", storage.Resource.Name);
2055var storageManifest = await ManifestUtils.GetManifestWithBicep(storage.Resource);
2147var connectionStringBlobResource = (IResourceWithConnectionString)blob.Resource;
2156var blobManifest = await ManifestUtils.GetManifest(blob.Resource);
2162var connectionStringQueueResource = (IResourceWithConnectionString)queue.Resource;
2171var queueManifest = await ManifestUtils.GetManifest(queue.Resource);
2177var connectionStringTableResource = (IResourceWithConnectionString)table.Resource;
2186var tableManifest = await ManifestUtils.GetManifest(table.Resource);
2206storage.Resource.Outputs["blobEndpoint"] = "https://myblob";
2207storage.Resource.Outputs["queueEndpoint"] = "https://myqueue";
2208storage.Resource.Outputs["tableEndpoint"] = "https://mytable";
2211Assert.Equal("storage", storage.Resource.Name);
2213var storageManifest = await ManifestUtils.GetManifestWithBicep(storage.Resource);
2305var connectionStringBlobResource = (IResourceWithConnectionString)blob.Resource;
2314var blobManifest = await ManifestUtils.GetManifest(blob.Resource);
2320var connectionStringQueueResource = (IResourceWithConnectionString)queue.Resource;
2329var queueManifest = await ManifestUtils.GetManifest(queue.Resource);
2335var connectionStringTableResource = (IResourceWithConnectionString)table.Resource;
2344var tableManifest = await ManifestUtils.GetManifest(table.Resource);
2365storage.Resource.Outputs["blobEndpoint"] = "https://myblob";
2366storage.Resource.Outputs["queueEndpoint"] = "https://myqueue";
2367storage.Resource.Outputs["tableEndpoint"] = "https://mytable";
2370Assert.Equal("storage", storage.Resource.Name);
2372var storageManifest = await ManifestUtils.GetManifestWithBicep(storage.Resource);
2464var connectionStringBlobResource = (IResourceWithConnectionString)blob.Resource;
2473var blobManifest = await ManifestUtils.GetManifest(blob.Resource);
2479var connectionStringQueueResource = (IResourceWithConnectionString)queue.Resource;
2488var queueManifest = await ManifestUtils.GetManifest(queue.Resource);
2494var connectionStringTableResource = (IResourceWithConnectionString)table.Resource;
2503var tableManifest = await ManifestUtils.GetManifest(table.Resource);
2523search.Resource.Outputs["connectionString"] = fakeConnectionString;
2525var connectionStringResource = (IResourceWithConnectionString)search.Resource;
2528Assert.Equal("search", search.Resource.Name);
2532var manifest = await ManifestUtils.GetManifestWithBicep(search.Resource);
2615var aiManifest = await ManifestUtils.GetManifest(ai.Resource);
2619var serviceBusManifest = await ManifestUtils.GetManifest(serviceBus.Resource);
2623var serviceManifest = await ManifestUtils.GetManifest(serviceA.Resource);
2650var manifest = await ManifestUtils.GetManifestWithBicep(openai.Resource);
2805var (manifest, bicep) = await ManifestUtils.GetManifestWithBicep(provisioningResource.Resource);
Aspire.Hosting.Azure.WebPubSub (4)
Aspire.Hosting.Containers.Tests (26)
ContainerResourceBuilderTests.cs (12)
17Assert.Equal("redis-stack", redis.Resource.Annotations.OfType<ContainerImageAnnotation>().Single().Image);
25Assert.Equal("redis-stack", redis.Resource.Annotations.OfType<ContainerImageAnnotation>().Single().Image);
26Assert.Equal("1.0.0", redis.Resource.Annotations.OfType<ContainerImageAnnotation>().Single().Tag);
34container.Resource.Annotations.RemoveAt(0);
37Assert.Equal("new-image", container.Resource.Annotations.OfType<ContainerImageAnnotation>().Single().Image);
38Assert.Equal("latest", container.Resource.Annotations.OfType<ContainerImageAnnotation>().Single().Tag);
46container.Resource.Annotations.Add(new ContainerImageAnnotation { Image = "another-image" });
49Assert.Equal("new-image", container.Resource.Annotations.OfType<ContainerImageAnnotation>().Last().Image);
50Assert.Equal("latest", container.Resource.Annotations.OfType<ContainerImageAnnotation>().Last().Tag);
58Assert.Equal("7.1", redis.Resource.Annotations.OfType<ContainerImageAnnotation>().Single().Tag);
66Assert.Equal("myregistry.azurecr.io", redis.Resource.Annotations.OfType<ContainerImageAnnotation>().Single().Registry);
74Assert.Equal("42b5c726e719639fcc1e9dbc13dd843f567dcd37911d0e1abb9f47f2cc1c95cd", redis.Resource.Annotations.OfType<ContainerImageAnnotation>().Single().SHA256);
Aspire.Hosting.Dapr (3)
Aspire.Hosting.Elasticsearch (1)
Aspire.Hosting.Elasticsearch.Tests (18)
Aspire.Hosting.Garnet.Tests (20)
Aspire.Hosting.Kafka (1)
Aspire.Hosting.Kafka.Tests (15)
Aspire.Hosting.Keycloak (2)
Aspire.Hosting.Keycloak.Tests (7)
Aspire.Hosting.Milvus (5)
Aspire.Hosting.Milvus.Tests (18)
Aspire.Hosting.MongoDB (6)
Aspire.Hosting.MongoDB.Tests (27)
Aspire.Hosting.MySql (4)
Aspire.Hosting.MySql.Tests (41)
AddMySqlTests.cs (21)
23Assert.Equal("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", mysql.Resource.PasswordParameter.Default?.GetType().FullName);
33Assert.NotEqual("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", mysql.Resource.PasswordParameter.Default?.GetType().FullName);
161var mySqlManifest = await ManifestUtils.GetManifest(mysql.Resource);
162var dbManifest = await ManifestUtils.GetManifest(db.Resource);
200var serverManifest = await ManifestUtils.GetManifest(mysql.Resource);
249Assert.Equal($"{mysql.Resource.Name}:{mysql.Resource.PrimaryEndpoint.TargetPort}", config["PMA_HOST"]);
290string pattern1 = $@"\$cfg\['Servers'\]\[\$i\]\['host'\] = '{mysql1.Resource.Name}:{mysql1.Resource.PrimaryEndpoint.TargetPort}';";
291string pattern2 = $@"\$cfg\['Servers'\]\[\$i\]\['host'\] = '{mysql2.Resource.Name}:{mysql2.Resource.PrimaryEndpoint.TargetPort}';";
331Assert.Equal(["db1", "db2"], mysql1.Resource.Databases.Keys);
332Assert.Equal(["customers1", "customers2"], mysql1.Resource.Databases.Values);
334Assert.Equal("customers1", db1.Resource.DatabaseName);
335Assert.Equal("customers2", db2.Resource.DatabaseName);
337Assert.Equal("{mysql1.connectionString};Database=customers1", db1.Resource.ConnectionStringExpression.ValueExpression);
338Assert.Equal("{mysql1.connectionString};Database=customers2", db2.Resource.ConnectionStringExpression.ValueExpression);
352Assert.Equal("imports", db1.Resource.DatabaseName);
353Assert.Equal("imports", db2.Resource.DatabaseName);
355Assert.Equal("{mysql1.connectionString};Database=imports", db1.Resource.ConnectionStringExpression.ValueExpression);
356Assert.Equal("{mysql2.connectionString};Database=imports", db2.Resource.ConnectionStringExpression.ValueExpression);
Aspire.Hosting.Nats (2)
Aspire.Hosting.Nats.Tests (33)
NatsFunctionalTests.cs (19)
37await app.WaitForTextAsync("Listening for client connections", nats.Resource.Name);
41hb.Configuration[$"ConnectionStrings:{nats.Resource.Name}"] = await nats.Resource.ConnectionStringExpression.GetValueAsync(default);
82await app.WaitForTextAsync("Listening for client connections", nats.Resource.Name);
86var connectionString = await nats.Resource.ConnectionStringExpression.GetValueAsync(default);
87hb.Configuration[$"ConnectionStrings:{nats.Resource.Name}"] = connectionString;
126await app.WaitForTextAsync("Listening for client connections", nats.Resource.Name);
130var connectionString = await nats.Resource.ConnectionStringExpression.GetValueAsync(default);
135hb.Configuration[$"ConnectionStrings:{nats.Resource.Name}"] = modifiedConnectionString;
187await app.WaitForTextAsync("Listening for client connections", nats1.Resource.Name);
192hb.Configuration[$"ConnectionStrings:{nats1.Resource.Name}"] = await nats1.Resource.ConnectionStringExpression.GetValueAsync(default);
235await app.WaitForTextAsync("Listening for client connections", nats2.Resource.Name);
240hb.Configuration[$"ConnectionStrings:{nats2.Resource.Name}"] = await nats2.Resource.ConnectionStringExpression.GetValueAsync(default);
347await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token);
349await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token);
353await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token);
355await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token);
Aspire.Hosting.NodeJs.Tests (2)
Aspire.Hosting.Oracle (3)
Aspire.Hosting.Oracle.Tests (30)
AddOracleTests.cs (13)
22Assert.Equal("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", orcl.Resource.PasswordParameter.Default?.GetType().FullName);
32Assert.NotEqual("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", orcl.Resource.PasswordParameter.Default?.GetType().FullName);
202var serverManifest = await ManifestUtils.GetManifest(oracleServer.Resource);
203var dbManifest = await ManifestUtils.GetManifest(db.Resource);
241var serverManifest = await ManifestUtils.GetManifest(oracleServer.Resource);
297Assert.Equal("customers1", db1.Resource.DatabaseName);
298Assert.Equal("customers2", db2.Resource.DatabaseName);
300Assert.Equal("{oracle1.connectionString}/customers1", db1.Resource.ConnectionStringExpression.ValueExpression);
301Assert.Equal("{oracle1.connectionString}/customers2", db2.Resource.ConnectionStringExpression.ValueExpression);
315Assert.Equal("imports", db1.Resource.DatabaseName);
316Assert.Equal("imports", db2.Resource.DatabaseName);
318Assert.Equal("{oracle1.connectionString}/imports", db1.Resource.ConnectionStringExpression.ValueExpression);
319Assert.Equal("{oracle2.connectionString}/imports", db2.Resource.ConnectionStringExpression.ValueExpression);
Aspire.Hosting.Orleans (7)
Aspire.Hosting.PostgreSQL (8)
Aspire.Hosting.PostgreSQL.Tests (47)
AddPostgresTests.cs (24)
22Assert.Single(redis.Resource.Annotations, a => a is HealthCheckAnnotation hca && hca.Key == "postgres_check");
32Assert.Equal("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", pg.Resource.PasswordParameter.Default?.GetType().FullName);
42Assert.NotEqual("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", pg.Resource.PasswordParameter.Default?.GetType().FullName);
159var connectionStringResource = postgres.Resource as IResourceWithConnectionString;
163Assert.Equal($"Host=localhost;Port=2000;Username=postgres;Password={postgres.Resource.PasswordParameter.Value}", connectionString);
251var serverManifest = await ManifestUtils.GetManifest(pgServer.Resource);
252var dbManifest = await ManifestUtils.GetManifest(db.Resource);
295var serverManifest = await ManifestUtils.GetManifest(pgServer.Resource);
321serverManifest = await ManifestUtils.GetManifest(pgServer.Resource);
347serverManifest = await ManifestUtils.GetManifest(pgServer.Resource);
476Assert.Equal(pg1.Resource.Name, servers.GetProperty("1").GetProperty("Name").GetString());
483Assert.Equal($"echo '{pg1.Resource.PasswordParameter.Value}'", servers.GetProperty("1").GetProperty("PasswordExecCommand").GetString());
486Assert.Equal(pg2.Resource.Name, servers.GetProperty("2").GetProperty("Name").GetString());
493Assert.Equal($"echo '{pg2.Resource.PasswordParameter.Value}'", servers.GetProperty("2").GetProperty("PasswordExecCommand").GetString());
541Assert.Equal(CreatePgWebBookmarkfileContent(db1.Resource), content);
545Assert.Equal(CreatePgWebBookmarkfileContent(db2.Resource), content);
582Assert.Equal("customers1", db1.Resource.DatabaseName);
583Assert.Equal("customers2", db2.Resource.DatabaseName);
585Assert.Equal("{postgres1.connectionString};Database=customers1", db1.Resource.ConnectionStringExpression.ValueExpression);
586Assert.Equal("{postgres1.connectionString};Database=customers2", db2.Resource.ConnectionStringExpression.ValueExpression);
600Assert.Equal("imports", db1.Resource.DatabaseName);
601Assert.Equal("imports", db2.Resource.DatabaseName);
603Assert.Equal("{postgres1.connectionString};Database=imports", db1.Resource.ConnectionStringExpression.ValueExpression);
604Assert.Equal("{postgres2.connectionString};Database=imports", db2.Resource.ConnectionStringExpression.ValueExpression);
PostgresFunctionalTests.cs (20)
56await rns.WaitForResourceAsync(postgres.Resource.Name, KnownResourceStates.Running, cts.Token);
59await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token);
65await rns.WaitForResourceHealthyAsync(postgres.Resource.Name, cts.Token);
68await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token);
90await app.WaitForTextAsync("Listening at", resourceName: adminBuilder.Resource.Name);
92var client = app.CreateHttpClient(adminBuilder.Resource.Name, "http");
123[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default)
126hb.AddNpgsqlDataSource(db.Resource.Name);
167await app.WaitForTextAsync("Starting server...", resourceName: pgWebBuilder.Resource.Name);
169var client = app.CreateHttpClient(pgWebBuilder.Resource.Name, "http");
239[$"ConnectionStrings:{db1.Resource.Name}"] = await db1.Resource.ConnectionStringExpression.GetValueAsync(default)
242hb.AddNpgsqlDataSource(db1.Resource.Name);
300[$"ConnectionStrings:{db2.Resource.Name}"] = await db2.Resource.ConnectionStringExpression.GetValueAsync(default)
303hb.AddNpgsqlDataSource(db2.Resource.Name);
392[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default)
395hb.AddNpgsqlDataSource(db.Resource.Name);
Aspire.Hosting.Python.Tests (3)
Aspire.Hosting.Qdrant (5)
Aspire.Hosting.Qdrant.Tests (20)
Aspire.Hosting.RabbitMQ (5)
Aspire.Hosting.RabbitMQ.Tests (20)
Aspire.Hosting.Redis (3)
Aspire.Hosting.Redis.Tests (59)
RedisFunctionalTests.cs (47)
50await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token);
52await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token);
56await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token);
58await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token);
79await app.WaitForTextAsync("Redis Connection", resourceName: commanderBuilder.Resource.Name);
81var client = app.CreateHttpClient(commanderBuilder.Resource.Name, "http");
84var path = $"/apiv2/server/R:{redis.Resource.Name}:{endpoint.TargetPort}:0/info";
105[$"ConnectionStrings:{redis.Resource.Name}"] = await redis.Resource.GetConnectionStringAsync()
108hb.AddRedisClient(redis.Resource.Name);
157builder1.Eventing.Subscribe<ResourceReadyEvent>(redisInsightBuilder.Resource, (evt, ct) =>
169using var client1 = app1.CreateHttpClient($"{redis1.Resource.Name}-insight", "http");
174Assert.Equal($"{redis1.Resource.Name}", firstRunDatabases[0].Name);
195builder2.Eventing.Subscribe<ResourceReadyEvent>(redisInsightBuilder.Resource, (evt, ct) =>
206using var client2 = app2.CreateHttpClient($"{redisInsightBuilder.Resource.Name}", "http");
211Assert.Equal($"{redis2.Resource.Name}", secondRunDatabases[0].Name);
223var latestEvent = await rns.WaitForResourceHealthyAsync(redisInsightBuilder.Resource.Name, cts.Token);
246builder.Eventing.Subscribe<ResourceReadyEvent>(redisInsightBuilder.Resource, (evt, ct) =>
258var client = app.CreateHttpClient(redisInsightBuilder.Resource.Name, "http");
269Assert.Equal(redis1.Resource.Name, db.Name);
270Assert.Equal(redis1.Resource.Name, db.Host);
271Assert.Equal(redis1.Resource.PrimaryEndpoint.TargetPort, db.Port);
277Assert.Equal(redis2.Resource.Name, db.Name);
278Assert.Equal(redis2.Resource.Name, db.Host);
279Assert.Equal(redis2.Resource.PrimaryEndpoint.TargetPort, db.Port);
316[$"ConnectionStrings:{redis1.Resource.Name}"] = $"{await redis1.Resource.GetConnectionStringAsync()},allowAdmin=true"
319hb.AddRedisClient(redis1.Resource.Name);
352[$"ConnectionStrings:{redis2.Resource.Name}"] = await redis2.Resource.GetConnectionStringAsync()
355hb.AddRedisClient(redis2.Resource.Name);
402[$"ConnectionStrings:{redis1.Resource.Name}"] = $"{await redis1.Resource.GetConnectionStringAsync()},allowAdmin=true"
405hb.AddRedisClient(redis1.Resource.Name);
437[$"ConnectionStrings:{redis2.Resource.Name}"] = await redis2.Resource.GetConnectionStringAsync()
440hb.AddRedisClient(redis2.Resource.Name);
486[$"ConnectionStrings:{redis1.Resource.Name}"] = $"{await redis1.Resource.GetConnectionStringAsync()},allowAdmin=true"
489hb.AddRedisClient(redis1.Resource.Name);
516[$"ConnectionStrings:{redis2.Resource.Name}"] = await redis2.Resource.GetConnectionStringAsync()
519hb.AddRedisClient(redis2.Resource.Name);
579builder1.Eventing.Subscribe<ResourceReadyEvent>(redisInsightBuilder1.Resource, (evt, ct) =>
589var httpClient = app.CreateHttpClient(redisInsightBuilder1.Resource.Name, "http");
622builder2.Eventing.Subscribe<ResourceReadyEvent>(redisInsightBuilder2.Resource, (evt, ct) =>
632var httpClient = app.CreateHttpClient(redisInsightBuilder2.Resource.Name, "http");
Aspire.Hosting.SqlServer (3)
Aspire.Hosting.SqlServer.Tests (28)
AddSqlServerTests.cs (13)
22Assert.Equal("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", sql.Resource.PasswordParameter.Default?.GetType().FullName);
32Assert.NotEqual("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", sql.Resource.PasswordParameter.Default?.GetType().FullName);
132var serverManifest = await ManifestUtils.GetManifest(sqlServer.Resource);
133var dbManifest = await ManifestUtils.GetManifest(db.Resource);
173var serverManifest = await ManifestUtils.GetManifest(sqlServer.Resource);
230Assert.Equal("customers1", db1.Resource.DatabaseName);
231Assert.Equal("customers2", db2.Resource.DatabaseName);
233Assert.Equal("{sqlserver1.connectionString};Database=customers1", db1.Resource.ConnectionStringExpression.ValueExpression);
234Assert.Equal("{sqlserver1.connectionString};Database=customers2", db2.Resource.ConnectionStringExpression.ValueExpression);
248Assert.Equal("imports", db1.Resource.DatabaseName);
249Assert.Equal("imports", db2.Resource.DatabaseName);
251Assert.Equal("{sqlserver1.connectionString};Database=imports", db1.Resource.ConnectionStringExpression.ValueExpression);
252Assert.Equal("{sqlserver2.connectionString};Database=imports", db2.Resource.ConnectionStringExpression.ValueExpression);
Aspire.Hosting.Testing.Tests (1)
Aspire.Hosting.Tests (179)
ExpressionResolverTests.cs (4)
53var csRef = new ConnectionStringReference(target.Resource, false);
65var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(source.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance, "ContainerHostName").DefaultTimeout();
97var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(test.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance, "ContainerHostName").DefaultTimeout();
116var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(test.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance, "ContainerHostName").DefaultTimeout();
Health\ResourceHealthCheckServiceTests.cs (23)
29await rns.PublishUpdateAsync(resource.Resource, s => s with
37await rns.PublishUpdateAsync(resource.Resource, s => s with
63await rns.PublishUpdateAsync(resource.Resource, s => s with
71await rns.PublishUpdateAsync(resource.Resource, s => s with
108await rns.PublishUpdateAsync(resource.Resource, s => s with
112await rns.WaitForResourceHealthyAsync(resource.Resource.Name, abortTokenSource.Token).DefaultTimeout();
155await rns.PublishUpdateAsync(resource.Resource, s => s with
159await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, abortTokenSource.Token).DefaultTimeout();
182builder.Eventing.Subscribe<ResourceReadyEvent>(resource.Resource, (@event, ct) =>
192await rns.PublishUpdateAsync(resource.Resource, s => s with
198Assert.Equal(resource.Resource, @event.Resource);
224await rns.PublishUpdateAsync(resource.Resource, s => s with
262builder.Eventing.Subscribe<ResourceReadyEvent>(parent.Resource, (@event, ct) =>
288await rns.PublishUpdateAsync(parent.Resource, s => s with
322builder.Eventing.Subscribe<ResourceReadyEvent>(parent.Resource, (@event, ct) =>
333await rns.PublishUpdateAsync(parent.Resource, s => s with
366builder.Eventing.Subscribe<ResourceReadyEvent>(parent.Resource, (@event, ct) =>
372var child = builder.AddResource(new ChildResource("child", parent.Resource));
375builder.Eventing.Subscribe<ResourceReadyEvent>(child.Resource, (@event, ct) =>
386await rns.PublishUpdateAsync(parent.Resource, s => s with
394await rns.PublishUpdateAsync(child.Resource, s => s with
400Assert.Equal(parentReadyEvent.Resource, parent.Resource);
403Assert.Equal(childReadyEvent.Resource, child.Resource);
WaitForTests.cs (23)
32await rns.WaitForResourceAsync(throwingResource.Resource.Name, KnownResourceStates.FailedToStart, abortCts.Token);
33await rns.WaitForResourceAsync(dependingContainerResource.Resource.Name, KnownResourceStates.FailedToStart, abortCts.Token);
34await rns.WaitForResourceAsync(dependingExecutableResource.Resource.Name, KnownResourceStates.FailedToStart, abortCts.Token);
65var childResourceBuilder = builder.AddResource(new CustomChildResource("child", parentResourceBuilder.Resource));
108await rns.WaitForResourceAsync(nginx.Resource.Name, "Waiting", waitingStateCts.Token);
113await rns.PublishUpdateAsync(dependency.Resource, s => s with
149await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Waiting, waitingStateCts.Token);
154await rns.PublishUpdateAsync(dependency.Resource, s => s with
164await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Running, runningStateCts.Token);
197await rns.WaitForResourceAsync(nginx.Resource.Name, "Waiting", waitingStateCts.Token);
202await rns.PublishUpdateAsync(dependency.Resource, s => s with
212await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.FailedToStart, runningStateCts.Token);
245await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Waiting, waitingStateCts.Token);
250await rns.PublishUpdateAsync(dependency.Resource, s => s with
259await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.FailedToStart, runningStateCts.Token);
294await rns.WaitForResourceAsync(nginx.Resource.Name, "FailedToStart", waitingStateCts.Token);
328await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Waiting, waitingStateCts.Token);
331await rns.PublishUpdateAsync(dependency.Resource, s => s with
336await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Running, waitingStateCts.Token);
348var childResource = builder.AddResource(new CustomChildResource("child", parentResource.Resource));
352Assert.True(containerResource.Resource.TryGetAnnotationsOfType<WaitAnnotation>(out var waitAnnotations));
356a => Assert.Equal(a.Resource, parentResource.Resource),
357a => Assert.Equal(a.Resource, childResource.Resource)
WithEnvironmentTests.cs (15)
31container.Resource,
53var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout();
66var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(project.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout();
82var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(project.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout();
98var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectA.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout();
115var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectA.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout();
130var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectA.Resource,
147projectA.Resource,
170var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectA.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout();
195.WithEnvironment("HOST", $"{test.Resource};name=1");
197var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(containerB.Resource).DefaultTimeout();
198var manifestConfig = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(containerB.Resource, DistributedApplicationOperation.Publish).DefaultTimeout();
230var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(containerB.Resource).DefaultTimeout();
254var runConfig = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(targetBuilder.Resource, DistributedApplicationOperation.Run).DefaultTimeout();
260var publishConfig = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(targetBuilder.Resource, DistributedApplicationOperation.Publish).DefaultTimeout();
WithReferenceTests.cs (10)
29var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout();
52var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout();
77var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout();
100var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout();
121var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout();
172var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance);
191var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout();
207var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Publish).DefaultTimeout();
223var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectB.Resource, DistributedApplicationOperation.Publish).DefaultTimeout();
296var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectA.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance).DefaultTimeout();
Aspire.Hosting.Valkey.Tests (22)
Aspire.Playground.Tests (1)
BicepSample.AppHost (1)
KafkaBasic.AppHost (2)
Stress.AppHost (5)