Mocking UrlReferrer

129 views
Skip to first unread message

Adrian Grigore

unread,
Nov 10, 2010, 9:55:51 AM11/10/10
to mvccontrib-discuss
Hi,

When using the TestHelper, how can I mock Request.UrlReferrer? I need
to set a value for the referrer in my test setup.

Thanks,

Adrian

Jeremy Skinner

unread,
Nov 10, 2010, 11:08:11 AM11/10/10
to mvccontri...@googlegroups.com
You can use Rhino Mocks' Expect extension method as you would with a manually-created mock:

var tcb = new TestControllerBuilder();
tcb.HttpContext.Request.Expect(x => x.UrlReferrer).Return(new Uri("http://foo"));

Jeremy


--
Contact Jeffrey Palermo or Eric Hexter with specific questions about the MvcContrib project.  Or go to http://mvccontrib.org

To unsubscribe from this group, send email to mvccontrib-disc...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/mvccontrib-discuss?hl=en

Adrian Grigore

unread,
Nov 10, 2010, 12:25:57 PM11/10/10
to mvccontrib-discuss
Thanks, Jeremy! :)

On 10 Nov., 17:08, Jeremy Skinner <jer...@jeremyskinner.co.uk> wrote:
> You can use Rhino Mocks' Expect extension method as you would with a
> manually-created mock:
>
> var tcb = new TestControllerBuilder();
> tcb.HttpContext.Request.Expect(x => x.UrlReferrer).Return(new Uri("http://foo"));
>
> Jeremy
>
> On 10 November 2010 14:55, Adrian Grigore <australiena...@googlemail.com>wrote:
>
> > Hi,
>
> > When using the TestHelper, how can I mock Request.UrlReferrer? I need
> > to set a value for the referrer in my test setup.
>
> > Thanks,
>
> > Adrian
>
> > --
> > Contact Jeffrey Palermo or Eric Hexter with specific questions about the
> > MvcContrib project.  Or go tohttp://mvccontrib.org
Reply all
Reply to author
Forward
0 new messages