In an ASP.NET Core 1.0 (MVC 6) project I have a Controller action method in which I use the Response property to set a header:
[HttpGet]
public IActionResult Get()
{
...
Response.Headers.Add("Location", location);
...
}
I tried to implement a unit test for this action method, but the value of the Response property is null.
This was easy to solve in the previous versions of ASP.NET, because the Response property had a setter, and you could simply set its value to a new HttpResponse instance during a unit test.
But in ASP.NET 5 Response does not have a setter, only a getter.
How can I set a value for Response in a unit test?
UPDATE: Just to make clear: this question is about ASP.NET Core 1.0. 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.