RequestCounter Class

Tracks the number of requests made to the mock server and individual endpoints.

public sealed class RequestCounter

Constructors

NameDescription
RequestCounter(IHttpContextAccessor)Tracks the number of requests made to the mock server and individual endpoints.

RequestCounter(IHttpContextAccessor)

RequestCounter.cs

Tracks the number of requests made to the mock server and individual endpoints.

public RequestCounter(IHttpContextAccessor httpContextAccessor)

Parameters

httpContextAccessor IHttpContextAccessor

Properties

NameDescription
TotalCountGets the total number of requests made to the mock server.

Gets the total number of requests made to the mock server.

public long TotalCount { get; }

Property value

long

Remarks

A request is counted before its handler runs, so reading this from a handler includes the request being handled.

Methods

NameDescription
Get()Gets the number of requests made to the current endpoint.
Get(Endpoint?)Gets the number of requests made to the specified endpoint.
Get(HttpContext)Gets the number of requests made to the endpoint associated with the specified HttpContext.

Get overloads

Gets the number of requests made to the current endpoint.

public long Get()
Returns

long The number of requests made to the current endpoint.

Remarks

A request is counted before its handler runs, so calling this from a handler includes the request being handled.

Get(Endpoint?)

RequestCounter.cs

Gets the number of requests made to the specified endpoint.

public long Get(Endpoint? endpoint)
Parameters
endpoint Endpoint?
The endpoint to get the request count for.
Returns

long The number of requests made to the endpoint.

Get(HttpContext)

RequestCounter.cs

Gets the number of requests made to the endpoint associated with the specified HttpContext.

public long Get(HttpContext httpContext)
Parameters
httpContext HttpContext
The HTTP context containing the endpoint.
Returns

long The number of requests made to the endpoint.