Created
July 3, 2011 08:02
-
-
Save half-ogre/1062053 to your computer and use it in GitHub Desktop.
It is way too hard to fake a call to Controller.Url.IsLocalUrl, which means I failed as a tester that day.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static UrlHelper CreateUrlHelperToFakeIsLocalUrl(string fakeRequestUrl) | |
{ | |
var httpContextBase = new Mock<HttpContextBase>(); | |
httpContextBase.Setup(x => x.Request.Url).Returns(new Uri(fakeRequestUrl)); | |
var requestContext = new RequestContext(httpContextBase.Object, new RouteData()); | |
return new UrlHelper(requestContext); | |
} | |
// controller.Url = CreateUrlHelperToFakeIsLocalUrl("http://aFakeHost/aFakePage"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment