Skip to content
Docs Try Aspire

DistributedApplicationFactory Methods

Class Methods 6 members
Factory for creating a distributed application for testing.
CreateHttpClient(string, string?) Section titled CreateHttpClient(string, string?) HttpClient
Creates an instance of Http.HttpClient that is configured to route requests to the specified resource and endpoint.
public class DistributedApplicationFactory
{
public HttpClient CreateHttpClient(
string resourceName,
string? endpointName = null)
{
// ...
}
}
resourceName string
endpointName string? optional
HttpClient The Http.HttpClient.
Dispose Section titled Dispose virtual
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public class DistributedApplicationFactory
{
public virtual void Dispose()
{
// ...
}
}
DisposeAsync Section titled DisposeAsync virtual ValueTask
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public class DistributedApplicationFactory
{
public virtual ValueTask DisposeAsync()
{
// ...
}
}
ValueTask A task that represents the asynchronous dispose operation.
GetConnectionString(string) Section titled GetConnectionString(string) ValueTask<string?>
Gets the connection string for the specified resource.
public class DistributedApplicationFactory
{
public ValueTask<string?> GetConnectionString(
string resourceName)
{
// ...
}
}
resourceName string The resource name.
ValueTask<string?> The connection string for the specified resource.
ArgumentException The resource was not found or does not expose a connection string.
GetEndpoint(string, string?) Section titled GetEndpoint(string, string?) Uri
Gets the endpoint for the specified resource.
public class DistributedApplicationFactory
{
public Uri GetEndpoint(
string resourceName,
string? endpointName = null)
{
// ...
}
}
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.
StartAsync(CancellationToken) Section titled StartAsync(CancellationToken) Task
Starts the application.
public class DistributedApplicationFactory
{
public Task StartAsync(
CancellationToken cancellationToken = default(CancellationToken))
{
// ...
}
}
cancellationToken CancellationToken optional A token used to signal cancellation.
Task A Tasks.Task representing the completion of the operation.