<p>I am trying to write a unit test for an action method which calls the <code>Controller.RedirectToReferrer()</code> method, but am getting a "No referrer available" message.</p>

<p>How can I isolate and mock this method?</p>

[{'answer_id': 62095, 'author': 'Chris Canal', 'author_id': 5802, 'author_profile': 'https://Stackoverflow.com/users/5802', 'pm_score': 2, 'selected': True, 'text': '<p>Have you thought about creating a <a href="http://xunitpatterns.com/Test%20Double.html" rel="nofollow noreferrer">test double</a>?</p>\n'}, {'answer_id': 137467, 'author': 'James Thigpen', 'author_id': 3285, 'author_profile': 'https://Stackoverflow.com/users/3285', 'pm_score': 0, 'selected': False, 'text': '<p>In <em>my</em> version of the trunk I\'m working against, r5299, I had to do this to mock out RedirectToReferrer.  I think it\'s been changed in recent commits, I\'m not sure.</p>\n\n<pre><code>[TestFixture]\npublic class LoginControllerTests : GenericBaseControllerTest&lt;LoginController&gt;\n{\n    private string referrer = "http://www.example.org";\n    protected override IMockRequest BuildRequest()\n    {\n        var request = new StubRequest(Cookies);\n        request.UrlReferrer = referrer;\n\n        return request;\n    }\n\n    protected override IMockResponse BuildResponse(UrlInfo info)\n    {\n        var response = new StubResponse(info,\n                                        new DefaultUrlBuilder(),\n                                        new StubServerUtility(),\n                                        new RouteMatch(),\n                                        referrer);\n        return response;\n    }\n</code></pre>\n\n<p>etc. etc.</p>\n\n<p>It\'s oddly the <em>Response</em> that you need to molest to get the <code>RedirectToReferrer</code> to work.  I had to crawl around in the monorail sources to figure it out.</p>\n'}]
['https://Stackoverflow.com/questions/62034', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6413/']