Class TestAzureResponse
- Namespace
- XBullet.EasyTesting.Azure
- Assembly
- XBullet.EasyTesting.Azure.dll
A concrete, configurable Azure SDK response for tests.
public sealed class TestAzureResponse : Response, IDisposable
- Inheritance
-
TestAzureResponse
- Implements
- Inherited Members
Constructors
TestAzureResponse(int, string?)
Creates a response with the supplied HTTP status.
public TestAzureResponse(int status = 200, string? reasonPhrase = null)
Parameters
statusintThe HTTP status code from 100 through 599. The default is 200.
reasonPhrasestringThe reason phrase, or null to derive the standard phrase for known status codes. Unknown codes receive an empty phrase. An explicitly empty phrase is preserved.
Properties
ClientRequestId
Gets the client request id that was sent to the server as x-ms-client-request-id headers.
public override string ClientRequestId { get; set; }
Property Value
ContentStream
Gets the contents of HTTP response. Returns null for responses without content.
public override Stream? ContentStream { get; set; }
Property Value
ReasonPhrase
Gets the HTTP reason phrase.
public override string ReasonPhrase { get; }
Property Value
Status
Gets the HTTP status code.
public override int Status { get; }
Property Value
Methods
ContainsHeader(string)
Returns true if the header is stored in the collection.
protected override bool ContainsHeader(string name)
Parameters
namestringThe header name.
Returns
- bool
trueif the specified header is stored in the collection, otherwisefalse.
Dispose()
Frees resources held by this Response instance.
public override void Dispose()
EnumerateHeaders()
Returns an iterator for enumerating HttpHeader in the response.
protected override IEnumerable<HttpHeader> EnumerateHeaders()
Returns
- IEnumerable<HttpHeader>
The IEnumerable<T> enumerating HttpHeader in the response.
FromValue<T>(T)
Wraps a model value and this raw response in an Azure Response<T>.
public Response<T> FromValue<T>(T value)
Parameters
valueTThe model value to retain; nullable values are accepted when
Tpermits them.
Returns
- Response<T>
A model response containing
valueand this exact raw response. This response remains caller-owned and must not be disposed while the wrapper is in use.
Type Parameters
TThe type of model value carried by the response.
TryGetHeader(string, out string)
Returns header value if the header is stored in the collection. If header has multiple values they are going to be joined with a comma.
protected override bool TryGetHeader(string name, out string value)
Parameters
Returns
- bool
trueif the specified header is stored in the collection, otherwisefalse.
TryGetHeaderValues(string, out IEnumerable<string>)
Returns header values if the header is stored in the collection.
protected override bool TryGetHeaderValues(string name, out IEnumerable<string> values)
Parameters
namestringThe header name.
valuesIEnumerable<string>The reference to populate with values.
Returns
- bool
trueif the specified header is stored in the collection, otherwisefalse.
WithContent(BinaryData, string?)
Sets the binary response body and optional content type.
public TestAzureResponse WithContent(BinaryData content, string? contentType = null)
Parameters
contentBinaryDataThe non-null binary content to copy into a new read-only stream. The caller retains ownership of the supplied value.
contentTypestringThe content-type header to add or replace, or null, empty, or whitespace to leave that header unchanged. The content-length header is always replaced with the byte count.
Returns
- TestAzureResponse
This response, for chaining. Any previous content stream is disposed and replaced immediately.
WithHeader(string, string)
Adds or replaces a response header.
public TestAzureResponse WithHeader(string name, string value)
Parameters
namestringThe non-empty, non-whitespace header name. Names are matched case-insensitively.
valuestringThe non-null header value. An empty value is accepted.
Returns
- TestAzureResponse
This response, for chaining. Any existing values for the header are replaced.
WithHeader(string, params string[])
Adds or replaces a multi-value response header.
public TestAzureResponse WithHeader(string name, params string[] values)
Parameters
namestringThe non-empty, non-whitespace header name. Names are matched case-insensitively.
valuesstring[]The non-null array of non-null header values. Empty strings and an empty array are accepted; the array is copied before this method returns.
Returns
- TestAzureResponse
This response, for chaining. Any existing values for the header are replaced.
WithJsonContent<T>(T, JsonSerializerOptions?)
Serializes a JSON response body.
public TestAzureResponse WithJsonContent<T>(T value, JsonSerializerOptions? serializerOptions = null)
Parameters
valueTThe value to serialize; nullable values are accepted when
Tpermits them.serializerOptionsJsonSerializerOptionsThe JSON options to use, or null to use Azure BinaryData defaults.
Returns
- TestAzureResponse
This response, for chaining, with a copied JSON body, an
application/jsoncontent type, and a matching content length. Any previous content stream is disposed.
Type Parameters
TThe type of value to serialize.