I am working on an asp.net mvc 3.0 application. In the module testing one of the action methods in my controller, I received an error.
How to taunt: Request.Params["FieldName"]
I turned on the Moq framework, but was not sure how to pass the value
Here is my code ... Please suggest ...
var request = new Mock<System.Web.HttpRequestBase>(); request .SetupGet(x => x.Headers) .Returns( new System.Net.WebHeaderCollection { {"X-Requested-With", "XMLHttpRequest"} }); var context = new Mock<System.Web.HttpContextBase>(); context.SetupGet(x => x.Request).Returns(request.Object); ValidCodeController target = new ValidCodeController(); target.ControllerContext = new ControllerContext(context.Object, new RouteData(), target);
source share