Sprache

Assert.Scope Methode

Definition

Erstellt einen neuen Assertionsbereich, der Assertionsfehler sammelt, anstatt sie sofort auszuwerfen. Wenn der zurückgegebene Bereich verworfen wird, werden alle gesammelten Fehler als einzelnes AssertFailedExceptionausgelöst.

[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

Gibt zurück

Eine IDisposable Darstellung des Assertionsbereichs.

Attribute

Beispiele

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

Gilt für: