Skip to content

Commit

Permalink
Add ability to stop in-memory hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
idg10 committed Jan 13, 2023
1 parent 154486c commit cabb9f9
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class OpenApiWebHostManager
/// your startup class has executed. You can use this to swap out services for stubs or fakes.
/// </param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public Task StartInProcessFunctionsHostAsync<TFunctionStartup>(
public Task<IWebHost> StartInProcessFunctionsHostAsync<TFunctionStartup>(
string baseUrl,
Action<IServiceCollection>? additionalServiceConfigurationCallback = null)
where TFunctionStartup : class, IWebJobsStartup, new()
Expand All @@ -78,7 +78,7 @@ public Task StartInProcessFunctionsHostAsync<TFunctionStartup>(
/// your startup class has executed. You can use this to swap out services for stubs or fakes.
/// </param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public Task StartInProcessFunctionsHostAsync<TFunctionStartup>(
public Task<IWebHost> StartInProcessFunctionsHostAsync<TFunctionStartup>(
string baseUrl,
IConfiguration configuration,
Action<IServiceCollection>? additionalServiceConfigurationCallback = null)
Expand All @@ -98,7 +98,7 @@ public Task StartInProcessFunctionsHostAsync<TFunctionStartup>(
/// your startup class has executed. You can use this to swap out services for stubs or fakes.
/// </param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public Task StartInProcessFunctionsHostAsync<TFunctionStartup>(
public Task<IWebHost> StartInProcessFunctionsHostAsync<TFunctionStartup>(
TFunctionStartup startupInstance,
string baseUrl,
Action<IServiceCollection>? additionalServiceConfigurationCallback = null)
Expand Down Expand Up @@ -136,7 +136,7 @@ public Task StartInProcessFunctionsHostAsync<TFunctionStartup>(
/// your startup class has executed. You can use this to swap out services for stubs or fakes.
/// </param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public Task StartInProcessFunctionsHostAsync<TFunctionStartup>(
public Task<IWebHost> StartInProcessFunctionsHostAsync<TFunctionStartup>(
TFunctionStartup startupInstance,
string baseUrl,
IConfiguration configuration,
Expand Down Expand Up @@ -184,7 +184,7 @@ public Task StartInProcessFunctionsHostAsync<TFunctionStartup>(
/// because that's the only way to ensure that your configuration will run after Startup. (The ASP.NET
/// web host startup prefers to run the Startup methods after all other configuration has occurred.)
/// </remarks>
public Task StartInProcessAspNetHostAsync<TStartup>(
public Task<IWebHost> StartInProcessAspNetHostAsync<TStartup>(
string baseUrl,
TStartup startupInstance)
where TStartup : class
Expand Down Expand Up @@ -217,7 +217,7 @@ public async Task StopAllHostsAsync()
/// A callback that will allow you to configure the <see cref="IWebHostBuilder"/> for your service.
/// </param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
private Task StartAspNetHostAsync(
private async Task<IWebHost> StartAspNetHostAsync(
string baseUrl,
Action<IServiceCollection> serviceConfigurationCallback,
Action<IWebHostBuilder> webHostBuilderCallback)
Expand All @@ -242,7 +242,8 @@ private Task StartAspNetHostAsync(

this.webHosts.Add(host);

return host.StartAsync();
await host.StartAsync();
return host;
}
}
}

0 comments on commit cabb9f9

Please sign in to comment.