title: How to unit test a Controller action using the Response property in ASP.NET 5 (MVC 6)?
body: <p>In an <strong>ASP.NET Core 1.0 (MVC 6)</strong> project I have a Controller action method in which I use the <code>Response</code> property to set a header:</p>
  
  <pre><code>[HttpGet]
  public IActionResult Get()
  {
      ...
  
      Response.Headers.Add("Location", location);
  
      ...
  }
  </code></pre>
  
  <p>I tried to implement a unit test for this action method, but the value of the <code>Response</code> property is null.</p>
  
  <p>This was easy to solve in the previous versions of ASP.NET, because the <code>Response</code> property had a setter, and you could simply set its value to a new <code>HttpResponse</code> instance during a unit test.</p>
  
  <p>But in ASP.NET 5 <code>Response</code> does not have a setter, only a getter.<br>
  How can I set a value for <code>Response</code> in a unit test?</p>
  
  <p><strong>UPDATE</strong>: Just to make clear: this question is about <strong>ASP.NET Core 1.0</strong>. The other question linked as duplicate is about ASP.NET 4, and the Api changed since then so the answer there does not apply to this question.</p>