Reputation: 14148
I have method expecting HttpContext type variable.
public string GetQueryStringValues(HttpContext context)
I am writing unit test from article hanselman article using Moq to create/populate HttpContext and pass into the method as follows:
string url = "http://localhost:51209/WebForm1.aspx?height=6&width=7&length=8&mode=walk";
HttpContextBase contextbase = MoqHelper.FakeHttpContext(url);
string result = new Helper(whitelist).GetQueryStringValues(context);
I get the following error message:
cannot convert from 'System.Web.HttpContextBase' to 'System.Web.HttpContext'
How do I resolve this with out changing the signature for method GetQueryStringValues ??
Please help.
thanks
Upvotes: 0
Views: 1612
Reputation: 15901
Unfortunately, you cannot do this without changing signature. However, your signature will be better with abstraction, not concrete type.
Upvotes: 1