<commit_before>MockHttp for HttpClient
=====================

MockHttp is a testing layer for Microsoft's HttpClient library. It allows "canned" responses to be configured for particular 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

    var mockHttp = new MockHttpMessageHandler();
	
    // Setup a respond for the user api (including a wildcard in the URL)
  	mockHttp.When("http://localost/api/user/*")
  			.Respond("application/json", "{'name' : '<NAME>'}"); // Respond with JSON
  	
  	// Inject the handler or client into your application code
  	var client = new HttpClient(mockHttp);
  	
  	var response = async client.GetAsync("http://localost/api/user/1234");
  	// or without async: var response = client.GetAsync("http://localost/api/user/1234").Result;
  	
  	var json = await response.Content.ReadAsStringAsync();
  	
  	// No network connection required
  	Console.Write(json); // {'name' : '<NAME>'}
<commit_msg>Updated NuGet command while it's a prerelease package<commit_after>MockHttp for HttpClient
=====================

MockHttp is a testing layer for Microsoft's HttpClient library. It allows "canned" responses to be configured for particular HTTP requests and can be used to test your application's service layer.

## NuGet

    PM> Install-Package RichardSzalay.MockHttp -IncludePrerelease

## 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

    var mockHttp = new MockHttpMessageHandler();
	
    // Setup a respond for the user api (including a wildcard in the URL)
  	mockHttp.When("http://localost/api/user/*")
  			.Respond("application/json", "{'name' : '<NAME>'}"); // Respond with JSON
  	
  	// Inject the handler or client into your application code
  	var client = new HttpClient(mockHttp);
  	
  	var response = async client.GetAsync("http://localost/api/user/1234");
  	// or without async: var response = client.GetAsync("http://localost/api/user/1234").Result;
  	
  	var json = await response.Content.ReadAsStringAsync();
  	
  	// No network connection required
  	Console.Write(json); // {'name' : '<NAME>'}

{'fraction_non_alphanumeric': 0.11557596632223498, 'fraction_numerical': 0.006123230003827019, 'mean_word_length': 4.007662835249042, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1904317', 'n_tokens_mistral': 744, 'n_tokens_neox': 696, 'n_words': 268}