我有一个案例,我必须测试没有HTTPContext
作为方法参数的Web服务方法,但是使用来自方法内部浏览器的HTTPContext
。
如下所示:
[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;
}
注意:此处Context
是System.Web.Services.WebService
类的属性。
如何使用模拟HTTPContext
测试上述Web服务方法。