Skip to content
Docs Try Aspire

DistributedApplicationHostingTestingExtensions Methods

Class Methods 4 members
Extensions for working with Hosting.DistributedApplication in test code.
CreateHttpClient(DistributedApplication, string, string?) Section titled CreateHttpClient(DistributedApplication, string, string?) extension HttpClient
Creates an Http.HttpClient configured to communicate with the specified resource.
public static class DistributedApplicationHostingTestingExtensions
{
public static HttpClient CreateHttpClient(
this DistributedApplication app,
string resourceName,
string? endpointName = null)
{
// ...
}
}
app DistributedApplication The application.
resourceName string The resourceName of the resource.
endpointName string? optional The resourceName of the endpoint on the resource to communicate with.
HttpClient The Http.HttpClient.
GetConnectionStringAsync(DistributedApplication, string, CancellationToken) Section titled GetConnectionStringAsync(DistributedApplication, string, CancellationToken) extension ValueTask<string?>
Gets the connection string for the specified resource.
public static class DistributedApplicationHostingTestingExtensions
{
public static ValueTask<string?> GetConnectionStringAsync(
this DistributedApplication app,
string resourceName,
CancellationToken cancellationToken = default(CancellationToken))
{
// ...
}
}
app DistributedApplication The application.
resourceName string The resource name.
cancellationToken CancellationToken optional A Threading.CancellationToken.
ValueTask<string?> The connection string for the specified resource.
ArgumentException The resource was not found or does not expose a connection string.
GetEndpoint(DistributedApplication, string, string?) Section titled GetEndpoint(DistributedApplication, string, string?) extension Uri
Gets the endpoint for the specified resource.
public static class DistributedApplicationHostingTestingExtensions
{
public static Uri GetEndpoint(
this DistributedApplication app,
string resourceName,
string? endpointName = null)
{
// ...
}
}
app DistributedApplication The application.
resourceName string The resource name.
endpointName string? optional The optional endpoint name. If none are specified, the single defined endpoint is returned.
Uri A URI representation of the endpoint.
ArgumentException The resource was not found, no matching endpoint was found, or multiple endpoints were found.
InvalidOperationException The resource has no endpoints.
GetEndpointForNetwork(DistributedApplication, string, NetworkIdentifier?, string?) Section titled GetEndpointForNetwork(DistributedApplication, string, NetworkIdentifier?, string?) extension Uri
Gets the endpoint for the specified resource.
public static class DistributedApplicationHostingTestingExtensions
{
public static Uri GetEndpointForNetwork(
this DistributedApplication app,
string resourceName,
NetworkIdentifier? networkIdentifier,
string? endpointName = null)
{
// ...
}
}
app DistributedApplication The application.
resourceName string The resource name.
networkIdentifier NetworkIdentifier? The optional network identifier. If none is specified, the default network is used.
endpointName string? optional The optional endpoint name. If none are specified, the single defined endpoint is returned.
Uri A URI representation of the endpoint.
ArgumentException The resource was not found, no matching endpoint was found, or multiple endpoints were found.
InvalidOperationException The resource has no endpoints.