Class RequestRecorder
An object that records all requests.
Inheritance
Namespace: LaunchDarkly.TestHelpers.HttpTest
Assembly: LaunchDarkly.TestHelpers.dll
Syntax
public class RequestRecorder : Object
Remarks
Normally you won't need to use this class directly, because HttpServer has a built-in instance that captures all requests. You can use it if you need to capture only a subset of requests.
Constructors
RequestRecorder()
Declaration
public RequestRecorder()
Fields
DefaultTimeout
The default timeout for RequireRequest(): 5 seconds.
Declaration
public static readonly TimeSpan DefaultTimeout
Field Value
Type | Description |
---|---|
System.TimeSpan |
Properties
Count
The number of requests currently in the queue.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Enabled
Set this property to false to turn off recording of requests. It is true by default.
Declaration
public bool Enabled { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Handler
Returns the stable Handler that is the external entry point to this
delegator. This is used implicitly if you use a RequestRecorder
anywhere that
a Handler is expected.
Declaration
public Handler Handler { get; }
Property Value
Type | Description |
---|---|
Handler |
Methods
RequireNoRequests(TimeSpan)
Asserts that there are no requests in the queue and none are received within the specified timeout.
Declaration
public void RequireNoRequests(TimeSpan timeout)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | timeout | the maximum length of time to wait |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | if a request was received |
RequireRequest()
Returns the first request in the queue, blocking until one is available, using DefaultTimeout.
Declaration
public RequestInfo RequireRequest()
Returns
Type | Description |
---|---|
RequestInfo | the request information |
Exceptions
Type | Condition |
---|---|
System.TimeoutException | if the timeout expires |
RequireRequest(TimeSpan)
Consumes and returns the first request in the queue, blocking until one is available.
Declaration
public RequestInfo RequireRequest(TimeSpan timeout)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | timeout | the maximum length of time to wait |
Returns
Type | Description |
---|---|
RequestInfo | the request information |
Exceptions
Type | Condition |
---|---|
System.TimeoutException | if the timeout expires |
Operators
Implicit(RequestRecorder to Handler)
Declaration
public static implicit operator Handler(RequestRecorder me)
Parameters
Type | Name | Description |
---|---|---|
RequestRecorder | me |
Returns
Type | Description |
---|---|
Handler |