Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Fact]
public async Task ShouldSubmitCorrectPayload()
{
// ... Do all the set up required i.e. stubs, domain objects
// with pre-cooked data neccesary to execute the behaviour.
// Build the service/adapter object with this mock HttpMessageHandler
var loopbackHttpHandler = new SubmissionServiceHttpHandlerStub();
var submitter = new SubmissionService(
new HttpClient(loopbackHttpHandler)
{
BaseAddress = new Uri("http://foo.bar")
});
var useCase = CreateUseCase(submitter);
useCase.Execute(...);
// verify that what will have been submitted to the external
// service would have been the right data
var payload = loopbackHttpHandler.PayloadDto("key");
payload.Field1.Should().Be("abc");
payload.Field2.Should().Be(10);
// other assertions
}
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.