JhonnyLi / SimpleHttpClient

Attempt at making it easier to use the HttpClient
1 stars 0 forks source link

Creating the Uri in the constructor makes it hard to test #5

Open JhonnyLi opened 5 years ago

JhonnyLi commented 5 years ago

After introducing Unit tests I have come to the conclusion that creating a Uri in the constructor is bad conduct. Too many things can go wrong and its hard/impossible to test in a satisfactory fashion.

It needs to be changed in a way that still makes it simple to use and test.

JhonnyLi commented 5 years ago

Tried adding a protected method to ProxyHttpClientConfig that I can test by using:

PrivateObject obj = new PrivateObject(target);
var retVal = obj.Invoke("CreateUriFromUrl",Mockup.MockUrl);

Still seems like an invalid way of doing this since the constructor will throw and exception if the url is invalid.