How to write unit test for ReadAsStringAsync

425 views Asked by At

I am trying to write unit tests for the following code:

m_Client.SendAsync(request).ContinueWith(responseTask =>
{
    HttpResponseMessage response = responseTask.Result;

    try
    {
        string str = response.Content.ReadAsStringAsync().Result;

        // ...
    }
    catch
    {
        // process exception here
    }
}

Is it possible to emulate exception of any kind during the ReadAsStringAsync execution?

0

There are 0 answers