Naredla Nithesh

Naredla Nithesh

  • NA
  • 328
  • 78.8k

NUnit Test cases for ASp.net Webservices with HTTPContext

Dec 26 2017 1:02 AM

I have a case where i have to test Webservices methods which do not have HTTPContext as method parameters, but uses HTTPContext whcih comes from the browser inside the method.It is something like below:

[WebMethod()]

public string Method()

{

string result = String.Empty;

try

{

result = new AnotherClass().anotherMethod(classB.UserName(Context));

}

catch (Exception e)

{

throw new WebServiceException(e);

}

return result;

}

 
 Note: Here Context is property of System.Web.Services.WebService class.
 
Here , How can i test above web service method with mocked HTTPContext.
 
 

Answers (1)