I found one solution to the problem, however, it is a bit tedious and confusing, so I'm still interested in a simpler approach, if one exists.
Controller gets the value of its Response property from ActionContext.HttpContext . What complicates this is that all of these properties are read-only, so we just cannot just set the mock value, we must create mocks for every object in the game.
Part of the answer I needed in my test was in the Headers collection, so I had to create and use the following layouts to do this. (The deal is executed using Moq .)
var sut = new MyController();
This is a bit more code than what I would like to see to mock one property, but have not yet found a better approach, and it seems to work well.
source share