Unit testing on MVC vb.net project. One of the action method in my controller, I was getting an error on Request.Params["FieldName"]
In this case, how to mock: Request.Params["FieldName"]
in unit test method? Prefer VB.net, and c# is accepted too.
Dim httpRequest = New Mock(Of System.Web.HttpRequestBase)()
Dim httpContext = New Mock(Of System.Web.HttpContextBase)()
Dim parameters As New NameValueCollection()
parameters("YourField") = "testField"
httpRequest.Setup(Function(x) x.Params).Returns(parameters)
httpContext.Setup(Function(x) x.Request).Returns(httpRequest.[Object])