Mocking Out RedirectToReferrer in Castle MonoRail

GRRRRRRRRRR!

In my 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.

[TestFixture]
public class LoginControllerTests : GenericBaseControllerTest<LoginController>
{
    private string referrer = "http://www.example.org";
    protected override IMockRequest BuildRequest()
    {
        var request = new StubRequest(Cookies);
        request.UrlReferrer = referrer;

        return request;
    }

    protected override IMockResponse BuildResponse(UrlInfo info)
    {
        var response = new StubResponse(info,
                                        new DefaultUrlBuilder(),
                                        new StubServerUtility(),
                                        new RouteMatch(),
                                        referrer);
        return response;
    }

etc. etc.

It’s oddly the Response that you need to molest to get the RedirectToReferrer to work. I had to crawl around in the monorail sources to figure it out.

Cheers!

This entry was posted in Development and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>