meziantou / Meziantou.Framework

MIT License
678 stars 98 forks source link

HttpClientMock supporting custom content types. #654

Open bmazzarol-bunnings opened 2 months ago

bmazzarol-bunnings commented 2 months ago

Hi @meziantou ,

Would it be possible to add an additional constructor to the HttpClientMock to pass a WebApplicationBuilder?

Trying to mock a post call that receives XML and I want to set AddXmlSerializerFormatters().

If this is acceptable, I can raise a PR.

If you have a better way to do it, happy to consider that as well.

Thanks mate!

bmazzarol-bunnings commented 2 months ago

Found a workaround https://stackoverflow.com/questions/70006903/minimal-api-and-xml-formatters

So, my exact use case does not need the change.

I still think it might be a good change in case something needs to be done before its built, if you disagree feel free to let me know and I can close this.

meziantou commented 1 month ago

I think you can add a new overload public HttpClientMock(Action<WebApplicationBuilder>? configure). Do you want to submit a PR?