Closed fingers10 closed 1 year ago
I don't know .NET enough to tell you how, but the main thing you need to do is start your service so that it is accessible over an HTTP port (e.g. port 80
). If you can do that, then that's all that matters.
That is, how you start your service is irrelevant - Pact just communicates with it over HTTP.
You mean you’re using a minimal API rather than the traditional controller-based APIs? I wouldn’t call that new versus old but rather a different design type, but I digress.
I’d like to see if there’s an easy way to do this, too. In my example here: https://github.com/basdijkstra/introduction-to-contract-testing-dotnet/tree/main/AddressProvider I had to wrap my API in a Startup / Program construct to enable adding the Pact service URL and ProviderStateMiddleware in my tests.
If there’s an easier way to do that, I’d love to learn more.
@basdijkstra I'm using new hosting model which has only Program.cs. And I'm not using minimal api. I'm using normal controllers. A simple .NET 7 API template with normal controller is what I'm using. I googled and found your example repo before raising issue here. I didnt check the contents inside Startup.cs. Now After checking your Startup.cs I'm wondering why this is needed? Can it be added directly in Program.cs?
This is a duplicate of #444
I'm planning to write PACT provider test. But all the examples mentioned in repo uses Startup.cs hosting model.
My .NET 6+ project is using new hosting model which has only Program.cs and no Startup.cs
Please can anyone share example with new hosting model?