Add WebApplicationFactory for in-memory tests
Issue #, if available: https://github.com/aws/aws-lambda-dotnet/issues/1151
Description of changes: I've created a type WebApplicationFactory, which parses serverless.template file, and creates HttpClient, which is able to invoke Http endpoints, defined in template file. It invokes handler functions directly, avoiding any network communications.
Inspired by WebApplicationFactory from AspNetCore.
You can take a look at ComplexCalculator.cs for the example of usage.
This PR is essentially a POC, to describe the idea, and discuss whether it makes sense to expand it further (e.g. add ability to replace services in the DI container).
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
@normj @ashishdhingra @ganeshnj Guys, what do you think? Is that something which would be appropriate for this repo? Does it make sense to work further on this thing?
@Dreamescaper thanks for PR
I understand what the code does, but failing to understand the intent here. Is having a testable in-memory server intention here?
@ganeshnj Basically yes. I want to be able to write tests in a similar way I would do with WebApplicationFactory for AspNetCore. https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-6.0