I have implemented an API gateway in .NET Core and I want to write functional tests to verify the behavior of the endpoints in the API gateway. I am using TestServer to test integration events between microservices, but I am not sure how to use it to test the endpoints in the API gateway. Is it possible to use WebApplicationFactory
to write functional tests for the API gateway endpoints and make simple HTTP requests to these endpoints to get the result?
I am using TestServer
to make http calls to different services which I use mostly for checking if IntegrationEvents
are handled correctly but I can not use it for API gateway
endpoints:
using Microsoft.AspNetCore.TestHost.TestServer identityServer = new IdentityScenariosBase().CreateServer();
using Microsoft.AspNetCore.TestHost.TestServer productServer = new ProductScenariosBase().CreateServer();
HttpClient identityClient = identityServer.CreateClient();
HttpClient productClient = productServer .CreateClient();
// Some other codes
And I know that as an alternative I can call all the processes of API gateway
endpoints in a test method like above code sample but I want to make one simple http call to an endpoint in API gateway
and get the result.