TestDocumentLoaders Class

Creates the loaders that connect the pages to an application in memory, to an HTTP handler, or to folders.

public static class TestDocumentLoaders

Methods

NameDescription
FromDirectories(Uri, IEnumerable<KeyValuePair<string, string>>)Creates a loader that serves the files of folders for the URLs of an origin, by URL path prefix: { "/" : "wwwroot" } serves https://localhost/css/app.css from wwwroot/css/app.css. The other URLs are network errors.
FromHttpMessageHandler(HttpMessageHandler)Creates a loader that sends the requests of the pages to an HTTP message handler. The handler must not follow the redirects nor handle the cookies: the pages do it, as in a browser.
FromTestServer(TestServer)Creates a loader that sends the requests of the pages to an in-memory ASP.NET Core application (TestServer, for instance WebApplicationFactory.Server). The cookies and the redirects are handled by the pages, as in a browser.

FromDirectories(Uri, IEnumerable<KeyValuePair<string, string>>)

TestDocumentLoaders.cs

Creates a loader that serves the files of folders for the URLs of an origin, by URL path prefix: { "/" : "wwwroot" } serves https://localhost/css/app.css from wwwroot/css/app.css. The other URLs are network errors.

public static DocumentLoader FromDirectories(Uri origin, IEnumerable<KeyValuePair<string, string>> folders)

Parameters

origin Uri
The origin of the URLs (https://localhost/).
folders IEnumerable<KeyValuePair<string, string>>
The folders, by URL path prefix.

Returns

DocumentLoader The loader.

FromHttpMessageHandler(HttpMessageHandler)

TestDocumentLoaders.cs

Creates a loader that sends the requests of the pages to an HTTP message handler. The handler must not follow the redirects nor handle the cookies: the pages do it, as in a browser.

public static DocumentLoader FromHttpMessageHandler(HttpMessageHandler handler)

Parameters

handler HttpMessageHandler
The handler.

Returns

DocumentLoader The loader.

FromTestServer(TestServer)

TestDocumentLoaders.cs

Creates a loader that sends the requests of the pages to an in-memory ASP.NET Core application (TestServer, for instance WebApplicationFactory.Server). The cookies and the redirects are handled by the pages, as in a browser.

public static DocumentLoader FromTestServer(TestServer server)

Parameters

server TestServer
The test server.

Returns

DocumentLoader The loader.