使用HTTPContext

时间:2017-12-26 06:12:12

标签: c# web-services nunit httpcontext

我有一个案例,我必须测试没有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;
}

注意:此处ContextSystem.Web.Services.WebService类的属性。

如何使用模拟HTTPContext测试上述Web服务方法。

0 个答案:

没有答案