I have a service which uses Microsoft.Net.Http
to retrieve some Json
data. Great!
Of course, I don't want my unit test hitting the actual server (otherwise, that's an integration test).
Here's my service ctor (which uses dependency injection...)
public Foo(string name, HttpClient httpClient = null)
{
...
}
I'm not sure how I can mock this with ... say .. Moq
or FakeItEasy
.
I want to make sure that when my service calls GetAsync
or PostAsync
.. then i can fake those calls.
Any suggestions how I can do that?
I'm -hoping- i don't need to make my own Wrapper .. cause that's crap :( Microsoft can't have made an oversight with this, right?
(yes, it's easy to make wrappers .. i've done them before ... but it's the point!)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…