title: How to unit test a method
body: <p>I have this piece of code on which I want to create a unit test and I am pretty new to that. So I just need some guidance on how should I start?</p>
  
  <pre><code> public async Task&lt;Response&lt;TResult&gt;&gt; CallAuthenticatedApi&lt;TRequest, TResult&gt;(
          HttpMethod method,
          string uri,
          string[] scope,
          HttpSessionStateBase session,
          TRequest content = default(TRequest))
      {
          _logger.Information($"Making a call: {method} to {uri}");
  
          var stringContent = new StringContent(JsonConvert.SerializeObject(content),
              Encoding.UTF8, "application/json");
  
          var authToken = await GetAuthenticationToken(scope, session);
  
          var response = await RetryHelper.RetryOnExceptionAsync&lt;HttpRequestException&gt;(async () =&gt;
          {
              var request = CreateRequestMessage(method, uri, stringContent, authToken);
              var response1 = await HttpClient.SendAsync(request);
              return response1;
          });
  
          switch (response.StatusCode)
          {
  
              case HttpStatusCode.Unauthorized:
                  _logger.Warning("User is unauthenticated");
                  return new Response&lt;TResult&gt;(default(TResult),
                      response.StatusCode);
  
  
  
              default:
                  var errorContent = await response.Content.ReadAsStringAsync();
                  _logger.Error("General failure when calling API! " +
                                $"Content: {errorContent}");
                  return new Response&lt;TResult&gt;(default(TResult),
                      response.StatusCode);
          }
      }
  </code></pre>
  
  <p>I can test for response code but then I am confused what kind of info should I enter for the session even if I decide to create a mock?Please guide me on what should I pass in session variable</p>