WebServiceHelper.TryUrlRedirection 方法

更新:2007 年 11 月

重定向 Web 服务对象,以便它指向 ASP.NET Development Server 而不是 Web 引用中定义的内容。

命名空间:  Microsoft.VisualStudio.TestTools.UnitTesting
程序集:  Microsoft.VisualStudio.QualityTools.UnitTestFramework(在 Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 中)

语法

声明
Public Shared Function TryUrlRedirection ( _
    client As WebClientProtocol, _
    context As TestContext, _
    identifier As String _
) As Boolean
用法
Dim client As WebClientProtocol
Dim context As TestContext
Dim identifier As String
Dim returnValue As Boolean

returnValue = WebServiceHelper.TryUrlRedirection(client, _
    context, identifier)
public static bool TryUrlRedirection(
    WebClientProtocol client,
    TestContext context,
    string identifier
)
public:
static bool TryUrlRedirection(
    WebClientProtocol^ client, 
    TestContext^ context, 
    String^ identifier
)
public static function TryUrlRedirection(
    client : WebClientProtocol, 
    context : TestContext, 
    identifier : String
) : boolean

参数

返回值

类型:System.Boolean

如果发生了重定向,则为 true;否则为 false。

备注

当使用 AspNetDevelopmentServerAttribute 运行测试时,将启动 ASP.NET Development Server 的实例。这样可确保 ASP.NET Development Server 站点启动,而且您知道 URL。然后,您在运行测试时,便可以使用 TryUrlRedirection 重定向 Web 服务对象,使它指向已知的服务器,而不是 Web 引用中定义的服务器。如果重定向成功,此方法将返回 true;否则(例如,如果标识符与现有 ASP.NET Development Server 实例的名称不匹配)将返回 false。

权限

另请参见

参考

WebServiceHelper 类

WebServiceHelper 成员

Microsoft.VisualStudio.TestTools.UnitTesting 命名空间