{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/1624","repository_url":"https://api.github.com/repos/dotnet/corefx","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":[{"id":178058848,"url":"https://api.github.com/repos/dotnet/corefx/labels/area-System.Net","name":"area-System.Net","color":"d4c5f9","default":false},{"id":443855532,"url":"https://api.github.com/repos/dotnet/corefx/labels/test%20enhancement","name":"test enhancement","color":"1d76db","default":false}],"state":"open","locked":false,"assignee":{"login":"davidsh","id":7684835,"avatar_url":"https://avatars.githubusercontent.com/u/7684835?v=3","gravatar_id":"","url":"https://api.github.com/users/davidsh","html_url":"https://github.com/davidsh","followers_url":"https://api.github.com/users/davidsh/followers","following_url":"https://api.github.com/users/davidsh/following{/other_user}","gists_url":"https://api.github.com/users/davidsh/gists{/gist_id}","starred_url":"https://api.github.com/users/davidsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidsh/subscriptions","organizations_url":"https://api.github.com/users/davidsh/orgs","repos_url":"https://api.github.com/users/davidsh/repos","events_url":"https://api.github.com/users/davidsh/events{/privacy}","received_events_url":"https://api.github.com/users/davidsh/received_events","type":"User","site_admin":false},"assignees":[{"login":"davidsh","id":7684835,"avatar_url":"https://avatars.githubusercontent.com/u/7684835?v=3","gravatar_id":"","url":"https://api.github.com/users/davidsh","html_url":"https://github.com/davidsh","followers_url":"https://api.github.com/users/davidsh/followers","following_url":"https://api.github.com/users/davidsh/following{/other_user}","gists_url":"https://api.github.com/users/davidsh/gists{/gist_id}","starred_url":"https://api.github.com/users/davidsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidsh/subscriptions","organizations_url":"https://api.github.com/users/davidsh/orgs","repos_url":"https://api.github.com/users/davidsh/repos","events_url":"https://api.github.com/users/davidsh/events{/privacy}","received_events_url":"https://api.github.com/users/davidsh/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/dotnet/corefx/milestones/5","html_url":"https://github.com/dotnet/corefx/milestones/Future","labels_url":"https://api.github.com/repos/dotnet/corefx/milestones/5/labels","id":1328080,"number":5,"title":"Future","description":"Milestone tracking the issues triaged for an unspecified future release","creator":{"login":"joshfree","id":1302850,"avatar_url":"https://avatars.githubusercontent.com/u/1302850?v=3","gravatar_id":"","url":"https://api.github.com/users/joshfree","html_url":"https://github.com/joshfree","followers_url":"https://api.github.com/users/joshfree/followers","following_url":"https://api.github.com/users/joshfree/following{/other_user}","gists_url":"https://api.github.com/users/joshfree/gists{/gist_id}","starred_url":"https://api.github.com/users/joshfree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshfree/subscriptions","organizations_url":"https://api.github.com/users/joshfree/orgs","repos_url":"https://api.github.com/users/joshfree/repos","events_url":"https://api.github.com/users/joshfree/events{/privacy}","received_events_url":"https://api.github.com/users/joshfree/received_events","type":"User","site_admin":false},"open_issues":630,"closed_issues":360,"state":"open","created_at":"2015-09-29T00:25:45Z","updated_at":"2016-11-11T23:52:49Z","due_on":null,"closed_at":null},"comments":107,"created_at":"2015-05-04T04:03:43Z","updated_at":"2016-11-12T13:57:36Z","closed_at":null,"body":"`System.Net.Http` has now been uploaded to the repo :smile: :tada: :balloon: \n\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.\n\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. \n\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.\n\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.\n\nIs there an easier way? Like .. can't we just have an `IHttpClient` interface and we can inject that into our service?\n"},"comment":{"url":"https://api.github.com/repos/dotnet/corefx/issues/comments/260123552","html_url":"https://github.com/dotnet/corefx/issues/1624#issuecomment-260123552","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/1624","id":260123552,"user":{"login":"jnm2","id":8040367,"avatar_url":"https://avatars.githubusercontent.com/u/8040367?v=3","gravatar_id":"","url":"https://api.github.com/users/jnm2","html_url":"https://github.com/jnm2","followers_url":"https://api.github.com/users/jnm2/followers","following_url":"https://api.github.com/users/jnm2/following{/other_user}","gists_url":"https://api.github.com/users/jnm2/gists{/gist_id}","starred_url":"https://api.github.com/users/jnm2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnm2/subscriptions","organizations_url":"https://api.github.com/users/jnm2/orgs","repos_url":"https://api.github.com/users/jnm2/repos","events_url":"https://api.github.com/users/jnm2/events{/privacy}","received_events_url":"https://api.github.com/users/jnm2/received_events","type":"User","site_admin":false},"created_at":"2016-11-12T13:57:36Z","updated_at":"2016-11-12T13:57:36Z","body":"It's not an absolute. If you're building a web browser, then I could see how it's 1:1 between what your app needs and what HttpClient abstracts. But if you're using HttpClient to talk to an API of some sort- anything with more specific expectations on top of HTTP, you're only going to need a fraction of what HttpClient can do. If you build a service which encapsulates the HttpClient transport mechanism and mock that service, the rest of your app can code against your service's API-specific interface abstraction, rather than coding against HttpClient."}}
{"actor":{"display_login":"jnm2"}}