title: Writing Unit Test for methods that use User.Identity.Name in ASP.NET Web API
body: <p>I am writing test cases using the Unit Test for ASP.NET Web API.</p>
  <p>Now I have an action which makes a call to some method I have defined in the service layer, where I have used the following line of code.</p>
  <pre><code>string username = User.Identity.Name;
  // do something with username
  // return something
  </code></pre>
  <p>Now how to I create unit test method for this, I am getting null reference exceptions. I am kinda new to writing unit test and stuff.</p>
  <p>I want to use Unit Test only for this. Please help me out on this.</p>