using the following in moq
public Mock<HttpRequestBase> Request { get; set; }
how can I mock this request [....]
(in controller) var modelFromPost = Request["mymodel"]
that's what i still have
public class ContextMocks { public Mock<HttpContextBase> HttpContext { get; set; } public Mock<HttpRequestBase> Request { get; set; } public RouteData RouteData { get; set; } public ContextMocks(Controller controller) { HttpContext = new Mock<HttpContextBase>(); HttpContext.Setup(x => x.Request).Returns(Request.Object); } }
Hurrah!
source share