1161 references to Resource
Aspire.Hosting (80)
ContainerResourceBuilderExtensions.cs (13)
112builder.Resource.Entrypoint = entrypoint; 128if (builder.Resource.Annotations.OfType<ContainerImageAnnotation>().LastOrDefault() is { } existingImageAnnotation) 148if (builder.Resource.Annotations.OfType<ContainerImageAnnotation>().LastOrDefault() is { } existingImageAnnotation) 187if (builder.Resource.Annotations.OfType<ContainerImageAnnotation>().LastOrDefault() is { } imageAnnotation) 194builder.Resource.Annotations.Add(imageAnnotation); 227if (builder.Resource.Annotations.OfType<ContainerImageAnnotation>().LastOrDefault() is { } existingImageAnnotation) 321throw new InvalidOperationException($"The resource '{builder.Resource.Name}' does not have a container image specified. Use WithImage to specify the container image and tag."); 333return builder.WithManifestPublishingCallback(context => context.WriteContainerAsync(builder.Resource)); 490var annotation = builder.Resource.Annotations.OfType<DockerfileBuildAnnotation>().SingleOrDefault(); 541if (value.Resource.Secret) 546return builder.WithBuildArg(name, value.Resource); 588var annotation = builder.Resource.Annotations.OfType<DockerfileBuildAnnotation>().SingleOrDefault(); 595annotation.BuildSecrets[name] = value.Resource;
ExecutableResourceBuilderExtensions.cs (4)
124builder.ApplicationBuilder.Resources.Remove(builder.Resource); 126var container = new ExecutableContainerResource(builder.Resource); 129cb.WithImage(builder.Resource.Name); 130cb.WithDockerfile(contextPath: builder.Resource.WorkingDirectory);
OtlpConfigurationExtensions.cs (1)
113AddOtlpEnvironment(builder.Resource, builder.ApplicationBuilder.Configuration, builder.ApplicationBuilder.Environment);
ParameterResourceBuilderExtensions.cs (2)
229var surrogate = new ResourceWithConnectionStringSurrogate(parameterBuilder.Resource, environmentVariableName); 257var parameter = new ParameterResource(builder.Resource.Name, _ => "", secret: true);
ProjectResourceBuilderExtensions.cs (19)
309var projectResource = builder.Resource; 402builder.Resource.KestrelEndpointAnnotationHosts[e] = endpoint.BindingAddress.Host; 515builder.Resource.DefaultHttpsEndpoint = e; 619builder.Resource.Annotations.Add(new EndpointEnvironmentInjectionFilterAnnotation(filter)); 653builder.ApplicationBuilder.Resources.Remove(builder.Resource); 655var container = new ProjectContainerResource(builder.Resource); 658cb.WithImage(builder.Resource.Name); 659cb.WithDockerfile(contextPath: builder.Resource.GetProjectMetadata().ProjectPath); 710foreach (var e in builder.Resource.GetEndpoints().Where(builder.Resource.ShouldInjectEndpointEnvironment)) 727var targetHost = e.EndpointAnnotation.IsProxied && builder.Resource.SupportsProxy() ? "localhost" : e.EndpointAnnotation.TargetHost; 762foreach (var e in builder.Resource.GetEndpoints().Where(builder.Resource.ShouldInjectEndpointEnvironment)) 765if (e.EndpointAnnotation.UriScheme == scheme && e.EndpointAnnotation != builder.Resource.DefaultHttpsEndpoint) 791if (builder.Resource.HasKestrelEndpoints) 793foreach (var e in builder.Resource.GetEndpoints().Where(builder.Resource.ShouldInjectEndpointEnvironment)) 796if (e.EndpointAnnotation == builder.Resource.DefaultHttpsEndpoint) 804builder.Resource.KestrelEndpointAnnotationHosts.TryGetValue(e.EndpointAnnotation, out var kestrelHost) ? kestrelHost : "*";
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 499var endpoint = builder.Resource.Annotations 513builder.Resource.Annotations.Add(endpoint); 552if (builder.Resource.Annotations.OfType<EndpointAnnotation>().Any(sb => string.Equals(sb.Name, annotation.Name, StringComparisons.EndpointAnnotationName))) 558if (env is not null && builder.Resource is IResourceWithEndpoints resourceWithEndpoints and IResourceWithEnvironment) 623if (!builder.Resource.TryGetAnnotationsOfType<EndpointAnnotation>(out var endpoints)) 651return builder.Resource.GetEndpoint(name); 712if (builder.Resource as IResource == dependency.Resource) 714throw new DistributedApplicationException($"The '{builder.Resource.Name}' resource cannot wait for itself."); 717if (builder.Resource is IResourceWithParent resourceWithParent && resourceWithParent.Parent == dependency.Resource) 719throw new DistributedApplicationException($"The '{builder.Resource.Name}' resource cannot wait for its parent '{dependency.Resource.Name}'."); 722if (dependency.Resource is IResourceWithParent dependencyResourceWithParent) 731builder.WithRelationship(dependency.Resource, KnownRelationshipTypes.WaitFor); 733return builder.WithAnnotation(new WaitAnnotation(dependency.Resource, WaitType.WaitUntilHealthy)); 767if (builder.Resource as IResource == dependency.Resource) 769throw new DistributedApplicationException($"The '{builder.Resource.Name}' resource cannot wait for itself."); 772if (builder.Resource is IResourceWithParent resourceWithParent && resourceWithParent.Parent == dependency.Resource) 774throw new DistributedApplicationException($"The '{builder.Resource.Name}' resource cannot wait for its parent '{dependency.Resource.Name}'."); 777builder.WithRelationship(dependency.Resource, KnownRelationshipTypes.WaitFor); 779return builder.WithAnnotation(new WaitAnnotation(dependency.Resource, WaitType.WaitForCompletion, exitCode)); 823if (builder.Resource.TryGetAnnotationsOfType<HealthCheckAnnotation>(out var annotations) && annotations.Any(a => a.Key == key)) 825throw new DistributedApplicationException($"Resource '{builder.Resource.Name}' already has a health check with key '{key}'."); 880var endpoint = builder.Resource.GetEndpoint(endpointName); 886throw new DistributedApplicationException($"The endpoint '{endpointName}' does not exist on the resource '{builder.Resource.Name}'."); 891throw new DistributedApplicationException($"The endpoint '{endpointName}' on resource '{builder.Resource.Name}' was not using the '{desiredScheme}' scheme."); 898builder.ApplicationBuilder.Eventing.Subscribe<BeforeResourceStartedEvent>(builder.Resource, (@event, ct) => 905var healthCheckKey = $"{builder.Resource.Name}_{endpointName}_{path}_{statusCode}_check"; 1024var existingAnnotation = builder.Resource.Annotations.OfType<ResourceCommandAnnotation>().SingleOrDefault(a => a.Name == name); 1027builder.Resource.Annotations.Remove(existingAnnotation);
Utils\ImageNameGenerator.cs (1)
17return $"{builder.Resource.Name}-image-{hex}";
Utils\VolumeNameGenerator.cs (1)
33var resourceName = builder.Resource.Name;
Aspire.Hosting.Azure (18)
AzureBicepResourceExtensions.cs (14)
57return new BicepOutputReference(name, builder.Resource); 68return new BicepSecretOutputReference(name, builder.Resource); 116builder.Resource.Parameters[name] = null; 132builder.Resource.Parameters[name] = value; 148builder.Resource.Parameters[name] = value; 164builder.Resource.Parameters[name] = value; 180builder.Resource.Parameters[name] = valueCallback; 195return builder.WithParameter(name, value.Resource); 210builder.Resource.Parameters[name] = value; 226builder.Resource.Parameters[name] = value.Resource; 242builder.Resource.Parameters[name] = value; 258builder.Resource.Parameters[name] = value; 274builder.Resource.Parameters[name] = value;
AzureProvisioningResourceExtensions.cs (4)
45builder.Resource.ConfigureInfrastructure += configure; 72parameterName ??= Infrastructure.NormalizeBicepIdentifier(parameterResourceBuilder.Resource.Name); 74infrastructure.AspireResource.Parameters[parameterName] = parameterResourceBuilder.Resource; 76return GetOrAddParameter(infrastructure, parameterName, parameterResourceBuilder.Resource.Secret);
Aspire.Hosting.Azure.ApplicationInsights (1)
AzureApplicationInsightsExtensions.cs (1)
64appInsights.WorkspaceResourceId = logAnalyticsWorkspace.Resource.WorkspaceId.AsProvisioningParameter(infrastructure, AzureBicepResource.KnownParameters.LogAnalyticsWorkspaceId);
Aspire.Hosting.Azure.CognitiveServices (1)
AzureOpenAIExtensions.cs (1)
114builder.Resource.AddDeployment(deployment);
Aspire.Hosting.Azure.CosmosDB (13)
AzureCosmosDBExtensions.cs (13)
87builder.ApplicationBuilder.Eventing.Subscribe<ConnectionStringAvailableEvent>(builder.Resource, async (@event, ct) => 89var connectionString = await builder.Resource.ConnectionStringExpression.GetValueAsync(ct).ConfigureAwait(false); 93throw new DistributedApplicationException($"ConnectionStringAvailableEvent was published for the '{builder.Resource.Name}' resource but the connection string was null."); 99builder.ApplicationBuilder.Eventing.Subscribe<ResourceReadyEvent>(builder.Resource, async (@event, ct) => 108foreach (var database in builder.Resource.Databases) 120var healthCheckKey = $"{builder.Resource.Name}_check"; 130var surrogate = new AzureCosmosDBEmulatorResource(builder.Resource); 167var dataPath = builder.Resource.InnerResource.IsPreviewEmulator ? "/data" : "/tmp/cosmos/appdata"; 198if (builder.Resource.InnerResource.IsPreviewEmulator) 232var database = builder.Resource.Databases.FirstOrDefault(x => x.Name == name); 237builder.Resource.Databases.Add(database); 256if (!builder.Resource.InnerResource.IsPreviewEmulator) 293var azureResource = builder.Resource;
Aspire.Hosting.Azure.EventHubs (16)
AzureEventHubsExtensions.cs (16)
106var hub = builder.Resource.Hubs.FirstOrDefault(x => x.Name == name); 111builder.Resource.Hubs.Add(hub); 176.AddAzureStorage($"{builder.Resource.Name}-storage") 179var storage = storageResource.Resource; 193builder.ApplicationBuilder.Eventing.Subscribe<ConnectionStringAvailableEvent>(builder.Resource, async (@event, ct) => 195var connectionString = await builder.Resource.ConnectionStringExpression.GetValueAsync(ct).ConfigureAwait(false) 196?? throw new DistributedApplicationException($"ConnectionStringAvailableEvent was published for the '{builder.Resource.Name}' resource but the connection string was null."); 201if (builder.Resource.Hubs is { Count: > 0 } && builder.Resource.Hubs[0] is { } hub) 208throw new DistributedApplicationException($"The '{builder.Resource.Name}' resource does not have any Event Hubs."); 212var healthCheckKey = $"{builder.Resource.Name}_check"; 222var surrogate = new AzureEventHubsEmulatorResource(builder.Resource); 227builder.ApplicationBuilder.Eventing.Subscribe<BeforeResourceStartedEvent>(builder.Resource, (e, ct) => 324=> builder.WithBindMount(path ?? $".eventhubs/{builder.Resource.Name}", "/data", isReadOnly: false); 370var configFileMount = builder.Resource.Annotations.OfType<ContainerMountAnnotation>().LastOrDefault(v => v.Target == AzureEventHubsEmulatorResource.EmulatorConfigJsonPath); 373builder.Resource.Annotations.Remove(configFileMount);
Aspire.Hosting.Azure.Functions (7)
AzureFunctionsProjectResourceExtensions.cs (7)
63.RunAsEmulator().Resource; 67storage = builder.AddAzureStorage(storageResourceName).RunAsEmulator().Resource; 163var launchProfile = builder.Resource.GetEffectiveLaunchProfile(); 192builder.Resource.HostStorage = storage.Resource; 209connectionName ??= source.Resource.Name; 210source.Resource.ApplyAzureFunctionsConfiguration(context.EnvironmentVariables, connectionName);
Aspire.Hosting.Azure.PostgreSQL (14)
AzurePostgresExtensions.cs (14)
52var postgres = CreatePostgreSqlFlexibleServer(infrastructure, builder.ApplicationBuilder, builder.Resource.Databases); 68var resource = new AzurePostgresResource(builder.Resource, configureInfrastructure); 71.WithLoginAndPassword(builder.Resource); 80if (builder.Resource.Annotations.OfType<ContainerImageAnnotation>().SingleOrDefault() is { } containerAnnotation) 82builder.Resource.Annotations.Remove(containerAnnotation); 163var azureResource = builder.Resource; 166builder.Resource.AddDatabase(name, databaseName); 212var azureResource = builder.Resource; 232azureResource.SetInnerResource(postgresContainer.Resource); 287var azureResource = builder.Resource; 289azureResource.UserNameParameter = userName?.Resource ?? 293azureResource.PasswordParameter = password?.Resource ?? 294ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder.ApplicationBuilder, $"{builder.Resource.Name}-password"); 474builder.ApplicationBuilder, $"{builder.Resource.Name}-username", secret: false, generatedUserName);
Aspire.Hosting.Azure.Redis (6)
AzureRedisExtensions.cs (6)
59var resource = new AzureRedisResource(builder.Resource, configureInfrastructure); 70if (builder.Resource.Annotations.OfType<ContainerImageAnnotation>().SingleOrDefault() is { } containerAnnotation) 72builder.Resource.Annotations.Remove(containerAnnotation); 157var azureResource = builder.Resource; 162azureResource.SetInnerResource(redisContainer.Resource); 193var azureResource = builder.Resource;
Aspire.Hosting.Azure.ServiceBus (13)
AzureServiceBusExtensions.cs (13)
118var queue = builder.Resource.Queues.FirstOrDefault(x => x.Name == name); 123builder.Resource.Queues.Add(queue); 171var topic = builder.Resource.Topics.FirstOrDefault(x => x.Name == name); 176builder.Resource.Topics.Add(topic); 261.AddContainer($"{builder.Resource.Name}-sqledge", 271var sqlEndpoint = sqlEdgeResource.Resource.GetEndpoint("tcp"); 281builder.ApplicationBuilder.Eventing.Subscribe<BeforeResourceStartedEvent>(builder.Resource, async (@event, ct) => 291var connectionString = await builder.Resource.ConnectionStringExpression.GetValueAsync(ct).ConfigureAwait(false); 295throw new DistributedApplicationException($"ConnectionStringAvailableEvent was published for the '{builder.Resource.Name}' resource but the connection string was null."); 412var healthCheckKey = $"{builder.Resource.Name}_check"; 416var surrogate = new AzureServiceBusEmulatorResource(builder.Resource); 449var configFileMount = builder.Resource.Annotations.OfType<ContainerMountAnnotation>().LastOrDefault(v => v.Target == AzureServiceBusEmulatorResource.EmulatorConfigJsonPath); 452builder.Resource.Annotations.Remove(configFileMount);
Aspire.Hosting.Azure.SignalR (1)
AzureSignalRExtensions.cs (1)
107var surrogate = new AzureSignalREmulatorResource(builder.Resource);
Aspire.Hosting.Azure.Sql (10)
AzureSqlExtensions.cs (10)
24CreateSqlServer(infrastructure, builder.ApplicationBuilder, builder.Resource.Databases); 27var resource = new AzureSqlServerResource(builder.Resource, configureInfrastructure); 38if (builder.Resource.Annotations.OfType<ContainerImageAnnotation>().SingleOrDefault() is { } containerAnnotation) 40builder.Resource.Annotations.Remove(containerAnnotation); 107var azureResource = builder.Resource; 110builder.Resource.AddDatabase(name, databaseName); 121azureSqlDatabase.SetInnerResource(innerDb.Resource); 156var azureResource = builder.Resource; 166azureResource.SetInnerResource(sqlContainer.Resource); 176existingDb.SetInnerResource(innerDb.Resource);
Aspire.Hosting.Azure.Storage (9)
AzureStorageExtensions.cs (9)
110builder.ApplicationBuilder.Eventing.Subscribe<BeforeResourceStartedEvent>(builder.Resource, async (@event, ct) => 112var connectionString = await builder.Resource.GetBlobConnectionString().GetValueAsync(ct).ConfigureAwait(false); 116throw new DistributedApplicationException($"ConnectionStringAvailableEvent was published for the '{builder.Resource.Name}' resource but the connection string was null."); 122var healthCheckKey = $"{builder.Resource.Name}_check"; 134var surrogate = new AzureStorageEmulatorResource(builder.Resource); 164=> builder.WithBindMount(path ?? $".azurite/{builder.Resource.Name}", "/data", isReadOnly); 250var resource = new AzureBlobStorageResource(name, builder.Resource); 262var resource = new AzureTableStorageResource(name, builder.Resource); 274var resource = new AzureQueueStorageResource(name, builder.Resource);
Aspire.Hosting.Azure.Tests (258)
AzureBicepProvisionerTests.cs (5)
24await BicepProvisioner.SetParametersAsync(parameters, bicep0.Resource); 56.WithParameter("expr", ReferenceExpression.Create($"{param.Resource}/1")) 176await BicepProvisioner.SetParametersAsync(parameters0, bicep0.Resource); 177var checkSum0 = BicepProvisioner.GetChecksum(bicep0.Resource, parameters0); 183var checkSum1 = await BicepProvisioner.GetCurrentChecksumAsync(bicep1.Resource, config);
AzureBicepResourceTests.cs (149)
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); 345var connectionStringResource = (IResourceWithConnectionString)cosmos.Resource; 347Assert.Equal("cosmos", cosmos.Resource.Name); 364cosmos.Resource.Outputs["connectionString"] = "mycosmosconnectionstring"; 366var manifest = await ManifestUtils.GetManifestWithBicep(cosmos.Resource); 466var connectionStringResource = (IResourceWithConnectionString)cosmos.Resource; 468Assert.Equal("cosmos", cosmos.Resource.Name); 485cosmos.Resource.SecretOutputs["connectionString"] = "mycosmosconnectionstring"; 487var manifest = await ManifestUtils.GetManifestWithBicep(cosmos.Resource); 577var connectionStringResource = (IResourceWithConnectionString)cosmos.Resource; 579Assert.Equal("cosmos", cosmos.Resource.Name); 596cosmos.Resource.Outputs["connectionString"] = "mycosmosconnectionstring"; 598var manifest = await ManifestUtils.GetManifestWithBicep(cosmos.Resource); 696var connectionStringResource = (IResourceWithConnectionString)cosmos.Resource; 698Assert.Equal("cosmos", cosmos.Resource.Name); 708appConfig.Resource.Outputs["appConfigEndpoint"] = "https://myendpoint"; 709Assert.Equal("https://myendpoint", await appConfig.Resource.ConnectionStringExpression.GetValueAsync(default)); 711var manifest = await ManifestUtils.GetManifestWithBicep(appConfig.Resource); 713var connectionStringResource = (IResourceWithConnectionString)appConfig.Resource; 775appInsights.Resource.Outputs["appInsightsConnectionString"] = "myinstrumentationkey"; 777var connectionStringResource = (IResourceWithConnectionString)appInsights.Resource; 779Assert.Equal("appInsights", appInsights.Resource.Name); 781Assert.Equal("{appInsights.outputs.appInsightsConnectionString}", appInsights.Resource.ConnectionStringExpression.ValueExpression); 783var appInsightsManifest = await ManifestUtils.GetManifestWithBicep(appInsights.Resource); 832appInsights.Resource.Outputs["appInsightsConnectionString"] = "myinstrumentationkey"; 834var connectionStringResource = (IResourceWithConnectionString)appInsights.Resource; 836Assert.Equal("appInsights", appInsights.Resource.Name); 838Assert.Equal("{appInsights.outputs.appInsightsConnectionString}", appInsights.Resource.ConnectionStringExpression.ValueExpression); 840var appInsightsManifest = await ManifestUtils.GetManifestWithBicep(appInsights.Resource); 898appInsights.Resource.Outputs["appInsightsConnectionString"] = "myinstrumentationkey"; 900var connectionStringResource = (IResourceWithConnectionString)appInsights.Resource; 902Assert.Equal("appInsights", appInsights.Resource.Name); 904Assert.Equal("{appInsights.outputs.appInsightsConnectionString}", appInsights.Resource.ConnectionStringExpression.ValueExpression); 906var appInsightsManifest = await ManifestUtils.GetManifestWithBicep(appInsights.Resource); 955Assert.Equal("logAnalyticsWorkspace", logAnalyticsWorkspace.Resource.Name); 956Assert.Equal("{logAnalyticsWorkspace.outputs.logAnalyticsWorkspaceId}", logAnalyticsWorkspace.Resource.WorkspaceId.ValueExpression); 958var appInsightsManifest = await ManifestUtils.GetManifestWithBicep(logAnalyticsWorkspace.Resource); 997appInsights.Resource.Outputs["appInsightsConnectionString"] = "myinstrumentationkey"; 1002var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(serviceA.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance); 1023var manifest = await ManifestUtils.GetManifest(infrastructure1.Resource); 1048var manifest = await ManifestUtils.GetManifest(infrastructure1.Resource); 1087var manifest = await ManifestUtils.GetManifest(infrastructure1.Resource); 1117Assert.True(redis.Resource.IsContainer()); 1119Assert.Equal("localhost:12455", await redis.Resource.GetConnectionStringAsync()); 1121var manifest = await ManifestUtils.GetManifestWithBicep(redis.Resource); 1181var manifest = await ManifestUtils.GetManifestWithBicep(mykv.Resource); 1243var manifest = await ManifestUtils.GetManifestWithBicep(mykv.Resource); 1308var manifest = await ManifestUtils.GetManifestWithBicep(sql.Resource); 1310Assert.True(sql.Resource.TryGetLastAnnotation<ConnectionStringRedirectAnnotation>(out var connectionStringAnnotation)); 1314Assert.Equal("Server=tcp:myserver,1433;Encrypt=True;Authentication=\"Active Directory Default\"", await sql.Resource.GetConnectionStringAsync(default)); 1315Assert.Equal("Server=tcp:{sql.outputs.sqlServerFqdn},1433;Encrypt=True;Authentication=\"Active Directory Default\"", sql.Resource.ConnectionStringExpression.ValueExpression); 1402var manifest = await ManifestUtils.GetManifestWithBicep(sql.Resource); 1404Assert.True(sql.Resource.TryGetLastAnnotation<ConnectionStringRedirectAnnotation>(out var connectionStringAnnotation)); 1408Assert.Equal("Server=tcp:myserver,1433;Encrypt=True;Authentication=\"Active Directory Default\"", await sql.Resource.GetConnectionStringAsync(default)); 1409Assert.Equal("Server=tcp:{sql.outputs.sqlServerFqdn},1433;Encrypt=True;Authentication=\"Active Directory Default\"", sql.Resource.ConnectionStringExpression.ValueExpression); 1488Assert.True(postgres.Resource.TryGetLastAnnotation<ConnectionStringRedirectAnnotation>(out var connectionStringAnnotation)); 1492var manifest = await ManifestUtils.GetManifestWithBicep(postgres.Resource); 1497Assert.Equal("myconnectionstring", await postgres.Resource.GetConnectionStringAsync(default)); 1606Assert.True(postgres.Resource.TryGetLastAnnotation<ConnectionStringRedirectAnnotation>(out var connectionStringAnnotation)); 1610var manifest = await ManifestUtils.GetManifestWithBicep(postgres.Resource); 1615Assert.Equal("myconnectionstring", await postgres.Resource.GetConnectionStringAsync(default)); 1716var manifest = await ManifestUtils.GetManifestWithBicep(postgres.Resource); 1722Assert.Equal(expectedConnectionString, await postgres.Resource.GetConnectionStringAsync()); 1748var manifest = await ManifestUtils.GetManifest(postgres.Resource); 1768manifest = await ManifestUtils.GetManifest(postgres.Resource); 1787manifest = await ManifestUtils.GetManifest(postgres.Resource); 1832serviceBus.Resource.Outputs["serviceBusEndpoint"] = "mynamespaceEndpoint"; 1834var connectionStringResource = (IResourceWithConnectionString)serviceBus.Resource; 1836Assert.Equal("sb", serviceBus.Resource.Name); 1840var manifest = await ManifestUtils.GetManifestWithBicep(serviceBus.Resource); 1925wps.Resource.Outputs["endpoint"] = "https://mywebpubsubendpoint"; 1939var connectionStringResource = (IResourceWithConnectionString)wps.Resource; 1942var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource); 1945Assert.Equal("wps1", wps.Resource.Name); 1994wps.Resource.Outputs["endpoint"] = "https://mywebpubsubendpoint"; 2009var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource); 2012Assert.Equal("wps1", wps.Resource.Name); 2065Assert.True(storage.Resource.IsContainer()); 2072=> new(storage.Resource, new EndpointAnnotation(ProtocolType.Tcp, name: name, targetPort: port)); 2078Assert.Equal(blobqs, blob.Resource.ConnectionStringExpression.ValueExpression); 2079Assert.Equal(queueqs, queue.Resource.ConnectionStringExpression.ValueExpression); 2080Assert.Equal(tableqs, table.Resource.ConnectionStringExpression.ValueExpression); 2086Assert.Equal(Resolve(blobqs, "blob", 10000), await ((IResourceWithConnectionString)blob.Resource).GetConnectionStringAsync()); 2087Assert.Equal(Resolve(queueqs, "queue", 10001), await ((IResourceWithConnectionString)queue.Resource).GetConnectionStringAsync()); 2088Assert.Equal(Resolve(tableqs, "table", 10002), await ((IResourceWithConnectionString)table.Resource).GetConnectionStringAsync()); 2107storage.Resource.Outputs["blobEndpoint"] = "https://myblob"; 2108storage.Resource.Outputs["queueEndpoint"] = "https://myqueue"; 2109storage.Resource.Outputs["tableEndpoint"] = "https://mytable"; 2112Assert.Equal("storage", storage.Resource.Name); 2114var storageManifest = await ManifestUtils.GetManifestWithBicep(storage.Resource); 2206var connectionStringBlobResource = (IResourceWithConnectionString)blob.Resource; 2215var blobManifest = await ManifestUtils.GetManifest(blob.Resource); 2221var connectionStringQueueResource = (IResourceWithConnectionString)queue.Resource; 2230var queueManifest = await ManifestUtils.GetManifest(queue.Resource); 2236var connectionStringTableResource = (IResourceWithConnectionString)table.Resource; 2245var tableManifest = await ManifestUtils.GetManifest(table.Resource); 2266storage.Resource.Outputs["blobEndpoint"] = "https://myblob"; 2267storage.Resource.Outputs["queueEndpoint"] = "https://myqueue"; 2268storage.Resource.Outputs["tableEndpoint"] = "https://mytable"; 2271Assert.Equal("storage", storage.Resource.Name); 2273var storageManifest = await ManifestUtils.GetManifestWithBicep(storage.Resource); 2365var connectionStringBlobResource = (IResourceWithConnectionString)blob.Resource; 2374var blobManifest = await ManifestUtils.GetManifest(blob.Resource); 2380var connectionStringQueueResource = (IResourceWithConnectionString)queue.Resource; 2389var queueManifest = await ManifestUtils.GetManifest(queue.Resource); 2395var connectionStringTableResource = (IResourceWithConnectionString)table.Resource; 2404var tableManifest = await ManifestUtils.GetManifest(table.Resource); 2424storage.Resource.Outputs["blobEndpoint"] = "https://myblob"; 2425storage.Resource.Outputs["queueEndpoint"] = "https://myqueue"; 2426storage.Resource.Outputs["tableEndpoint"] = "https://mytable"; 2429Assert.Equal("storage", storage.Resource.Name); 2431var storageManifest = await ManifestUtils.GetManifestWithBicep(storage.Resource); 2523var connectionStringBlobResource = (IResourceWithConnectionString)blob.Resource; 2532var blobManifest = await ManifestUtils.GetManifest(blob.Resource); 2538var connectionStringQueueResource = (IResourceWithConnectionString)queue.Resource; 2547var queueManifest = await ManifestUtils.GetManifest(queue.Resource); 2553var connectionStringTableResource = (IResourceWithConnectionString)table.Resource; 2562var tableManifest = await ManifestUtils.GetManifest(table.Resource); 2583storage.Resource.Outputs["blobEndpoint"] = "https://myblob"; 2584storage.Resource.Outputs["queueEndpoint"] = "https://myqueue"; 2585storage.Resource.Outputs["tableEndpoint"] = "https://mytable"; 2588Assert.Equal("storage", storage.Resource.Name); 2590var storageManifest = await ManifestUtils.GetManifestWithBicep(storage.Resource); 2682var connectionStringBlobResource = (IResourceWithConnectionString)blob.Resource; 2691var blobManifest = await ManifestUtils.GetManifest(blob.Resource); 2697var connectionStringQueueResource = (IResourceWithConnectionString)queue.Resource; 2706var queueManifest = await ManifestUtils.GetManifest(queue.Resource); 2712var connectionStringTableResource = (IResourceWithConnectionString)table.Resource; 2721var tableManifest = await ManifestUtils.GetManifest(table.Resource); 2741search.Resource.Outputs["connectionString"] = fakeConnectionString; 2743var connectionStringResource = (IResourceWithConnectionString)search.Resource; 2746Assert.Equal("search", search.Resource.Name); 2750var manifest = await ManifestUtils.GetManifestWithBicep(search.Resource); 2833var aiManifest = await ManifestUtils.GetManifest(ai.Resource); 2837var serviceBusManifest = await ManifestUtils.GetManifest(serviceBus.Resource); 2841var serviceManifest = await ManifestUtils.GetManifest(serviceA.Resource); 2868var manifest = await ManifestUtils.GetManifestWithBicep(openai.Resource); 3023var (manifest, bicep) = await ManifestUtils.GetManifestWithBicep(provisioningResource.Resource);
AzureCosmosDBEmulatorFunctionalTests.cs (16)
51await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 53await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 57await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 59await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 177await rns.WaitForResourceHealthyAsync(db1.Resource.Name, cts.Token); 185[$"ConnectionStrings:{db1.Resource.Name}"] = await db1.Resource.ConnectionStringExpression.GetValueAsync(default) 188hb.AddAzureCosmosClient(db1.Resource.Name); 225await rns.WaitForResourceHealthyAsync(db2.Resource.Name, cts.Token); 233[$"ConnectionStrings:{db2.Resource.Name}"] = await db2.Resource.ConnectionStringExpression.GetValueAsync(default) 236hb.AddAzureCosmosClient(db2.Resource.Name); 293await rns.WaitForResourceHealthyAsync(cosmos.Resource.Name, cts.Token); 296hb.Configuration[$"ConnectionStrings:{cosmos.Resource.Name}"] = await cosmos.Resource.ConnectionStringExpression.GetValueAsync(default); 297hb.AddAzureCosmosClient(cosmos.Resource.Name);
AzureCosmosDBExtensionsTests.cs (3)
29var endpointAnnotation = cosmos.Resource.Annotations.OfType<EndpointAnnotation>().FirstOrDefault(); 50var containerImageAnnotation = cosmos.Resource.Annotations.OfType<ContainerImageAnnotation>().FirstOrDefault(); 67var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(cosmos.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance);
AzureEventHubsExtensionsTests.cs (13)
51await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 53await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 57await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 59await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 80hb.Configuration["ConnectionStrings:eventhubns"] = await eventHub.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None); 111var volumeAnnotation = eventHubs.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(a => !a.Target.Contains("Config.json")); 128var volumeAnnotation = eventHubs.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(a => !a.Target.Contains("Config.json")); 145var volumeAnnotation = eventHubs.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(a => !a.Target.Contains("Config.json")); 162var volumeAnnotation = eventHubs.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(a => !a.Target.Contains("Config.json")); 182eventHubs.Resource.Annotations.OfType<EndpointAnnotation>(), 204var containerImageAnnotation = eventHubs.Resource.Annotations.OfType<ContainerImageAnnotation>().FirstOrDefault(); 223var manifest = await ManifestUtils.GetManifestWithBicep(eventHubs.Resource); 297var manifest = await ManifestUtils.GetManifestWithBicep(eventHubs.Resource);
AzurePostgresExtensionsTests.cs (11)
22var manifest = await ManifestUtils.GetManifestWithBicep(postgres.Resource); 146var manifest = await ManifestUtils.GetManifestWithBicep(postgres.Resource); 154"administratorLogin": "{{{userName?.Resource.Name ?? "postgres-data-username"}}.value}", 155"administratorLoginPassword": "{{{password?.Resource.Name ?? "postgres-data-password"}}.value}", 280Assert.True(postgres.Resource.IsContainer(), "The resource should now be a container resource."); 281Assert.StartsWith("Host=localhost;Port=12455;Username=postgres;Password=", await postgres.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None)); 283var db1ConnectionString = await db1.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None); 287var db2ConnectionString = await db2.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None); 322Assert.Equal("Host=localhost;Port=12455;Username=user;Password=p@ssw0rd1", await postgres.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None)); 323Assert.Equal("Host=localhost;Port=12455;Username=user;Password=p@ssw0rd1;Database=db1", await db1.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None)); 324Assert.Equal("Host=localhost;Port=12455;Username=user;Password=p@ssw0rd1;Database=db2Name", await db2.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None));
AzureProvisioningResourceExtensionsTests.cs (1)
50var manifest = await ManifestUtils.GetManifestWithBicep(resource1.Resource);
AzureRedisExtensionsTests.cs (4)
20var manifest = await ManifestUtils.GetManifestWithBicep(redis.Resource); 88var manifest = await ManifestUtils.GetManifestWithBicep(redis.Resource); 152Assert.True(redis.Resource.IsContainer(), "The resource should now be a container resource."); 154Assert.Equal("localhost:12455", await redis.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None));
AzureServiceBusExtensionsTests.cs (12)
43var manifest = await ManifestUtils.GetManifestWithBicep(serviceBus.Resource); 138var manifest = await ManifestUtils.GetManifestWithBicep(serviceBus.Resource); 212await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 214await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 218await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 220await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 242hb.Configuration["ConnectionStrings:servicebusns"] = await serviceBus.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None); 249await rns.WaitForResourceAsync(serviceBus.Resource.Name, KnownResourceStates.Running, cts.Token); 250await rns.WaitForResourceHealthyAsync(serviceBus.Resource.Name, cts.Token); 276serviceBus.Resource.Annotations.OfType<EndpointAnnotation>(), 298var containerImageAnnotation = serviceBus.Resource.Annotations.OfType<ContainerImageAnnotation>().FirstOrDefault(); 372var manifest = await ManifestUtils.GetManifestWithBicep(serviceBus.Resource);
AzureSignalREmulatorFunctionalTest.cs (8)
30Assert.True(signalR.Resource.IsEmulator); 32var connectionStringExpr = signalR.Resource.ConnectionStringExpression; 37Assert.Equal(connectionString, await ((IResourceWithConnectionString)signalR.Resource).GetConnectionStringAsync()); 63await rns.WaitForResourceAsync(signalR.Resource.Name, KnownResourceStates.Running, cts.Token); 64await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 68await rns.WaitForResourceHealthyAsync(signalR.Resource.Name, cts.Token); 70await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 101var connectionString = await signalR.Resource.ConnectionStringExpression.GetValueAsync(default);
AzureSignalRExtensionsTests.cs (2)
21var manifest = await ManifestUtils.GetManifestWithBicep(signalr.Resource); 93var manifest = await ManifestUtils.GetManifestWithBicep(signalr.Resource);
AzureSqlExtensionsTests.cs (5)
25var manifest = await ManifestUtils.GetManifestWithBicep(sql.Resource); 161Assert.True(sql.Resource.IsContainer(), "The resource should now be a container resource."); 162var serverConnectionString = await sql.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None); 166var db1ConnectionString = await db1.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None); 170var db2ConnectionString = await db2.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None);
AzureStorageEmulatorFunctionalTests.cs (7)
50await rns.WaitForResourceAsync(storage.Resource.Name, KnownResourceStates.Running, cts.Token); 52await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 56await rns.WaitForResourceHealthyAsync(blobs.Resource.Name, cts.Token); 57await rns.WaitForResourceHealthyAsync(queues.Resource.Name, cts.Token); 58await rns.WaitForResourceHealthyAsync(tables.Resource.Name, cts.Token); 60await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 78hb.Configuration["ConnectionStrings:BlobConnection"] = await storage.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None);
AzureStorageExtensionsTests.cs (7)
32var volumeAnnotation = storage.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 58var volumeAnnotation = storage.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 84var volumeAnnotation = storage.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 110var volumeAnnotation = storage.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 129storage.Resource.Annotations.OfType<EndpointAnnotation>(), 143var args = await ArgumentEvaluator.GetArgumentListAsync(storage.Resource); 163var args = await ArgumentEvaluator.GetArgumentListAsync(storage.Resource);
AzureWebPubSubExtensionsTests.cs (15)
37Assert.Equal(hubName, hub.Resource.Name); 38var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource); 63var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource); 69Assert.Equal("wps1", wps.Resource.Name); 138var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource); 144Assert.Equal("wps1", wps.Resource.Name); 213var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource); 219Assert.Equal("wps1", wps.Resource.Name); 289wps.Resource.Outputs["endpoint"] = "https://mywebpubsubendpoint"; 290var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource); 295Assert.Equal("wps1", wps.Resource.Name); 375wps.Resource.Outputs["endpoint"] = "https://mywebpubsubendpoint"; 392var connectionStringResource = (IResourceWithConnectionString)wps.Resource; 395var manifest = await ManifestUtils.GetManifestWithBicep(wps.Resource); 402Assert.Equal("wps1", wps.Resource.Name);
Aspire.Hosting.Azure.WebPubSub (4)
AzureWebPubSubExtensions.cs (4)
126if (!builder.Resource.Hubs.TryGetValue(hubName, out hubResource)) 128hubResource = new AzureWebPubSubHubResource(hubName, builder.Resource); 129builder.Resource.Hubs[hubName] = hubResource; 168builder.Resource.EventHandlers.Add((urlExpression, userEventPattern, systemEvents, authSettings));
Aspire.Hosting.Containers.Tests (30)
ContainerResourceBuilderTests.cs (16)
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); 152var annotation = redis.Resource.Annotations.OfType<ContainerImageAnnotation>().Single(); 164var annotation = redis.Resource.Annotations.OfType<ContainerImageAnnotation>().Single(); 177var annotation = redis.Resource.Annotations.OfType<ContainerImageAnnotation>().Single(); 207var containerImage = builder.Resource.Annotations.OfType<ContainerImageAnnotation>().Single();
ContainerResourceTests.cs (2)
116var args = await ArgumentEvaluator.GetArgumentListAsync(c2.Resource); 123var manifest = await ManifestUtils.GetManifest(c2.Resource);
WithDockerfileTests.cs (12)
173var manifest = await ManifestUtils.GetManifest(container.Resource, manifestDirectory: tempContextPath); 220var manifest = await ManifestUtils.GetManifest(container.Resource, manifestDirectory: tempContextPath); 266var manifest = await ManifestUtils.GetManifest(container.Resource, manifestDirectory: tempContextPath); 311var manifest = await ManifestUtils.GetManifest(container.Resource, manifestDirectory: tempContextPath); 538var annotation = Assert.Single(container.Resource.Annotations.OfType<DockerfileBuildAnnotation>()); 553var annotation = Assert.Single(container.Resource.Annotations.OfType<DockerfileBuildAnnotation>()); 569var annotation = Assert.Single(container.Resource.Annotations.OfType<DockerfileBuildAnnotation>()); 584var annotation = Assert.Single(container.Resource.Annotations.OfType<DockerfileBuildAnnotation>()); 600var annotation = Assert.Single(container.Resource.Annotations.OfType<DockerfileBuildAnnotation>()); 615var annotation = Assert.Single(container.Resource.Annotations.OfType<DockerfileBuildAnnotation>()); 631var annotation = Assert.Single(container.Resource.Annotations.OfType<DockerfileBuildAnnotation>()); 646var annotation = Assert.Single(container.Resource.Annotations.OfType<DockerfileBuildAnnotation>());
Aspire.Hosting.Dapr (3)
IDistributedApplicationComponentBuilderExtensions.cs (3)
60var sidecarBuilder = builder.ApplicationBuilder.AddResource(new DaprSidecarResource($"{builder.Resource.Name}-dapr")) 70return builder.WithAnnotation(new DaprSidecarAnnotation(sidecarBuilder.Resource)); 94return builder.WithAnnotation(new DaprComponentReferenceAnnotation(component.Resource));
Aspire.Hosting.Elasticsearch (1)
ElasticsearchBuilderExtensions.cs (1)
54var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password");
Aspire.Hosting.Elasticsearch.Tests (21)
AddElasticsearchTests.cs (3)
151Assert.Equal($"http://elastic:{elasticsearch.Resource.PasswordParameter.Value}@localhost:27020", connectionString); 162var manifest = await ManifestUtils.GetManifest(elasticsearch.Resource); 201var manifest = await ManifestUtils.GetManifest(elasticsearch.Resource);
ElasticsearchFunctionalTests.cs (17)
46await rns.WaitForResourceHealthyAsync(elasticsearch.Resource.Name, cts.Token); 50hb.Configuration[$"ConnectionStrings:{elasticsearch.Resource.Name}"] = await elasticsearch.Resource.ConnectionStringExpression.GetValueAsync(default); 52hb.AddElasticsearchClient(elasticsearch.Resource.Name); 89var password = elasticsearch1.Resource.PasswordParameter.Value; 111await rns.WaitForResourceHealthyAsync(elasticsearch1.Resource.Name, cts.Token); 117hb.Configuration[$"ConnectionStrings:{elasticsearch1.Resource.Name}"] = await elasticsearch1.Resource.ConnectionStringExpression.GetValueAsync(default); 119hb.AddElasticsearchClient(elasticsearch1.Resource.Name); 169await rns.WaitForResourceHealthyAsync(elasticsearch2.Resource.Name, cts.Token); 175hb.Configuration[$"ConnectionStrings:{elasticsearch2.Resource.Name}"] = await elasticsearch2.Resource.ConnectionStringExpression.GetValueAsync(default); 177hb.AddElasticsearchClient(elasticsearch2.Resource.Name); 261await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 263await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 267await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 269await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token);
ElasticsearchPublicApiTests.cs (1)
80var action = () => new ElasticsearchResource(name, password.Resource);
Aspire.Hosting.Garnet.Tests (20)
AddGarnetTests.cs (9)
93var manifest = await ManifestUtils.GetManifest(garnet.Resource); 130var volumeAnnotation = garnet.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 155var volumeAnnotation = garnet.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 170Assert.True(garnet.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 189var persistenceAnnotation = garnet.Resource.Annotations.OfType<CommandLineArgsCallbackAnnotation>().SingleOrDefault(); 201Assert.True(garnet.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 220var persistenceAnnotation = garnet.Resource.Annotations.OfType<CommandLineArgsCallbackAnnotation>().SingleOrDefault(); 233Assert.True(garnet.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 252Assert.True(garnet.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsAnnotations));
GarnetFunctionalTests.cs (11)
44await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 46await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 50await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 52await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 78hb.Configuration[$"ConnectionStrings:{garnet.Resource.Name}"] = await garnet.Resource.ConnectionStringExpression.GetValueAsync(default); 80hb.AddRedisClient(garnet.Resource.Name); 157hb.Configuration[$"ConnectionStrings:{garnet1.Resource.Name}"] = $"{await garnet1.Resource.ConnectionStringExpression.GetValueAsync(default)}"; 208hb.Configuration[$"ConnectionStrings:{garnet2.Resource.Name}"] = $"{await garnet2.Resource.ConnectionStringExpression.GetValueAsync(default)}";
Aspire.Hosting.Kafka (1)
KafkaBuilderExtensions.cs (1)
104containerName ??= $"{builder.Resource.Name}-kafka-ui";
Aspire.Hosting.Kafka.Tests (15)
AddKafkaTests.cs (5)
81var manifest = await ManifestUtils.GetManifest(kafka.Resource); 121var config = await kafka.Resource.GetEnvironmentVariableValuesAsync(); 123var volumeAnnotation = kafka.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 139var config = await kafka.Resource.GetEnvironmentVariableValuesAsync(); 141var volumeAnnotation = kafka.Resource.Annotations.OfType<ContainerMountAnnotation>().Single();
KafkaFunctionalTests.cs (10)
45await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 47await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 51await rns.WaitForResourceHealthyAsync(resource.Resource.Name).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 53await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 76hb.Configuration[$"ConnectionStrings:{kafka.Resource.Name}"] = await kafka.Resource.ConnectionStringExpression.GetValueAsync(default); 169hb.Configuration[$"ConnectionStrings:{kafka1.Resource.Name}"] = await kafka1.Resource.ConnectionStringExpression.GetValueAsync(default); 221hb.Configuration[$"ConnectionStrings:{kafka2.Resource.Name}"] = await kafka2.Resource.ConnectionStringExpression.GetValueAsync(default);
Aspire.Hosting.Keycloak (2)
KeycloakResourceBuilderExtensions.cs (2)
56var passwordParameter = adminPassword?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password"); 58var resource = new KeycloakResource(name, adminUsername?.Resource, passwordParameter);
Aspire.Hosting.Keycloak.Tests (8)
KeycloakPublicApiTests.cs (3)
19var action = () => new KeycloakResource(name, default(ParameterResource?), adminPassword.Resource); 156var containerAnnotation = keycloak.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 191var containerAnnotation = keycloak.Resource.Annotations.OfType<ContainerMountAnnotation>().Single();
KeycloakResourceBuilderTests.cs (5)
66var volumeAnnotation = keycloak.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 81var volumeAnnotation = keycloak.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 96Assert.Equal("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", rmq.Resource.AdminPasswordParameter.Default?.GetType().FullName); 106Assert.NotEqual("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", rmq.Resource.AdminPasswordParameter.Default?.GetType().FullName); 115var manifest = await ManifestUtils.GetManifest(keycloak.Resource);
Aspire.Hosting.Milvus (5)
MilvusBuilderExtensions.cs (5)
49var apiKeyParameter = apiKey?.Resource ?? 102builder.Resource.AddDatabase(name, databaseName); 103var milvusDatabaseResource = new MilvusDatabaseResource(name, databaseName, builder.Resource); 134containerName ??= $"{builder.Resource.Name}-attu"; 141.WithEnvironment(context => ConfigureAttuContainer(context, builder.Resource))
Aspire.Hosting.Milvus.Tests (18)
AddMilvusTests.cs (5)
86var connectionStringResource = milvus.Resource as IResourceWithConnectionString; 106var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectA.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance); 117var containerConfig = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(container1.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance); 133var serverManifest = await ManifestUtils.GetManifest(milvus.Resource); // using this method does not get any ExecutionContext.IsPublishMode changes 134var dbManifest = await ManifestUtils.GetManifest(db1.Resource);
MilvusFunctionalTests.cs (13)
32await app.WaitForTextAsync("Milvus Proxy successfully initialized and ready to serve", milvus.Resource.Name); 36hb.Configuration[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default); 38hb.AddMilvusClient(db.Resource.Name); 81var password = milvus1.Resource.ApiKeyParameter.Value; 104await app.WaitForTextAsync("Milvus Proxy successfully initialized and ready to serve", milvus1.Resource.Name); 110hb.Configuration[$"ConnectionStrings:{db1.Resource.Name}"] = await db1.Resource.ConnectionStringExpression.GetValueAsync(default); 112hb.AddMilvusClient(db1.Resource.Name); 151await app.WaitForTextAsync("Milvus Proxy successfully initialized and ready to serve", milvus2.Resource.Name); 157hb.Configuration[$"ConnectionStrings:{db2.Resource.Name}"] = await db2.Resource.ConnectionStringExpression.GetValueAsync(default); 159hb.AddMilvusClient(db2.Resource.Name);
Aspire.Hosting.MongoDB (6)
MongoDBBuilderExtensions.cs (6)
58var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password", special: false); 60var mongoDBContainer = new MongoDBServerResource(name, userName?.Resource, passwordParameter); 110builder.Resource.AddDatabase(name, databaseName); 111var mongoDBDatabase = new MongoDBDatabaseResource(name, databaseName, builder.Resource); 153containerName ??= $"{builder.Resource.Name}-mongoexpress"; 159.WithEnvironment(context => ConfigureMongoExpressContainer(context, builder.Resource))
Aspire.Hosting.MongoDB.Tests (27)
AddMongoDBTests.cs (10)
196var mongoManifest = await ManifestUtils.GetManifest(mongo.Resource); 197var dbManifest = await ManifestUtils.GetManifest(db.Resource); 262Assert.Equal("customers1", db1.Resource.DatabaseName); 263Assert.Equal("customers2", db2.Resource.DatabaseName); 265Assert.Equal("mongodb://admin:{mongo1-password.value}@{mongo1.bindings.tcp.host}:{mongo1.bindings.tcp.port}/customers1?authSource=admin&authMechanism=SCRAM-SHA-256", db1.Resource.ConnectionStringExpression.ValueExpression); 266Assert.Equal("mongodb://admin:{mongo1-password.value}@{mongo1.bindings.tcp.host}:{mongo1.bindings.tcp.port}/customers2?authSource=admin&authMechanism=SCRAM-SHA-256", db2.Resource.ConnectionStringExpression.ValueExpression); 280Assert.Equal("imports", db1.Resource.DatabaseName); 281Assert.Equal("imports", db2.Resource.DatabaseName); 283Assert.Equal("mongodb://admin:{mongo1-password.value}@{mongo1.bindings.tcp.host}:{mongo1.bindings.tcp.port}/imports?authSource=admin&authMechanism=SCRAM-SHA-256", db1.Resource.ConnectionStringExpression.ValueExpression); 284Assert.Equal("mongodb://admin:{mongo2-password.value}@{mongo2.bindings.tcp.host}:{mongo2.bindings.tcp.port}/imports?authSource=admin&authMechanism=SCRAM-SHA-256", db2.Resource.ConnectionStringExpression.ValueExpression);
MongoDbFunctionalTests.cs (17)
56await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 58await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 62await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 64await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 89hb.Configuration[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default); 91hb.AddMongoDBClient(db.Resource.Name); 125var password = mongodb1.Resource.PasswordParameter!.Value; 150hb.Configuration[$"ConnectionStrings:{db1.Resource.Name}"] = await db1.Resource.ConnectionStringExpression.GetValueAsync(default); 152hb.AddMongoDBClient(db1.Resource.Name); 196hb.Configuration[$"ConnectionStrings:{db2.Resource.Name}"] = await db2.Resource.ConnectionStringExpression.GetValueAsync(default); 198hb.AddMongoDBClient(db2.Resource.Name); 317hb.Configuration[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default); 319hb.AddMongoDBClient(db.Resource.Name);
Aspire.Hosting.MySql (4)
MySqlBuilderExtensions.cs (4)
34var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password"); 79builder.Resource.AddDatabase(name, databaseName); 80var mySqlDatabase = new MySqlDatabaseResource(name, databaseName, builder.Resource); 103containerName ??= $"{builder.Resource.Name}-phpmyadmin";
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); 160var mySqlManifest = await ManifestUtils.GetManifest(mysql.Resource); 161var dbManifest = await ManifestUtils.GetManifest(db.Resource); 199var serverManifest = await ManifestUtils.GetManifest(mysql.Resource); 248Assert.Equal($"{mysql.Resource.Name}:{mysql.Resource.PrimaryEndpoint.TargetPort}", config["PMA_HOST"]); 289string pattern1 = $@"\$cfg\['Servers'\]\[\$i\]\['host'\] = '{mysql1.Resource.Name}:{mysql1.Resource.PrimaryEndpoint.TargetPort}';"; 290string pattern2 = $@"\$cfg\['Servers'\]\[\$i\]\['host'\] = '{mysql2.Resource.Name}:{mysql2.Resource.PrimaryEndpoint.TargetPort}';"; 330Assert.Equal(["db1", "db2"], mysql1.Resource.Databases.Keys); 331Assert.Equal(["customers1", "customers2"], mysql1.Resource.Databases.Values); 333Assert.Equal("customers1", db1.Resource.DatabaseName); 334Assert.Equal("customers2", db2.Resource.DatabaseName); 336Assert.Equal("{mysql1.connectionString};Database=customers1", db1.Resource.ConnectionStringExpression.ValueExpression); 337Assert.Equal("{mysql1.connectionString};Database=customers2", db2.Resource.ConnectionStringExpression.ValueExpression); 351Assert.Equal("imports", db1.Resource.DatabaseName); 352Assert.Equal("imports", db2.Resource.DatabaseName); 354Assert.Equal("{mysql1.connectionString};Database=imports", db1.Resource.ConnectionStringExpression.ValueExpression); 355Assert.Equal("{mysql2.connectionString};Database=imports", db2.Resource.ConnectionStringExpression.ValueExpression);
MySqlFunctionalTests.cs (20)
52await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 54await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 58await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 60await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 93[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default) 96hb.AddMySqlDataSource(db.Resource.Name); 135var password = mysql1.Resource.PasswordParameter.Value; 166[$"ConnectionStrings:{db1.Resource.Name}"] = await db1.Resource.ConnectionStringExpression.GetValueAsync(default) 169hb.AddMySqlDataSource(db1.Resource.Name); 235[$"ConnectionStrings:{db2.Resource.Name}"] = await db2.Resource.ConnectionStringExpression.GetValueAsync(default) 238hb.AddMySqlDataSource(db2.Resource.Name); 341[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default) 344hb.AddMySqlDataSource(db.Resource.Name); 411[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default) 414hb.AddMySqlDbContext<TestDbContext>(db.Resource.Name);
Aspire.Hosting.Nats (2)
NatsBuilderExtensions.cs (2)
55var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password", special: false); 57var nats = new NatsServerResource(name, userName?.Resource, passwordParameter);
Aspire.Hosting.Nats.Tests (33)
AddNatsTests.cs (12)
21Assert.Equal("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", nats.Resource.PasswordParameter!.Default?.GetType().FullName); 31Assert.NotEqual("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", nats.Resource.PasswordParameter!.Default?.GetType().FullName); 42Assert.NotNull(nats.Resource.PasswordParameter); 43Assert.False(string.IsNullOrEmpty(nats.Resource.PasswordParameter!.Value)); 68Assert.NotNull(nats.Resource.UserNameParameter); 69Assert.NotNull(nats.Resource.PasswordParameter); 71Assert.Equal("usr", nats.Resource.UserNameParameter!.Value); 72Assert.Equal("password", nats.Resource.PasswordParameter!.Value); 188var manifest = await ManifestUtils.GetManifest(nats.Resource); 225var manifest = await ManifestUtils.GetManifest(nats.Resource); 253manifest = await ManifestUtils.GetManifest(nats.Resource); 280manifest = await ManifestUtils.GetManifest(nats.Resource);
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; 124await app.WaitForTextAsync("Listening for client connections", nats.Resource.Name); 128var connectionString = await nats.Resource.ConnectionStringExpression.GetValueAsync(default); 133hb.Configuration[$"ConnectionStrings:{nats.Resource.Name}"] = modifiedConnectionString; 185await app.WaitForTextAsync("Listening for client connections", nats1.Resource.Name); 190hb.Configuration[$"ConnectionStrings:{nats1.Resource.Name}"] = await nats1.Resource.ConnectionStringExpression.GetValueAsync(default); 233await app.WaitForTextAsync("Listening for client connections", nats2.Resource.Name); 238hb.Configuration[$"ConnectionStrings:{nats2.Resource.Name}"] = await nats2.Resource.ConnectionStringExpression.GetValueAsync(default); 345await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 347await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 351await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 353await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token);
NatsPublicApiTests.cs (2)
106var action = () => new NatsServerResource(name, user.Resource, password.Resource);
Aspire.Hosting.NodeJs.Tests (2)
AddNodeAppTests.cs (2)
19var manifest = await ManifestUtils.GetManifest(nodeApp.Resource); 48manifest = await ManifestUtils.GetManifest(npmApp.Resource);
Aspire.Hosting.Oracle (3)
OracleDatabaseBuilderExtensions.cs (3)
30var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password"); 73builder.Resource.AddDatabase(name, databaseName); 74var oracleDatabase = new OracleDatabaseResource(name, databaseName, builder.Resource);
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); 200var serverManifest = await ManifestUtils.GetManifest(oracleServer.Resource); 201var dbManifest = await ManifestUtils.GetManifest(db.Resource); 239var serverManifest = await ManifestUtils.GetManifest(oracleServer.Resource); 295Assert.Equal("customers1", db1.Resource.DatabaseName); 296Assert.Equal("customers2", db2.Resource.DatabaseName); 298Assert.Equal("{oracle1.connectionString}/customers1", db1.Resource.ConnectionStringExpression.ValueExpression); 299Assert.Equal("{oracle1.connectionString}/customers2", db2.Resource.ConnectionStringExpression.ValueExpression); 313Assert.Equal("imports", db1.Resource.DatabaseName); 314Assert.Equal("imports", db2.Resource.DatabaseName); 316Assert.Equal("{oracle1.connectionString}/imports", db1.Resource.ConnectionStringExpression.ValueExpression); 317Assert.Equal("{oracle2.connectionString}/imports", db2.Resource.ConnectionStringExpression.ValueExpression);
OracleFunctionalTests.cs (17)
52hb.Configuration[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default); 54hb.AddOracleDatabaseDbContext<TestDbContext>(db.Resource.Name); 99var password = oracle1.Resource.PasswordParameter.Value; 135hb.Configuration[$"ConnectionStrings:{db1.Resource.Name}"] = await db1.Resource.ConnectionStringExpression.GetValueAsync(default); 137hb.AddOracleDatabaseDbContext<TestDbContext>(db1.Resource.Name); 195hb.Configuration[$"ConnectionStrings:{db2.Resource.Name}"] = await db2.Resource.ConnectionStringExpression.GetValueAsync(default); 197hb.AddOracleDatabaseDbContext<TestDbContext>(db2.Resource.Name); 309hb.Configuration[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default); 311hb.AddOracleDatabaseDbContext<TestDbContext>(db.Resource.Name); 374await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 376await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 380await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 382await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token);
Aspire.Hosting.Orleans (7)
OrleansServiceExtensions.cs (5)
55orleansServiceBuilder.ClusterId = clusterId.Resource; 83orleansServiceBuilder.ServiceId = serviceId.Resource; 131=> WithGrainStorage(orleansServiceBuilder, provider.Resource.Name, provider); 183=> WithStreaming(orleansServiceBuilder, provider.Resource.Name, provider); 299=> WithGrainDirectory(orleansServiceBuilder, provider.Resource.Name, provider);
ProviderConfiguration.cs (2)
21var serviceKey = resourceBuilder.Resource.Name; 22var resourceType = resourceBuilder.Resource.GetType().Name;
Aspire.Hosting.PostgreSQL (8)
PostgresBuilderExtensions.cs (8)
49var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password"); 51var postgresServer = new PostgresServerResource(name, userName?.Resource, passwordParameter); 119builder.Resource.AddDatabase(name, databaseName); 120var postgresDatabase = new PostgresDatabaseResource(name, databaseName, builder.Resource); 146containerName ??= $"{builder.Resource.Name}-pgadmin"; 209pgAdminContainerBuilder.WithRelationship(builder.Resource, "PgAdmin"); 280containerName ??= $"{builder.Resource.Name}-pgweb"; 294pgwebContainerBuilder.WithRelationship(builder.Resource, "PgWeb");
Aspire.Hosting.PostgreSQL.Tests (49)
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); 158var connectionStringResource = postgres.Resource as IResourceWithConnectionString; 162Assert.Equal($"Host=localhost;Port=2000;Username=postgres;Password={postgres.Resource.PasswordParameter.Value}", connectionString); 249var serverManifest = await ManifestUtils.GetManifest(pgServer.Resource); 250var dbManifest = await ManifestUtils.GetManifest(db.Resource); 293var serverManifest = await ManifestUtils.GetManifest(pgServer.Resource); 319serverManifest = await ManifestUtils.GetManifest(pgServer.Resource); 345serverManifest = await ManifestUtils.GetManifest(pgServer.Resource); 474Assert.Equal(pg1.Resource.Name, servers.GetProperty("1").GetProperty("Name").GetString()); 481Assert.Equal($"echo '{pg1.Resource.PasswordParameter.Value}'", servers.GetProperty("1").GetProperty("PasswordExecCommand").GetString()); 484Assert.Equal(pg2.Resource.Name, servers.GetProperty("2").GetProperty("Name").GetString()); 491Assert.Equal($"echo '{pg2.Resource.PasswordParameter.Value}'", servers.GetProperty("2").GetProperty("PasswordExecCommand").GetString()); 539Assert.Equal(CreatePgWebBookmarkfileContent(db1.Resource), content); 543Assert.Equal(CreatePgWebBookmarkfileContent(db2.Resource), content); 580Assert.Equal("customers1", db1.Resource.DatabaseName); 581Assert.Equal("customers2", db2.Resource.DatabaseName); 583Assert.Equal("{postgres1.connectionString};Database=customers1", db1.Resource.ConnectionStringExpression.ValueExpression); 584Assert.Equal("{postgres1.connectionString};Database=customers2", db2.Resource.ConnectionStringExpression.ValueExpression); 598Assert.Equal("imports", db1.Resource.DatabaseName); 599Assert.Equal("imports", db2.Resource.DatabaseName); 601Assert.Equal("{postgres1.connectionString};Database=imports", db1.Resource.ConnectionStringExpression.ValueExpression); 602Assert.Equal("{postgres2.connectionString};Database=imports", db2.Resource.ConnectionStringExpression.ValueExpression);
PostgrePublicApiTests.cs (3)
80var postgresParentResource = new PostgresServerResource("PostgresServer", default(ParameterResource?), parameterResource.Resource); 95var postgresParentResource = new PostgresServerResource("PostgresServer", default(ParameterResource?), parameterResource.Resource); 123var action = () => new PostgresServerResource(name, default(ParameterResource?), password.Resource);
PostgresFunctionalTests.cs (22)
56await rns.WaitForResourceAsync(postgres.Resource.Name, KnownResourceStates.Running).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 59await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 65await rns.WaitForResourceHealthyAsync(postgres.Resource.Name).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 68await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 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"); 233await rns.WaitForResourceHealthyAsync(db1.Resource.Name, cts.Token); 241[$"ConnectionStrings:{db1.Resource.Name}"] = await db1.Resource.ConnectionStringExpression.GetValueAsync(default) 244hb.AddNpgsqlDataSource(db1.Resource.Name); 297await rns.WaitForResourceHealthyAsync(db2.Resource.Name, cts.Token); 305[$"ConnectionStrings:{db2.Resource.Name}"] = await db2.Resource.ConnectionStringExpression.GetValueAsync(default) 308hb.AddNpgsqlDataSource(db2.Resource.Name); 397[$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default) 400hb.AddNpgsqlDataSource(db.Resource.Name);
Aspire.Hosting.Python.Tests (3)
AddPythonAppTests.cs (3)
34var manifest = await ManifestUtils.GetManifest(pyproj.Resource, manifestDirectory: projectDirectory); 66var manifest = await ManifestUtils.GetManifest(pyproj.Resource, manifestDirectory: projectDirectory); 126var environmentVariables = await pyproj.Resource.GetEnvironmentVariableValuesAsync(DistributedApplicationOperation.Run);
Aspire.Hosting.Qdrant (5)
QdrantBuilderExtensions.cs (5)
47var apiKeyParameter = apiKey?.Resource ?? 138context.EnvironmentVariables[$"ConnectionStrings__{qdrantResource.Resource.Name}"] = qdrantResource.Resource.ConnectionStringExpression; 141context.EnvironmentVariables[$"ConnectionStrings__{qdrantResource.Resource.Name}_{QdrantServerResource.HttpEndpointName}"] = qdrantResource.Resource.HttpConnectionStringExpression;
Aspire.Hosting.Qdrant.Tests (20)
AddQdrantTests.cs (7)
25Assert.Equal("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", qd.Resource.ApiKeyParameter.Default?.GetType().FullName); 35Assert.NotEqual("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", qd.Resource.ApiKeyParameter.Default?.GetType().FullName); 159var connectionStringResource = qdrant.Resource as IResourceWithConnectionString; 180var config = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(projectA.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance); 192var containerConfig = await EnvironmentVariableEvaluator.GetEnvironmentVariablesAsync(container1.Resource, DistributedApplicationOperation.Run, TestServiceProvider.Instance); 207var serverManifest = await ManifestUtils.GetManifest(qdrant.Resource); // using this method does not get any ExecutionContext.IsPublishMode changes 245var serverManifest = await ManifestUtils.GetManifest(qdrant.Resource); // using this method does not get any ExecutionContext.IsPublishMode changes
QdrantFunctionalTests.cs (13)
46[$"ConnectionStrings:{qdrant.Resource.Name}"] = await qdrant.Resource.ConnectionStringExpression.GetValueAsync(default) 49hb.AddQdrantClient(qdrant.Resource.Name); 130[$"ConnectionStrings:{qdrant1.Resource.Name}"] = await qdrant1.Resource.ConnectionStringExpression.GetValueAsync(default) 133hb.AddQdrantClient(qdrant1.Resource.Name); 175[$"ConnectionStrings:{qdrant2.Resource.Name}"] = await qdrant2.Resource.ConnectionStringExpression.GetValueAsync(default) 178hb.AddQdrantClient(qdrant2.Resource.Name); 247await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 249await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 253await rns.WaitForResourceAsync(resource.Resource.Name, (re => re.Snapshot.HealthStatus == HealthStatus.Healthy), cts.Token); 255await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token);
Aspire.Hosting.RabbitMQ (5)
RabbitMQBuilderExtensions.cs (5)
39var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password", special: false); 41var rabbitMq = new RabbitMQServerResource(name, userName?.Resource, passwordParameter); 153var containerAnnotations = builder.Resource.Annotations.OfType<ContainerImageAnnotation>().ToList(); 202throw new DistributedApplicationException($"Cannot configure the RabbitMQ resource '{builder.Resource.Name}' to enable the management plugin as it uses an unrecognized container image registry, name, or tag."); 256var nodeName = $"{builder.Resource.Name}@localhost";
Aspire.Hosting.RabbitMQ.Tests (20)
AddRabbitMQTests.cs (6)
21Assert.Equal("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", rmq.Resource.PasswordParameter.Default?.GetType().FullName); 31Assert.NotEqual("Aspire.Hosting.ApplicationModel.UserSecretsParameterDefault", rmq.Resource.PasswordParameter.Default?.GetType().FullName); 203var manifest = await ManifestUtils.GetManifest(rabbit.Resource); 249var manifest = await ManifestUtils.GetManifest(rabbit.Resource); 273manifest = await ManifestUtils.GetManifest(rabbit.Resource); 297manifest = await ManifestUtils.GetManifest(rabbit.Resource);
RabbitMQFunctionalTests.cs (14)
46await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 48await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 52await rns.WaitForResourceHealthyAsync(resource.Resource.Name).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 54await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 74hb.Configuration[$"ConnectionStrings:{rabbitMQ.Resource.Name}"] = await rabbitMQ.Resource.ConnectionStringExpression.GetValueAsync(default); 75hb.AddRabbitMQClient(rabbitMQ.Resource.Name); 111var password = rabbitMQ1.Resource.PasswordParameter.Value; 134hb.Configuration[$"ConnectionStrings:{rabbitMQ1.Resource.Name}"] = await rabbitMQ1.Resource.ConnectionStringExpression.GetValueAsync(default); 136hb.AddRabbitMQClient(rabbitMQ1.Resource.Name); 191hb.Configuration[$"ConnectionStrings:{rabbitMQ2.Resource.Name}"] = await rabbitMQ2.Resource.ConnectionStringExpression.GetValueAsync(default); 193hb.AddRabbitMQClient(rabbitMQ2.Resource.Name);
Aspire.Hosting.Redis (3)
RedisBuilderExtensions.cs (3)
89containerName ??= $"{builder.Resource.Name}-commander"; 128resourceBuilder.WithRelationship(builder.Resource, "RedisCommander"); 156containerName ??= $"{builder.Resource.Name}-insight";
Aspire.Hosting.Redis.Tests (59)
AddRedisTests.cs (12)
20Assert.Single(redis.Resource.Annotations, a => a is HealthCheckAnnotation hca && hca.Key == "redis_check"); 102var manifest = await ManifestUtils.GetManifest(redis.Resource); 225Assert.Equal($"myredis1:{redis.Resource.Name}:6379:0", config["REDIS_HOSTS"]); 249Assert.Equal($"myredis1:{redis1.Resource.Name}:6379:0,myredis2:myredis2:6379:0", config["REDIS_HOSTS"]); 269var volumeAnnotation = redis.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 294var volumeAnnotation = redis.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 309Assert.True(redis.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 328var persistenceAnnotation = redis.Resource.Annotations.OfType<CommandLineArgsCallbackAnnotation>().SingleOrDefault(); 340Assert.True(redis.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 359var persistenceAnnotation = redis.Resource.Annotations.OfType<CommandLineArgsCallbackAnnotation>().SingleOrDefault(); 372Assert.True(redis.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 391Assert.True(redis.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsAnnotations));
RedisFunctionalTests.cs (47)
51await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 53await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 57await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 59await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 80await app.WaitForTextAsync("Redis Connection", resourceName: commanderBuilder.Resource.Name); 82var client = app.CreateHttpClient(commanderBuilder.Resource.Name, "http"); 85var path = $"/apiv2/server/R:{redis.Resource.Name}:{endpoint.TargetPort}:0/info"; 106[$"ConnectionStrings:{redis.Resource.Name}"] = await redis.Resource.GetConnectionStringAsync() 109hb.AddRedisClient(redis.Resource.Name); 159builder1.Eventing.Subscribe<ResourceReadyEvent>(redisInsightBuilder.Resource, (evt, ct) => 171using var client1 = app1.CreateHttpClient($"{redis1.Resource.Name}-insight", "http"); 176Assert.Equal($"{redis1.Resource.Name}", firstRunDatabases[0].Name); 197builder2.Eventing.Subscribe<ResourceReadyEvent>(redisInsightBuilder.Resource, (evt, ct) => 208using var client2 = app2.CreateHttpClient($"{redisInsightBuilder.Resource.Name}", "http"); 213Assert.Equal($"{redis2.Resource.Name}", secondRunDatabases[0].Name); 225var latestEvent = await rns.WaitForResourceHealthyAsync(redisInsightBuilder.Resource.Name, cts.Token); 249builder.Eventing.Subscribe<ResourceReadyEvent>(redisInsightBuilder.Resource, (evt, ct) => 261var client = app.CreateHttpClient(redisInsightBuilder.Resource.Name, "http"); 272Assert.Equal(redis1.Resource.Name, db.Name); 273Assert.Equal(redis1.Resource.Name, db.Host); 274Assert.Equal(redis1.Resource.PrimaryEndpoint.TargetPort, db.Port); 280Assert.Equal(redis2.Resource.Name, db.Name); 281Assert.Equal(redis2.Resource.Name, db.Host); 282Assert.Equal(redis2.Resource.PrimaryEndpoint.TargetPort, db.Port); 319[$"ConnectionStrings:{redis1.Resource.Name}"] = $"{await redis1.Resource.GetConnectionStringAsync()},allowAdmin=true" 322hb.AddRedisClient(redis1.Resource.Name); 355[$"ConnectionStrings:{redis2.Resource.Name}"] = await redis2.Resource.GetConnectionStringAsync() 358hb.AddRedisClient(redis2.Resource.Name); 405[$"ConnectionStrings:{redis1.Resource.Name}"] = $"{await redis1.Resource.GetConnectionStringAsync()},allowAdmin=true" 408hb.AddRedisClient(redis1.Resource.Name); 440[$"ConnectionStrings:{redis2.Resource.Name}"] = await redis2.Resource.GetConnectionStringAsync() 443hb.AddRedisClient(redis2.Resource.Name); 489[$"ConnectionStrings:{redis1.Resource.Name}"] = $"{await redis1.Resource.GetConnectionStringAsync()},allowAdmin=true" 492hb.AddRedisClient(redis1.Resource.Name); 519[$"ConnectionStrings:{redis2.Resource.Name}"] = await redis2.Resource.GetConnectionStringAsync() 522hb.AddRedisClient(redis2.Resource.Name); 583builder1.Eventing.Subscribe<ResourceReadyEvent>(redisInsightBuilder1.Resource, (evt, ct) => 593var httpClient = app.CreateHttpClient(redisInsightBuilder1.Resource.Name, "http"); 626builder2.Eventing.Subscribe<ResourceReadyEvent>(redisInsightBuilder2.Resource, (evt, ct) => 636var httpClient = app.CreateHttpClient(redisInsightBuilder2.Resource.Name, "http");
Aspire.Hosting.SqlServer (3)
SqlServerBuilderExtensions.cs (3)
32var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password", minLower: 1, minUpper: 1, minNumeric: 1); 78builder.Resource.AddDatabase(name, databaseName); 79var sqlServerDatabase = new SqlServerDatabaseResource(name, databaseName, builder.Resource);
Aspire.Hosting.SqlServer.Tests (30)
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); 130var serverManifest = await ManifestUtils.GetManifest(sqlServer.Resource); 131var dbManifest = await ManifestUtils.GetManifest(db.Resource); 171var serverManifest = await ManifestUtils.GetManifest(sqlServer.Resource); 228Assert.Equal("customers1", db1.Resource.DatabaseName); 229Assert.Equal("customers2", db2.Resource.DatabaseName); 231Assert.Equal("{sqlserver1.connectionString};Database=customers1", db1.Resource.ConnectionStringExpression.ValueExpression); 232Assert.Equal("{sqlserver1.connectionString};Database=customers2", db2.Resource.ConnectionStringExpression.ValueExpression); 246Assert.Equal("imports", db1.Resource.DatabaseName); 247Assert.Equal("imports", db2.Resource.DatabaseName); 249Assert.Equal("{sqlserver1.connectionString};Database=imports", db1.Resource.ConnectionStringExpression.ValueExpression); 250Assert.Equal("{sqlserver2.connectionString};Database=imports", db2.Resource.ConnectionStringExpression.ValueExpression);
SqlServerFunctionalTests.cs (17)
46await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 48await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 52await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 54await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token); 81hb.Configuration[$"ConnectionStrings:{tempDb.Resource.Name}"] = await tempDb.Resource.ConnectionStringExpression.GetValueAsync(default); 83hb.AddSqlServerDbContext<TestDbContext>(tempDb.Resource.Name); 84hb.AddSqlServerClient(tempDb.Resource.Name); 140var password = sqlserver1.Resource.PasswordParameter.Value; 181await rns.WaitForResourceHealthyAsync(masterdb1.Resource.Name, cts.Token); 189[$"ConnectionStrings:{masterdb1.Resource.Name}"] = await masterdb1.Resource.ConnectionStringExpression.GetValueAsync(default), 192hb1.AddSqlServerClient(masterdb1.Resource.Name); 266await rns.WaitForResourceHealthyAsync(masterdb2.Resource.Name, cts.Token); 274[$"ConnectionStrings:{masterdb2.Resource.Name}"] = await masterdb2.Resource.ConnectionStringExpression.GetValueAsync(default), 277hb2.AddSqlServerClient(masterdb2.Resource.Name);
Aspire.Hosting.Testing.Tests (1)
tests\Aspire.Hosting.Tests\Utils\LoggerNotificationExtensions.cs (1)
36await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cancellationToken);
Aspire.Hosting.Tests (192)
AddParameterTests.cs (3)
106parameter.Resource.Default = new TestParameterDefault("DefaultValue"); 286Assert.IsType<UserSecretsParameterDefault>(parameter1.Resource.Default); 290Assert.IsType<GenerateParameterDefault>(parameter2.Resource.Default);
Codespaces\CodespacesUrlRewriterTests.cs (2)
77await rns.PublishUpdateAsync(resource.Resource, s => s with 85resource.Resource.Name,
Dashboard\DashboardResourceTests.cs (1)
105Assert.Same(container.Resource, dashboard);
Dcp\DcpExecutorTests.cs (4)
55.WithReplicas(2).Resource; 1007HasKnownCommandAnnotations(exe.Resource); 1008HasKnownCommandAnnotations(container.Resource); 1009HasKnownCommandAnnotations(project.Resource);
DistributedApplicationTests.cs (7)
245using var clientA = app.CreateHttpClient(testProgram.ServiceABuilder.Resource.Name, "http"); 246using var clientC = app.CreateHttpClient(testProgram.ServiceCBuilder.Resource.Name, "http"); 253var uri = app.GetEndpoint(testProgram.ServiceBBuilder.Resource.Name, "http"); 807var httpEndPoint = app.GetEndpoint(testProgram.ServiceABuilder.Resource.Name, endpointName: "http"); 825var httpsEndpoint = app.GetEndpoint(testProgram.ServiceABuilder.Resource.Name, endpointName: "https"); 872using var clientA = app.CreateHttpClient(servicea.Resource.Name, "http"); 923using var clientA = app.CreateHttpClient(servicea.Resource.Name, "http");
Eventing\DistributedApplicationBuilderEventingTests.cs (1)
182builder.Eventing.Subscribe<BeforeResourceStartedEvent>(redis.Resource, (e, ct) =>
ExecutableResourceTests.cs (2)
39var args = await ArgumentEvaluator.GetArgumentListAsync(exe2.Resource).DefaultTimeout(); 51var manifest = await ManifestUtils.GetManifest(exe2.Resource).DefaultTimeout();
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 (30)
35await rns.PublishUpdateAsync(resource.Resource, s => s with 43await rns.PublishUpdateAsync(resource.Resource, s => s with 76await rns.PublishUpdateAsync(resource.Resource, s => s with 84await rns.PublishUpdateAsync(resource.Resource, s => s with 115builder.Eventing.Subscribe<ResourceReadyEvent>(resource.Resource, (@event, ct) => 128await rns.PublishUpdateAsync(resource.Resource, s => s with 137Assert.Equal(resource.Resource, e1.Resource); 143await rns.PublishUpdateAsync(resource.Resource, s => s with 151await rns.PublishUpdateAsync(resource.Resource, s => s with 165Assert.Equal(resource.Resource, e2.Resource); 195await rns.PublishUpdateAsync(resource.Resource, s => s with 199await rns.WaitForResourceHealthyAsync(resource.Resource.Name, abortTokenSource.Token).DefaultTimeout(); 238await rns.PublishUpdateAsync(resource.Resource, s => s with 282await rns.PublishUpdateAsync(resource.Resource, s => s with 286await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, abortTokenSource.Token).DefaultTimeout(); 309builder.Eventing.Subscribe<ResourceReadyEvent>(resource.Resource, (@event, ct) => 319await rns.PublishUpdateAsync(resource.Resource, s => s with 325Assert.Equal(resource.Resource, @event.Resource); 351await rns.PublishUpdateAsync(resource.Resource, s => s with 389builder.Eventing.Subscribe<ResourceReadyEvent>(parent.Resource, (@event, ct) => 415await rns.PublishUpdateAsync(parent.Resource, s => s with 449builder.Eventing.Subscribe<ResourceReadyEvent>(parent.Resource, (@event, ct) => 463await rns.PublishUpdateAsync(parent.Resource, s => s with 496builder.Eventing.Subscribe<ResourceReadyEvent>(parent.Resource, (@event, ct) => 502var child = builder.AddResource(new ChildResource("child", parent.Resource)); 505builder.Eventing.Subscribe<ResourceReadyEvent>(child.Resource, (@event, ct) => 516await rns.PublishUpdateAsync(parent.Resource, s => s with 524await rns.PublishUpdateAsync(child.Resource, s => s with 530Assert.Equal(parentReadyEvent.Resource, parent.Resource); 533Assert.Equal(childReadyEvent.Resource, child.Resource);
HealthCheckTests.cs (4)
88await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running).DefaultTimeout(TestConstants.DefaultOrchestratorTestLongTimeout); 90await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting).DefaultTimeout(TestConstants.DefaultOrchestratorTestLongTimeout); 94await rns.WaitForResourceHealthyAsync(resource.Resource.Name).DefaultTimeout(TestConstants.DefaultOrchestratorTestLongTimeout); 96await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running).DefaultTimeout(TestConstants.DefaultOrchestratorTestLongTimeout);
ManifestGenerationTests.cs (3)
100var redisManifest = await ManifestUtils.GetManifest(redis.Resource).DefaultTimeout(); 462param.Resource.Default = new GenerateParameterDefault() 500var manifest = await ManifestUtils.GetManifest(param.Resource).DefaultTimeout();
Orchestrator\ApplicationOrchestratorTests.cs (5)
24var childResource = builder.AddResource(new CustomChildResource("child", parentResource.Resource)); 41if (item.Resource == parentResource.Resource) 45else if (item.Resource == childResource.Resource) 57await events.PublishAsync(new OnResourceStartingContext(CancellationToken.None, KnownResourceTypes.Container, parentResource.Resource, parentResource.Resource.Name));
ProjectResourceTests.cs (1)
587var args = await ArgumentEvaluator.GetArgumentListAsync(project.Resource).DefaultTimeout();
PublishAsConnectionStringTests.cs (2)
19Assert.True(redis.Resource.TryGetLastAnnotation<ManifestPublishingCallbackAnnotation>(out _)); 21var manifest = await ManifestUtils.GetManifest(redis.Resource).DefaultTimeout();
PublishAsDockerfileTests.cs (3)
29var manifest = await ManifestUtils.GetManifest(frontend.Resource, manifestDirectory: path).DefaultTimeout(); 169var manifest = await ManifestUtils.GetManifest(frontend.Resource, manifestDirectory: path).DefaultTimeout(); 228var manifest = await ManifestUtils.GetManifest(project.Resource, manifestDirectory: path).DefaultTimeout();
ResourceCommandAnnotationTests.cs (2)
44resourceBuilder.Resource.AddLifeCycleCommands(); 46var startCommand = resourceBuilder.Resource.Annotations.OfType<ResourceCommandAnnotation>().Single(a => a.Name == commandName);
ResourceExtensionsTests.cs (30)
18Assert.False(parent.Resource.HasAnnotationOfType<DummyAnnotation>()); 19Assert.False(parent.Resource.TryGetAnnotationsOfType<DummyAnnotation>(out var annotations)); 30Assert.False(parent.Resource.HasAnnotationOfType<DummyAnnotation>()); 31Assert.False(parent.Resource.TryGetAnnotationsOfType<DummyAnnotation>(out var annotations)); 42Assert.True(parent.Resource.HasAnnotationOfType<DummyAnnotation>()); 43Assert.True(parent.Resource.TryGetAnnotationsOfType<DummyAnnotation>(out var annotations)); 54Assert.True(parent.Resource.HasAnnotationIncludingAncestorsOfType<DummyAnnotation>()); 55Assert.True(parent.Resource.TryGetAnnotationsIncludingAncestorsOfType<DummyAnnotation>(out var annotations)); 65Assert.False(parent.Resource.HasAnnotationIncludingAncestorsOfType<DummyAnnotation>()); 66Assert.False(parent.Resource.TryGetAnnotationsIncludingAncestorsOfType<DummyAnnotation>(out var annotations)); 77Assert.False(parent.Resource.HasAnnotationIncludingAncestorsOfType<DummyAnnotation>()); 78Assert.False(parent.Resource.TryGetAnnotationsIncludingAncestorsOfType<DummyAnnotation>(out var annotations)); 89var child = builder.AddResource(new ChildResource("child", parent.Resource)) 92Assert.False(parent.Resource.HasAnnotationIncludingAncestorsOfType<DummyAnnotation>()); 93Assert.False(child.Resource.TryGetAnnotationsIncludingAncestorsOfType<DummyAnnotation>(out var annotations)); 104var child = builder.AddResource(new ChildResource("child", parent.Resource)); 106Assert.True(parent.Resource.HasAnnotationIncludingAncestorsOfType<DummyAnnotation>()); 107Assert.True(child.Resource.TryGetAnnotationsIncludingAncestorsOfType<DummyAnnotation>(out var annotations)); 118var child = builder.AddResource(new ChildResource("child", parent.Resource)) 121Assert.True(parent.Resource.HasAnnotationIncludingAncestorsOfType<DummyAnnotation>()); 122Assert.True(child.Resource.TryGetAnnotationsIncludingAncestorsOfType<DummyAnnotation>(out var annotations)); 133var child = builder.AddResource(new ChildResource("child", parent: parent.Resource)) 136var grandchild = builder.AddResource(new ChildResource("grandchild", parent: child.Resource)) 139Assert.True(parent.Resource.HasAnnotationIncludingAncestorsOfType<DummyAnnotation>()); 140Assert.True(grandchild.Resource.TryGetAnnotationsIncludingAncestorsOfType<DummyAnnotation>(out var annotations)); 150Assert.True(container.Resource.TryGetContainerImageName(out var imageName)); 160Assert.True(container.Resource.TryGetContainerImageName(out var imageName)); 176var env = await container.Resource.GetEnvironmentVariableValuesAsync().DefaultTimeout(); 209var env = await container.Resource.GetEnvironmentVariableValuesAsync().DefaultTimeout(); 242var env = await container.Resource.GetEnvironmentVariableValuesAsync(DistributedApplicationOperation.Publish).DefaultTimeout();
ResourceNotificationTests.cs (1)
29var annotation = custom.Resource.Annotations.OfType<ResourceSnapshotAnnotation>().SingleOrDefault();
SlimTestProgramTests.cs (5)
34using var clientA = app.CreateHttpClient(testProgram.ServiceABuilder.Resource.Name, "http"); 37using var clientB = app.CreateHttpClient(testProgram.ServiceBBuilder.Resource.Name, "http"); 40using var clientC = app.CreateHttpClient(testProgram.ServiceCBuilder.Resource.Name, "http"); 56var endpoint = projectBuilders.Resource.Annotations.OfType<EndpointAnnotation>().Single(); 74var endpoint = projectBuilders.Resource.Annotations.OfType<EndpointAnnotation>().Single();
TestProgramFixture.cs (3)
69using var clientA = App.CreateHttpClient(TestProgram.ServiceABuilder.Resource.Name, "http"); 73using var clientB = App.CreateHttpClient(TestProgram.ServiceBBuilder.Resource.Name, "http"); 77using var clientC = App.CreateHttpClient(TestProgram.ServiceCBuilder.Resource.Name, "http");
Utils\LoggerNotificationExtensions.cs (1)
36await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cancellationToken);
Utils\VolumeNameGeneratorTests.cs (3)
23Assert.Equal($"{volumePrefix}-{resource.Resource.Name}-data", volumeName); 67Assert.Equal($"{runVolumePrefix}-{runResource.Resource.Name}-data", runVolumeName); 68Assert.Equal($"{publishVolumePrefix}-{publishResource.Resource.Name}-data", publishVolumeName);
Utils\WithAnnotationTests.cs (4)
18var dummyAnnotations = redis.Resource.Annotations.OfType<DummyAnnotation>(); 32var dummyAnnotations = redis.Resource.Annotations.OfType<DummyAnnotation>(); 44var firstAnnotation = redis.Resource.Annotations.OfType<DummyAnnotation>().Single(); 48var secondAnnotation = redis.Resource.Annotations.OfType<DummyAnnotation>().Single();
WaitForTests.cs (29)
33await rns.WaitForResourceAsync(throwingResource.Resource.Name, KnownResourceStates.FailedToStart, abortCts.Token); 34await rns.WaitForResourceAsync(dependingContainerResource.Resource.Name, KnownResourceStates.FailedToStart, abortCts.Token); 35await rns.WaitForResourceAsync(dependingExecutableResource.Resource.Name, KnownResourceStates.FailedToStart, abortCts.Token); 66var childResourceBuilder = builder.AddResource(new CustomChildResource("child", parentResourceBuilder.Resource)); 109await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Waiting, waitingStateCts.Token); 111await rns.PublishUpdateAsync(dependency.Resource, s => s with 148await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Waiting, waitingStateCts.Token); 153await rns.PublishUpdateAsync(dependency.Resource, s => s with 189await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Waiting, waitingStateCts.Token); 194await rns.PublishUpdateAsync(dependency.Resource, s => s with 204await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Running, runningStateCts.Token); 237await rns.WaitForResourceAsync(nginx.Resource.Name, "Waiting", waitingStateCts.Token); 242await rns.PublishUpdateAsync(dependency.Resource, s => s with 252await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.FailedToStart, runningStateCts.Token); 276builder.Eventing.Subscribe<ResourceReadyEvent>(dependency.Resource, (e, ct) => resourceReadyTcs.Task); 293await rns.WaitForResourceAsync(nginx.Resource.Name, "Waiting", waitingStateCts.Token); 298await rns.PublishUpdateAsync(dependency.Resource, s => s with 309await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.FailedToStart, runningStateCts.Token); 348await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Waiting, waitingStateCts.Token); 353await rns.PublishUpdateAsync(dependency.Resource, s => s with 362await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.FailedToStart, runningStateCts.Token); 397await rns.WaitForResourceAsync(nginx.Resource.Name, "FailedToStart", waitingStateCts.Token); 431await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Waiting, waitingStateCts.Token); 434await rns.PublishUpdateAsync(dependency.Resource, s => s with 439await rns.WaitForResourceAsync(nginx.Resource.Name, KnownResourceStates.Running, waitingStateCts.Token); 451var childResource = builder.AddResource(new CustomChildResource("child", parentResource.Resource)); 455Assert.True(containerResource.Resource.TryGetAnnotationsOfType<WaitAnnotation>(out var waitAnnotations)); 459a => Assert.Equal(a.Resource, parentResource.Resource), 460a => Assert.Equal(a.Resource, childResource.Resource)
WithEndpointTests.cs (17)
29var endpoint = projectA.Resource.Annotations.OfType<EndpointAnnotation>() 46var endpoint = projectA.Resource.Annotations.OfType<EndpointAnnotation>() 81var endpoint = projectA.Resource.Annotations.OfType<EndpointAnnotation>() 119Assert.False(projectA.Resource.TryGetAnnotationsOfType<EndpointAnnotation>(out var annotations)); 136Assert.True(projectA.Resource.TryGetAnnotationsOfType<EndpointAnnotation>(out _)); 153Assert.True(projectA.Resource.TryGetAnnotationsOfType<EndpointAnnotation>(out _)); 272var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 300var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 327var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 354var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 381var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 408var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 435var manifest = await ManifestUtils.GetManifest(container.Resource).DefaultTimeout(); 466var manifest = await ManifestUtils.GetManifest(project.Resource).DefaultTimeout(); 536var manifest = await ManifestUtils.GetManifest(project.Resource).DefaultTimeout(); 563var manifests = await ManifestUtils.GetManifests([container0.Resource, container1.Resource]).DefaultTimeout();
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)
AddValkeyTests.cs (9)
93var manifest = await ManifestUtils.GetManifest(valkey.Resource); 130var volumeAnnotation = valkey.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 155var volumeAnnotation = valkey.Resource.Annotations.OfType<ContainerMountAnnotation>().Single(); 170Assert.True(valkey.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 189var persistenceAnnotation = valkey.Resource.Annotations.OfType<CommandLineArgsCallbackAnnotation>().SingleOrDefault(); 201Assert.True(valkey.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 220var persistenceAnnotation = valkey.Resource.Annotations.OfType<CommandLineArgsCallbackAnnotation>().SingleOrDefault(); 233Assert.True(valkey.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsCallbacks)); 252Assert.True(valkey.Resource.TryGetAnnotationsOfType<CommandLineArgsCallbackAnnotation>(out var argsAnnotations));
ValkeyFunctionalTests.cs (13)
36[$"ConnectionStrings:{valkey.Resource.Name}"] = await valkey.Resource.ConnectionStringExpression.GetValueAsync(default) 39hb.AddRedisClient(valkey.Resource.Name); 97[$"ConnectionStrings:{valkey1.Resource.Name}"] = $"{await valkey1.Resource.ConnectionStringExpression.GetValueAsync(default)},allowAdmin=true" 100hb.AddRedisClient(valkey1.Resource.Name); 148[$"ConnectionStrings:{valkey2.Resource.Name}"] = await valkey2.Resource.ConnectionStringExpression.GetValueAsync(default) 151hb.AddRedisClient(valkey2.Resource.Name); 221await rns.WaitForResourceAsync(resource.Resource.Name, KnownResourceStates.Running, cts.Token); 223await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Waiting, cts.Token); 227await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cts.Token); 229await rns.WaitForResourceAsync(dependentResource.Resource.Name, KnownResourceStates.Running, cts.Token);
Aspire.Playground.Tests (1)
tests\Aspire.Hosting.Tests\Utils\LoggerNotificationExtensions.cs (1)
36await rns.WaitForResourceHealthyAsync(resource.Resource.Name, cancellationToken);
BicepSample.AppHost (1)
Program.cs (1)
25temp00 = bicep0.Resource;
KafkaBasic.AppHost (2)
Program.cs (2)
11.WithArgs(kafka.Resource.Name); 15.WithArgs(kafka.Resource.Name);
Mongo.AppHost (2)
Program.cs (2)
14builder.Eventing.Subscribe<ResourceReadyEvent>(db.Resource, async (@event, ct) => 20var cs = await db.Resource.ConnectionStringExpression.GetValueAsync(ct);
Stress.AppHost (5)
Program.cs (2)
19IResource parent = rb.Resource; 25parent = nestedRb.Resource;
ResourceBuilderExtensions.cs (3)
43var endpoints = builder.Resource.GetEndpoints(); 45?? throw new DistributedApplicationException($"Could not create HTTP command for resource '{builder.Resource.Name}' as no endpoint named '{endpointName}' was found."); 58return new ExecuteCommandResult { Success = false, ErrorMessage = $"The endpoint named '{endpointName}' on resource '{builder.Resource.Name}' does not have the expected scheme of '{expectedScheme}'." };