Skip to content

Instantly share code, notes, and snippets.

View thoemmi's full-sized avatar

Thomas Freudenberg thoemmi

View GitHub Profile
@thoemmi
thoemmi / fake-http-context.cs
Created October 5, 2012 19:59 — forked from AlexZeitler/fake-http-context.cs
A Moq-using fake HTTP context to test controllers.
public HttpContextBase FakeHttpContext() {
var context = new Mock<HttpContextBase>();
var files = new Mock<HttpFileCollectionBase>();
var request = new Mock<HttpRequestBase>();
var response = new Mock<HttpResponseBase>();
var session = new Mock<HttpSessionStateBase>();
var server = new Mock<HttpServerUtilityBase>();
var user = new Mock<IPrincipal>();
var identity = new Mock<IIdentity>();
request.Setup(req => req.ApplicationPath).Returns("~/");