Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
namespace Domain.Tests.Unit.Stubs
{
internal class SubmissionServiceHttpHandlerStub : HttpMessageHandler
{
private Dictionary<string, Payload> _requestPayload;
protected override async Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request,
CancellationToken cancellationToken)
{
_payload = JsonConvert.DeserializeObject<Dictionary<string,
Payload>>(
await request.Content.ReadAsStringAsync());
// Assume that submission was successful,
// construct the response payload
var result = ConstructResponsePayload(_payload)
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(JsonConvert.SerializeObject(result))
};
}
internal Payload PayloadDto(
string key) =>
_payload[key].FirstOrDefault();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.