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