{"repo":"ardalis/HttpClientTestExtensions","free":true,"listed":false,"github":"https://github.com/ardalis/HttpClientTestExtensions","clone":"git clone https://github.com/ardalis/HttpClientTestExtensions.git","description":"Extensions for testing HTTP endpoints and deserializing the results. Currently works with XUnit.","language":"C#","stars":107,"topics":["api","asp-net-core","csharp","dotnet","hacktoberfest","testing","web-api"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"HttpClient Test Extensions Extensions for testing HTTP endpoints and deserializing the results. Currently works with XUnit. Installation Add the NuGet package: In your tests add this namespace: Usage If you have existing test code that looks something like this: You can now update the test to eliminate all but one of the lines prior to the assertions: If you need to verify an endpoint returns a 404, you can use this approach: List of Included Helper Methods HttpClient All of these methods are extensions on HttpClient ; the following samples assume client is an HttpClient . All methods take an optional ITestOutputHelper , which is an xUnit type. GET POST PUT PATCH DELETE HttpResponseMessage All of these methods are extensions on HttpResponseMessage . StringContentHelpers Extensions on HttpContent which you'll typically want to return a StringContent type as you serialize your DTO to JSON. Notes - For now this is coupled with xUnit but if there is interest it could be split so the ITestOutputHelper dependency is removed/optional/swappable - Additional helpers for other verbs are planned - This is using System.Text.Json with default camelCase options that I've found most useful in my projects. This could be made extensible somehow as well. - When making updates to this file make sure to also update the docs/README file that is embedded in the NuGet package","default_branch":null,"files":null,"tree":[],"storefront":"/r/ardalis","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/ardalis/HttpClientTestExtensions/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}