Assert.Scope 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立一個新的斷言範圍,收集斷言失敗,而非立即丟棄。 當回傳示波器被丟棄時,所有收集的失敗會作為一個 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
傳回
A 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.