Skip to content

Instantly share code, notes, and snippets.

@explorer14
Last active August 22, 2019 19:59
Show Gist options
  • Save explorer14/58dd589019735a4b7c4a44459792cb68 to your computer and use it in GitHub Desktop.
Save explorer14/58dd589019735a4b7c4a44459792cb68 to your computer and use it in GitHub Desktop.
[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