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, and https://localhost/ from wwwroot/index.html. The URL of a folder without its trailing slash (/docs) redirects to the folder (/docs/). The other URLs are network errors.
FromDirectories(Uri, IEnumerable<KeyValuePair<string, 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, and https://localhost/ from wwwroot/index.html. The URL of a folder without its trailing slash (/docs) redirects to the folder (/docs/). The URLs that match no file and whose path has no extension serve the file of fallbackPath, as MapFallbackToFile does: the routes of a single-page application, such as a Blazor WebAssembly application, serve its page. 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 overloads

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, and https://localhost/ from wwwroot/index.html. The URL of a folder without its trailing slash (/docs) redirects to the folder (/docs/). 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.

FromDirectories(Uri, IEnumerable<KeyValuePair<string, 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, and https://localhost/ from wwwroot/index.html. The URL of a folder without its trailing slash (/docs) redirects to the folder (/docs/). The URLs that match no file and whose path has no extension serve the file of fallbackPath, as MapFallbackToFile does: the routes of a single-page application, such as a Blazor WebAssembly application, serve its page. The other URLs are network errors.

public static DocumentLoader FromDirectories(Uri origin, IEnumerable<KeyValuePair<string, string>> folders, string? fallbackPath)
Parameters
origin Uri
The origin of the URLs (https://localhost/).
folders IEnumerable<KeyValuePair<string, string>>
The folders, by URL path prefix.
fallbackPath string?
The URL path of the file served for the routes of the application (/index.html), or null.
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.