{"repo":"richardszalay/mockhttp","free":true,"listed":false,"github":"https://github.com/richardszalay/mockhttp","clone":"git clone https://github.com/richardszalay/mockhttp.git","description":"Testing layer for Microsoft's HttpClient library. Create canned responses using a fluent API.","language":"C#","stars":1766,"topics":["dotnet","httpclient","testing","mocking","dotnetcore"],"license":"MIT","category":"dev-tools","readme_excerpt":"MockHttp for HttpClient ===================== MockHttp is a testing layer for Microsoft's HttpClient library. It allows stubbed responses to be configured for matched HTTP requests and can be used to test your application's service layer. NuGet PM Install-Package RichardSzalay.MockHttp How? MockHttp defines a replacement HttpMessageHandler , the engine that drives HttpClient, that provides a fluent configuration API and provides a canned response. The caller (eg. your application's service layer) remains unaware of its presence. Usage When (Backend Definitions) vs Expect (Request Expectations) MockHttpMessageHandler defines both When and Expect , which can be used to define responses. They both expose the same fluent API, but each works in a slightly different way. Using When specifies a \"Backend Definition\". Backend Definitions can be matched against multiple times and in any order, but they won't match if there are any outstanding Request Expectations present (unless BackendDefinitionBehavior.Always is specified). If no Request Expectations match, Fallback will be used. Using Expect specifies a \"Request Expectation\". Request Expectations match only once and in the order they were added in. Only once all expectations have been satisfied will Backend Definitions be evaluated. Calling mockHttp.VerifyNoOutstandingExpectation() will assert that there are no expectations that have yet to be called. Calling ResetExpectations clears the the queue of expectations. This pattern is he","default_branch":null,"files":null,"tree":[],"storefront":"/r/richardszalay","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/richardszalay/mockhttp/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."}