I\'m new to Mocking frameworks and have started using RhinoMocks to assist with my MVC App Unit Testing.
I\'m using Scott Hanselmanns MVC Mock Helper to assist in mo
you could use the below for Moq. It took me awhile how to mock the HttpApplication, and the appState.Object is the return method duh!
public static HttpContextBase FakeHttpContext()
{
var context = new Mock();
var request = new Mock();
var response = new Mock();
var session = new FakeHttpSessionState();
var server = new Mock();
var appState = new Mock();
context.Setup(ctx => ctx.Request).Returns(request.Object);
context.Setup(ctx => ctx.Response).Returns(response.Object);
context.Setup(ctx => ctx.Session).Returns(session);
context.Setup(ctx => ctx.Server).Returns(server.Object);
context.Setup(ctx => ctx.Application).Returns(appState.Object);
//emulate session (HttpContext.Current.Session)
var contx = new HttpContext(new MyApp.NUnit.Tests.Fakes.FakeHttpWorkerRequest());
contx.Items["AspSession"] = CreateSession();
HttpContext.Current = contx;
return context.Object;
}