Class RecordedRequest
An HTTP request that a StubHandler or a RecordingHandler received. It is a copy, so it stays readable after the client has disposed the request.
public sealed class RecordedRequest
- Inheritance
-
RecordedRequest
- Inherited Members
Remarks
A test says what was sent instead of comparing JSON text: ReadItem<T>() reads the item of a put back through the code of the entity and ReadKey() the key of a get, an update or a
delete, TransactItems reads a transaction step by step, and ConditionText, UpdateText, KeyConditionText, FilterText and
ProjectionText read an expression, and TableName, IndexName, ConsistentRead, ScanIndexForward and Limit read a
member of the top of the body as it was sent, null where the request has none. BodyJson reaches everything else, such as the writes of a BatchWriteItem.
The notation of the texts. An expression reads as DynamoDB gets it, keywords, functions and spacing included, with each placeholder replaced by what it stands for, so a test does not depend on how
placeholders are numbered: #n0 = :v0 reads version = 3. A name stands as it is, and in backticks if it holds a dot or a bracket, because `a.b` is one attribute and a.b a path through two.
A value reads in the notation of PartiQL with double quotes, from its wire form, so a number keeps its text:
| On the wire | In a text |
|---|---|
{"S":"Placed"} | "Placed", with the escapes of JSON |
{"N":"3.10"} | 3.10 |
{"BOOL":true}, {"NULL":true} | true, null |
{"B":"aGk="} | b"aGk=", the base64 of the wire |
{"L":[{"S":"a"},{"N":"1"}]} | ["a", 1] |
{"M":{"k":{"N":"1"}}} | {"k": 1} |
{"SS":["a","b"]}, {"NS":["1"]}, {"BS":["aA=="]} | <<"a", "b">>, <<1>>, <<b"aA==">> |
A placeholder that the maps of the request lack stays as it is, which is the mistake a test should see. Elements of a list, entries of a map and elements of a set stay in the order of the wire, and DynamoDB does not keep the last two: a test that compares a set or a map sends it through ReadItem<T>(), or holds one element.
Properties
Body
Gets the request body, which for DynamoDB is UTF-8 JSON. Empty when the request had no content.
public ReadOnlyMemory<byte> Body { get; }
Property Value
BodyJson
Gets the request body as JSON, parsed anew on each read. The element stands on its own, so a test can keep it as long as it likes.
public JsonElement BodyJson { get; }
Property Value
- JsonElement
The root of the body.
Exceptions
- JsonException
The body is not JSON, or there is none.
BodyText
Gets the request body as text.
public string BodyText { get; }
Property Value
- string
The body decoded as UTF-8.
ConditionText
Gets the ConditionExpression with its placeholders resolved, in the notation of the remarks of this class: version = 3; null if the request has none.
public string? ConditionText { get; }
Property Value
Exceptions
- JsonException
The body is not JSON, or there is none.
ConsistentRead
Gets ConsistentRead of a GetItem, a Query or a Scan as the request sent it; null if it sent none, which DynamoDB reads as an eventually consistent read. The client
sends it only for a strongly consistent read, so a test asserts true or null. A BatchGetItem has it per table, in BodyJson.
public bool? ConsistentRead { get; }
Property Value
Exceptions
- JsonException
The body is not JSON, or there is none.
- InvalidOperationException
The member is not a JSON boolean.
FilterText
Gets the FilterExpression with its placeholders resolved, in the notation of the remarks of this class: Status = "Placed"; null if the request has none.
public string? FilterText { get; }
Property Value
Exceptions
- JsonException
The body is not JSON, or there is none.
Headers
Gets the request headers and the content headers (such as Content-Type) by name, ignoring case. A header with several
values is joined with a comma and a space. The signature headers Authorization, X-Amz-Date and
X-Amz-Security-Token are included.
public IReadOnlyDictionary<string, string> Headers { get; }
Property Value
IndexName
Gets the IndexName of a Query or a Scan of an index; null for a read of the table and for every other operation.
public string? IndexName { get; }
Property Value
Exceptions
- JsonException
The body is not JSON, or there is none.
KeyConditionText
Gets the KeyConditionExpression with its placeholders resolved, in the notation of the remarks of this class: pk = "alice" AND begins_with(sk, "ORDER#"); null if the request has none.
public string? KeyConditionText { get; }
Property Value
Exceptions
- JsonException
The body is not JSON, or there is none.
Limit
Gets the Limit of the body: how many items a Query or a Scan reads at most for this page, before the filter, or how many tables, streams, shards or records a page of
ListTables, ListStreams, DescribeStream or GetRecords holds at most; null if the request set none.
public int? Limit { get; }
Property Value
Exceptions
- JsonException
The body is not JSON, or there is none.
- FormatException
The member is not a JSON number that fits an int.
Method
Gets the HTTP method. DynamoDB requests are always POST.
public HttpMethod Method { get; }
Property Value
Operation
Gets the DynamoDB operation from the X-Amz-Target header, for example GetItem for
DynamoDB_20120810.GetItem; null if the request has no such header.
public string? Operation { get; }
Property Value
ProjectionText
Gets the ProjectionExpression with its names resolved, in the notation of the remarks of this class: name, address.city; null if the request has none.
public string? ProjectionText { get; }
Property Value
Exceptions
- JsonException
The body is not JSON, or there is none.
RequestUri
Gets the request URI, which for DynamoDB is the endpoint.
public Uri? RequestUri { get; }
Property Value
ScanIndexForward
Gets ScanIndexForward of a Query as the request sent it; null if it sent none, which DynamoDB reads as ascending order of the sort key. A query command sends it only for
Descending(), so a test of one asserts false or null; a QueryRequest sends what it holds.
public bool? ScanIndexForward { get; }
Property Value
Exceptions
- JsonException
The body is not JSON, or there is none.
- InvalidOperationException
The member is not a JSON boolean.
TableName
Gets the TableName of the body, which a request on one table carries, such as a GetItem, a Query or a DescribeTable; null if it has none. A batch and a
transaction name a table per entry and have none at the top: TransactItems gives the table of each step, and BodyJson the tables of a batch.
public string? TableName { get; }
Property Value
Exceptions
- JsonException
The body is not JSON, or there is none.
TransactItems
Gets the actions of a TransactWriteItems or TransactGetItems in the order of the request, read anew on each access. Empty for any other request.
public IReadOnlyList<RecordedTransactStep> TransactItems { get; }
Property Value
- IReadOnlyList<RecordedTransactStep>
The steps.
Exceptions
- JsonException
The body is not JSON, or there is none.
UpdateText
Gets the UpdateExpression with its placeholders resolved, in the notation of the remarks of this class: SET plan = "pro", visits = visits + 1; null if the request has none.
public string? UpdateText { get; }
Property Value
Exceptions
- JsonException
The body is not JSON, or there is none.
Methods
ReadItem()
Reads the Item of the body, which a PutItem carries.
public Item ReadItem()
Returns
- Item
A new item with the attributes as they went over the wire.
Exceptions
- InvalidOperationException
The body has no
Item.
ReadItem(string)
Reads any member of the body that has the form of an item, for example ExclusiveStartKey.
public Item ReadItem(string member)
Parameters
memberstringThe name of the member at the top of the body.
Returns
- Item
A new item with the attributes as they went over the wire.
Exceptions
- ArgumentNullException
memberis null.- InvalidOperationException
The body has no such member.
ReadItem<T>()
Reads the Item of the body the way a response that carries it is read, so that a test can compare what a PutItem carried with an entity.
public T ReadItem<T>() where T : IDynamoDbDocument<T>
Returns
- T
The value.
Type Parameters
TThe type to read: a generated entity or Item.
Exceptions
- InvalidOperationException
The body has no
Item.- DynamoDbMappingException
An attribute is missing or cannot be converted, or the item is of another type.
ReadItem<T>(string)
Reads any member of the body that has the form of an item the way a response that carries it is read.
public T ReadItem<T>(string member) where T : IDynamoDbDocument<T>
Parameters
memberstringThe name of the member at the top of the body, for example
Item.
Returns
- T
The value.
Type Parameters
TThe type to read: a generated entity or Item.
Exceptions
- ArgumentNullException
memberis null.- InvalidOperationException
The body has no such member.
- DynamoDbMappingException
An attribute is missing or cannot be converted, or the item is of another type.
ReadKey()
Reads the Key of the body, which a GetItem, UpdateItem or DeleteItem carries. KeyOf(IKey) gives what to compare it with.
public Item ReadKey()
Returns
- Item
A new item with the key attributes.
Exceptions
- InvalidOperationException
The body has no
Key.
ReadKey<T>()
Reads the Key of the body through a type. A key holds the key attributes and nothing else, so an entity with other required attributes fails with a
DynamoDbMappingException; for such a type, compare ReadKey() with KeyOf(IKey).
public T ReadKey<T>() where T : IDynamoDbDocument<T>
Returns
- T
The value.
Type Parameters
TThe type to read, which can be made from the key attributes alone.
Exceptions
- InvalidOperationException
The body has no
Key.- DynamoDbMappingException
An attribute is missing or cannot be converted.