{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/1624","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/1624/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/1624/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/1624/events","html_url":"https://github.com/dotnet/corefx/issues/1624","id":72915733,"number":1624,"title":"An simple way to mock an httpClient.GetAsync(..) method for unit tests?","user":{"login":"PureKrome","id":899878,"avatar_url":"https://avatars.githubusercontent.com/u/899878?v=3","gravatar_id":"","url":"https://api.github.com/users/PureKrome","html_url":"https://github.com/PureKrome","followers_url":"https://api.github.com/users/PureKrome/followers","following_url":"https://api.github.com/users/PureKrome/following{/other_user}","gists_url":"https://api.github.com/users/PureKrome/gists{/gist_id}","starred_url":"https://api.github.com/users/PureKrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PureKrome/subscriptions","organizations_url":"https://api.github.com/users/PureKrome/orgs","repos_url":"https://api.github.com/users/PureKrome/repos","events_url":"https://api.github.com/users/PureKrome/events{/privacy}","received_events_url":"https://api.github.com/users/PureKrome/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/corefx/labels/System.Net","name":"System.Net","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":42,"created_at":"2015-05-04T04:03:43Z","updated_at":"2015-05-14T18:38:54Z","closed_at":null,"body":"`System.Net.Http` has now been uploaded to the repo :smile: :tada: :balloon: \r\n\r\nWhenever I've used this in some service, it works great but makes it hard to unit test => my unit tests don't want to actually ever hit that real end point.\r\n\r\nAges ago, I asked @davidfowl what should we do? I hoping I paraphrase and don't misquote him - but he suggested that I need to fake up a message handler (ie. `HttpClientHandler`), wire that up, etc. \r\n\r\nAs such, I ended up making a helper library called [HttpClient.Helpers](https://github.com/PureKrome/HttpClient.Helpers) to help me run my unit tests.\r\n\r\nSo this works ... but it feels _very_ messy and .. complicated. I'm sure I'm not the first person that needs to make sure my unit tests don't do a real call to an external service.\r\n\r\nIs there an easier way? Like .. can't we just have an `IHttpClient` interface and we can inject that into our service?"},"comment":{"url":"https://api.github.com/repos/dotnet/corefx/issues/comments/102131199","html_url":"https://github.com/dotnet/corefx/issues/1624#issuecomment-102131199","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/1624","id":102131199,"user":{"login":"luisrudge","id":941075,"avatar_url":"https://avatars.githubusercontent.com/u/941075?v=3","gravatar_id":"","url":"https://api.github.com/users/luisrudge","html_url":"https://github.com/luisrudge","followers_url":"https://api.github.com/users/luisrudge/followers","following_url":"https://api.github.com/users/luisrudge/following{/other_user}","gists_url":"https://api.github.com/users/luisrudge/gists{/gist_id}","starred_url":"https://api.github.com/users/luisrudge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luisrudge/subscriptions","organizations_url":"https://api.github.com/users/luisrudge/orgs","repos_url":"https://api.github.com/users/luisrudge/repos","events_url":"https://api.github.com/users/luisrudge/events{/privacy}","received_events_url":"https://api.github.com/users/luisrudge/received_events","type":"User","site_admin":false},"created_at":"2015-05-14T18:38:54Z","updated_at":"2015-05-14T18:38:54Z","body":"Being sure you hit the correct url has low net value for you? What about being sure you do a PUT request to edit a resource instead of a post? The other 99% of my app can be covered, if this call's fails, then nothing will work."}}