If you don't want a class level RestClient field in SomeRepository, you can use method injection, and add a RestClient parameter to the CheckSomething method. You can then mock the RestClient for your unit tests.

public bool CheckSomething(RestClient restClient)
{
    var request = new RestRequest("resourceX/{name}", Method.GET);
    request.AddUrlSegment("name", "ABC");
    var response = client.Execute(request);

    if (response.StatusCode == HttpStatusCode.NotFound) return false;
    if (response.StatusCode == HttpStatusCode.OK) return true;

    throw new Exception("Something is messed up");
}


If that were my code, I would want to test the following things:


Has the RestRequest that was passed into the RestClient.Execute method been properly setup.
Does the method return true or false based on the response.StatusCode
Does any other status code result in an exception being thrown.


If that is all you need to test, then the only thing you need to mock is the RestClient, which means you could easily just use method injection, or constructor or property injection.

Unit test with HttpWebClient or RestSharp
What kind of non-technical training course do you suggest for a programmer? Example could be public speaking course, presentation skill, English, business writing, or anything not related to programming or software engineering itself.
