Class RestResponse
public sealed class RestResponse : IDisposable, IProtoBinaryContent
- Inheritance
-
RestResponse
- Implements
- Inherited Members
- Extension Methods
Properties
Content
public string Content { get; }
Property Value
ContentBytes
public ReadOnlyMemory<byte> ContentBytes { get; }
Property Value
ContentHeaders
public HttpContentHeaders ContentHeaders { get; }
Property Value
ElapsedTime
public TimeSpan ElapsedTime { get; }
Property Value
Headers
public HttpResponseHeaders Headers { get; }
Property Value
IsSuccessStatusCode
public bool IsSuccessStatusCode { get; }
Property Value
RawResponse
public HttpResponseMessage RawResponse { get; }
Property Value
Should
Positive assertions on this response, such as Should.HaveHttpStatus(...).
public RestAssertions Should { get; }
Property Value
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
StatusCode
public HttpStatusCode StatusCode { get; }
Property Value
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
anonymousTypeDefinitionTOnly its type is used, so the compiler can infer the anonymous type; its values are ignored.
optionsJsonSerializerOptionsSerializer 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
optionsJsonSerializerOptions
Returns
- T
Type Parameters
T
ShouldMatchShape(object, JsonSerializerOptions?)
public RestResponse ShouldMatchShape(object expectedShape, JsonSerializerOptions? options = null)
Parameters
expectedShapeobjectoptionsJsonSerializerOptions