TestServer 類別

定義

IServer用於執行測試的實作。

public ref class TestServer : IDisposable, Microsoft::AspNetCore::Hosting::Server::IServer
public class TestServer : IDisposable, Microsoft.AspNetCore.Hosting.Server.IServer
type TestServer = class
    interface IServer
    interface IDisposable
Public Class TestServer
Implements IDisposable, IServer
繼承
TestServer
實作

建構函式

TestServer(IServiceProvider)

用於 IHostBuilder。

TestServer(IServiceProvider, IFeatureCollection)

用於 IHostBuilder。

TestServer(IServiceProvider, IFeatureCollection, IOptions<TestServerOptions>)

用於 IHostBuilder。

TestServer(IServiceProvider, IOptions<TestServerOptions>)

用於 IHostBuilder。

TestServer(IWebHostBuilder)

用於 IWebHostBuilder。

TestServer(IWebHostBuilder, IFeatureCollection)

用於 IWebHostBuilder。

屬性

AllowSynchronousIO

取得或設定值,這個值控制 是否允許 和 ResponseRequest 同步 IO。 預設值是 false

BaseAddress

取得或設定與測試伺服器所傳回之 HttpClient 相關聯的基底位址。 預設為 http://localhost/.

Features

取得與測試伺服器相關聯的伺服器功能集合。

Host

取得與 IWebHost 測試伺服器相關聯的實例。

PreserveExecutionContext

取得或設定值,這個值會控制是否 ExecutionContext 將 和 AsyncLocal<T> 值從用戶端保留到伺服器。 預設值是 false

Services

取得與測試伺服器相關聯的服務提供者。

方法

CreateClient()

建立 , HttpClient 以使用測試伺服器處理 HTTP 要求/回應。

CreateHandler()

建立自訂 HttpMessageHandler ,以使用測試伺服器處理 HTTP 要求/回應。

CreateHandler(Action<HttpContext>)

使用測試伺服器的自訂群組態,建立用於處理 HTTP 要求/回應的自訂 HttpMessageHandler

CreateRequest(String)

開始建構要提交的要求訊息。

CreateWebSocketClient()

WebSocketClient建立 與測試伺服器互動的 。

Dispose()

IWebHost處置與測試伺服器相關聯的 物件。

SendAsync(Action<HttpContext>, CancellationToken)

建立、設定、傳送和傳 HttpContext 回 。 這會在回應啟動時立即完成。

明確介面實作

IServer.Features

IServer用於執行測試的實作。

IServer.Start<TContext>(IHttpApplication<TContext>)

IServer用於執行測試的實作。

IServer.StartAsync<TContext>(IHttpApplication<TContext>, CancellationToken)

IServer用於執行測試的實作。

IServer.StopAsync(CancellationToken)

IServer用於執行測試的實作。

適用於