Share via


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

パラメーター

  • identifier
    型: System.String
    ASP.NET 開発サーバーのインスタンスを識別する一意の文字列です。これは、テスト メソッドの AspNetDevelopmentServerAttribute の名前パラメーターに一致します。

戻り値

型: System.Boolean
リダイレクトが発生した場合は true。それ以外の場合は false。

解説

AspNetDevelopmentServerAttribute を指定してテストを実行すると、ASP.NET 開発サーバーのインスタンスが起動します。 これにより、ASP.NET 開発サーバーのサイトを確実に起動し、その URL を把握することができます。 テストを実行したら、TryUrlRedirection を使用して、指定された Web 参照で定義されているリソースではなく既知のサーバーを指すように Web サービス オブジェクトをリダイレクトできます。 このメソッドは、リダイレクトに成功した場合は true を、そうでない場合は false を返します。 たとえば、識別子が既存の ASP.NET 開発サーバー インスタンスの名前と一致しなかった場合、メソッドは false を返します。

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

WebServiceHelper クラス

Microsoft.VisualStudio.TestTools.UnitTesting 名前空間

TestContext

AspNetDevelopmentServerAttribut