WebServiceHelper.TryUrlRedirection 方法
将 Web 服务对象重定向到 ASP.NET 开发服务器而不是提供的 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
public static bool TryUrlRedirection(
WebClientProtocol client,
TestContext context,
string identifier
)
public:
static bool TryUrlRedirection(
WebClientProtocol^ client,
TestContext^ context,
String^ identifier
)
static member TryUrlRedirection :
client:WebClientProtocol *
context:TestContext *
identifier:string -> bool
public static function TryUrlRedirection(
client : WebClientProtocol,
context : TestContext,
identifier : String
) : boolean
参数
- client
类型:System.Web.Services.Protocols.WebClientProtocol
要测试的 Web 服务类型的实例。
- context
类型:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext
此单元测试的 TestContext。
- identifier
类型:System.String
标识 ASP.NET 开发服务器实例的唯一字符串。它与测试方法中 AspNetDevelopmentServerAttribute 的 name 参数匹配。
返回值
类型:System.Boolean
如果发生了重定向,则为 true;否则为 false。
备注
当使用 AspNetDevelopmentServerAttribute 运行测试时,将启动 ASP.NET 开发服务器的实例。 确保 ASP.NET 开发服务器站点启动并确保 URL为已知。 运行测试时,您可以使用 TryUrlRedirection 重定向 Web 服务对象,使它指向已知服务器,而不是提供的 Web 引用中定义的资源。 如果重定向未成功,则此方法将返回 true,如果重定向成功则将返回 false。 例如,如果该标识符与现有 ASP.NET Development Server 实例不匹配,则该方法返回 false。
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。
请参见
参考
Microsoft.VisualStudio.TestTools.UnitTesting 命名空间
AspNetDevelopmentServerAttribut