diff --git a/src/Microsoft.AspNetCore.Mvc.Testing/WebApplicationFactory.cs b/src/Microsoft.AspNetCore.Mvc.Testing/WebApplicationFactory.cs
index bd3ff2c023..f1edf8fc04 100644
--- a/src/Microsoft.AspNetCore.Mvc.Testing/WebApplicationFactory.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Testing/WebApplicationFactory.cs
@@ -95,7 +95,6 @@ namespace Microsoft.AspNetCore.Mvc.Testing
CreateServer,
CreateWebHostBuilder,
GetTestAssemblies,
- CreateDefaultClient,
builder =>
{
_configuration(builder);
@@ -301,11 +300,20 @@ namespace Microsoft.AspNetCore.Mvc.Testing
/// A list of instances to set up on the
/// .
/// The .
- public virtual HttpClient CreateDefaultClient(params DelegatingHandler[] handlers)
+ public HttpClient CreateDefaultClient(params DelegatingHandler[] handlers) =>
+ CreateDefaultClient(new Uri("http://localhost"), handlers);
+
+ ///
+ /// Creates a new instance of an that can be used to
+ /// send to the server.
+ ///
+ /// The base address of the instance.
+ /// A list of instances to set up on the
+ /// .
+ /// The .
+ public HttpClient CreateDefaultClient(Uri baseAddress, params DelegatingHandler[] handlers)
{
EnsureServer();
-
- var baseAddress = new Uri("http://localhost");
if (handlers == null || handlers.Length == 0)
{
var client = _server.CreateClient();
@@ -334,22 +342,6 @@ namespace Microsoft.AspNetCore.Mvc.Testing
}
}
- ///
- /// Creates a new instance of an that can be used to
- /// send to the server.
- ///
- /// The base address of the instance.
- /// A list of instances to set up on the
- /// .
- /// The .
- public HttpClient CreateDefaultClient(Uri baseAddress, params DelegatingHandler[] handlers)
- {
- var client = CreateDefaultClient(handlers);
- client.BaseAddress = baseAddress;
-
- return client;
- }
-
///
public void Dispose()
{
@@ -394,21 +386,18 @@ namespace Microsoft.AspNetCore.Mvc.Testing
private readonly Func _createServer;
private readonly Func _createWebHostBuilder;
private readonly Func> _getTestAssemblies;
- private readonly Func _createDefaultClient;
public DelegatedWebApplicationFactory(
WebApplicationFactoryClientOptions options,
Func createServer,
Func createWebHostBuilder,
Func> getTestAssemblies,
- Func createClient,
Action configureWebHost)
{
ClientOptions = new WebApplicationFactoryClientOptions(options);
_createServer = createServer;
_createWebHostBuilder = createWebHostBuilder;
_getTestAssemblies = getTestAssemblies;
- _createDefaultClient = createClient;
_configuration = configureWebHost;
}
@@ -419,8 +408,6 @@ namespace Microsoft.AspNetCore.Mvc.Testing
protected override IEnumerable GetTestAssemblies() => _getTestAssemblies();
protected override void ConfigureWebHost(IWebHostBuilder builder) => _configuration(builder);
-
- public override HttpClient CreateDefaultClient(params DelegatingHandler[] handlers) => _createDefaultClient(handlers);
}
}
}