Class RestResponse

Namespace
ProtoTest.Rest
Assembly
ProtoTest.Rest.dll
public sealed class RestResponse : IDisposable, IProtoBinaryContent
Inheritance
RestResponse
Implements
Inherited Members
Extension Methods

Properties

Content

public string Content { get; }

Property Value

string

ContentBytes

public ReadOnlyMemory<byte> ContentBytes { get; }

Property Value

ReadOnlyMemory<byte>

ContentHeaders

public HttpContentHeaders ContentHeaders { get; }

Property Value

HttpContentHeaders

ElapsedTime

public TimeSpan ElapsedTime { get; }

Property Value

TimeSpan

Headers

public HttpResponseHeaders Headers { get; }

Property Value

HttpResponseHeaders

IsSuccessStatusCode

public bool IsSuccessStatusCode { get; }

Property Value

bool

RawResponse

public HttpResponseMessage RawResponse { get; }

Property Value

HttpResponseMessage

Should

Positive assertions on this response, such as Should.HaveHttpStatus(...).

public RestAssertions Should { get; }

Property Value

RestAssertions

ShouldNot

Assertions that must not hold, such as ShouldNot.HaveHttpStatus(...). Shape assertions stay on this response because a negated shape match is not meaningful.

public RestAssertions ShouldNot { get; }

Property Value

RestAssertions

StatusCode

public HttpStatusCode StatusCode { get; }

Property Value

HttpStatusCode

Methods

Dispose()

Releases the underlying HTTP response. Callers own a returned RestResponse and should dispose it when access to RawResponse is no longer required.

public void Dispose()

ReadAsAnonymous<T>(T, JsonSerializerOptions?)

Deserializes the body into an anonymous type described by example, e.g. ReadAsAnonymous(new { id = 0, status = "" }).

public T? ReadAsAnonymous<T>(T anonymousTypeDefinition, JsonSerializerOptions? options = null)

Parameters

anonymousTypeDefinition T

Only its type is used, so the compiler can infer the anonymous type; its values are ignored.

options JsonSerializerOptions

Serializer options; property names are case-insensitive by default.

Returns

T

Type Parameters

T

ReadAsBytes()

public byte[] ReadAsBytes()

Returns

byte[]

ReadAsDynamic()

public dynamic? ReadAsDynamic()

Returns

dynamic

ReadAsJson<T>(JsonSerializerOptions?)

public T? ReadAsJson<T>(JsonSerializerOptions? options = null)

Parameters

options JsonSerializerOptions

Returns

T

Type Parameters

T

ShouldMatchShape(object, JsonSerializerOptions?)

public RestResponse ShouldMatchShape(object expectedShape, JsonSerializerOptions? options = null)

Parameters

expectedShape object
options JsonSerializerOptions

Returns

RestResponse