Table of Contents

RunAsync Method

Definition

Namespace
Codebelt.Extensions.Xunit.Hosting.AspNetCore
Assemblies
Codebelt.Extensions.Xunit.Hosting.AspNetCore.dll
Source
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/WebApplicationTestFactory.cs

RunAsync<TEntryPoint>(Action<IWebHostBuilder>, Func<HttpClient, Task<HttpResponseMessage>>, IWebApplicationFixture<TEntryPoint>)

Runs an ASP.NET Core application and returns an HttpResponseMessage for the test server.

public static Task<HttpResponseMessage> RunAsync<TEntryPoint>(Action<IWebHostBuilder> webHostSetup = null, Func<HttpClient, Task<HttpResponseMessage>> responseFactory = null, IWebApplicationFixture<TEntryPoint> hostFixture = null) where TEntryPoint : class

Parameters

webHostSetup Action<IWebHostBuilder>

The IWebHostBuilder which may be configured.

responseFactory Func<HttpClient, Task<HttpResponseMessage>>

The function delegate that creates a HttpResponseMessage from the HttpClient. Default is a GET request to the root URL ("/").

hostFixture IWebApplicationFixture<TEntryPoint>

An optional IWebApplicationFixture<TEntryPoint> implementation to use instead of the default ManagedWebApplicationFixture<TEntryPoint> instance.

Returns

Task<HttpResponseMessage>

A Task that represents the asynchronous operation. The task result contains the HttpResponseMessage for the test server.

Type Parameters

TEntryPoint

A type in the entry point assembly of the application.