Last active
August 22, 2019 19:48
-
-
Save explorer14/d3a91756ec88d9a6c8cc6a5c0bc2b5e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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