Class ProtoTestContextPropagation

Namespace
ProtoTest.AspNetCore
Assembly
ProtoTest.AspNetCore.dll

Propagates the test's context onto a request an in-process transport opens itself. A real HTTP handler propagates the W3C trace context itself, but the TestServer handler bypasses the HTTP diagnostics, so an in-process request carries the ambient trace context explicitly; it also carries the test's id, which is how the application's TimeProvider finds the test's clock on a request flow that no longer has the test's ambient context.

public static class ProtoTestContextPropagation
Inheritance
ProtoTestContextPropagation
Inherited Members

Fields

TestIdHeader

The header that carries the test id to the application's clock bridge. The in-process HTTP client's handler sends it on every request; a transport that opens a raw request applies ApplyTo(HttpRequest) so the application resolves the same test.

public const string TestIdHeader = "x-prototest-test"

Field Value

string

Methods

ApplyTo(HttpRequest)

Adds the same context to the request the test server hands the application, for an in-process client that opens one raw - a WebSocket handshake configured through ConfigureRequest.

public static void ApplyTo(HttpRequest request)

Parameters

request HttpRequest

ApplyTo(HttpRequestMessage)

Adds the ambient trace context and, when a test is active on this flow, that test's id to an outbound request. An existing header is left untouched.

public static void ApplyTo(HttpRequestMessage request)

Parameters

request HttpRequestMessage