I wants unit test the Search class below that uses HttpClient,
public class Search:ISearch{ HttpClient httpClient; public Search(HttpClient httpClient){ this.httpClient = httpClient; } //use httClient to send request. } Is there a way to mock the HttpClient? I cannot find any information via Google.
Update
Is there an alternaitve to sending an Http web request that can be mocked. I have the code below:
public class Search:ISearch{ private static readonly string url = "http://www.google.com/search"; public Result SendSearch(string query){ string queryUrl = string.Format("{0}?q={1}", url, query); var webRequest = WebRequest.Create(queryUrl); ///... }