TestDocumentLoaders Class
Creates the loaders that connect the pages to an application in memory, to an HTTP handler, or to folders.
public static class TestDocumentLoadersMethods
| Name | Description |
|---|---|
| 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.csCreates 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
originUri- The origin of the URLs (
https://localhost/). foldersIEnumerable<KeyValuePair<string, string>>- The folders, by URL path prefix.
Returns
DocumentLoader The loader.
FromDirectories(Uri, IEnumerable<KeyValuePair<string, string>>, string?)
TestDocumentLoaders.csCreates 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
originUri- The origin of the URLs (
https://localhost/). foldersIEnumerable<KeyValuePair<string, string>>- The folders, by URL path prefix.
fallbackPathstring?- The URL path of the file served for the routes of the application (
/index.html), or null.
Returns
DocumentLoader The loader.
FromHttpMessageHandler(HttpMessageHandler)
TestDocumentLoaders.csCreates 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)FromTestServer(TestServer)
TestDocumentLoaders.csCreates 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)