Language

Assert.Scope メソッド

定義

アサーションエラーを直ちにスローするのではなく収集する新しいアサーション スコープを作成します。 返されたスコープが破棄されると、収集されたすべてのエラーが 1 つの AssertFailedExceptionとしてスローされます。

[System.Diagnostics.CodeAnalysis.Experimental("MSTESTEXP", UrlFormat="https://aka.ms/mstest/diagnostics#{0}")]
public static IDisposable Scope();
public static IDisposable Scope();
[<System.Diagnostics.CodeAnalysis.Experimental("MSTESTEXP", UrlFormat="https://aka.ms/mstest/diagnostics#{0}")>]
static member Scope : unit -> IDisposable
static member Scope : unit -> IDisposable
Public Shared Function Scope () As IDisposable

返品

アサーション スコープを表す IDisposable 。

属性

例

using (Assert.Scope())
{
    Assert.AreEqual(1, 2);  // collected, not thrown
    Assert.IsTrue(false);   // collected, not thrown
}
// AssertFailedException is thrown here with all collected failures.

適用対象