C# Class NUnit.Framework.Assert

The Assert class contains a collection of static methods that implement the most common assertions used in NUnit.
ファイルを表示 Open project: nunit/nunit Class Usage Examples

Public Methods

Method Description
Contains ( object expected, ICollection actual ) : void

Asserts that an object is contained in a collection.

Contains ( object expected, ICollection actual, string message ) : void

Asserts that an object is contained in a collection.

Fail ( ) : void

Throws an AssertionException. This is used by the other Assert functions.

Fail ( string message ) : void

Throws an AssertionException with the message and arguments that are passed in. This is used by the other Assert functions.

Ignore ( ) : void

Throws an IgnoreException. This causes the test to be reported as ignored.

Ignore ( string message ) : void

Throws an IgnoreException with the message and arguments that are passed in. This causes the test to be reported as ignored.

Inconclusive ( ) : void

Throws an InconclusiveException. This causes the test to be reported as Inconclusive.

Inconclusive ( string message ) : void

Throws an InconclusiveException with the message and arguments that are passed in. This causes the test to be reported as inconclusive.

Multiple ( TestDelegate testDelegate ) : void

Wraps code containing a series of assertions, which should all be executed, even if they fail. Failed results are saved and reported at the end of the code block.

Pass ( ) : void

Throws a SuccessException with the message and arguments that are passed in. This allows a test to be cut short, with a result of success returned to NUnit.

Pass ( string message ) : void

Throws a SuccessException with the message and arguments that are passed in. This allows a test to be cut short, with a result of success returned to NUnit.

Warn ( string message ) : void

Issues a warning using the message and arguments provided.

Protected Methods

Method Description
Assert ( ) : System

We don't actually want any instances of this object, but some people like to inherit from it to add other static methods. Hence, the protected constructor disallows any instances of this object.

Private Methods

Method Description
Equals ( object a, object b ) : bool
GetStackTrace ( ) : string
IncrementAssertCount ( ) : void
IssueWarning ( string message ) : void
ReferenceEquals ( object a, object b ) : void
ReportFailure ( ConstraintResult result, string message ) : void
ReportFailure ( string message ) : void

Method Details

Assert() protected method

We don't actually want any instances of this object, but some people like to inherit from it to add other static methods. Hence, the protected constructor disallows any instances of this object.
protected Assert ( ) : System
return System

Contains() public static method

Asserts that an object is contained in a collection.
public static Contains ( object expected, ICollection actual ) : void
expected object The expected object
actual ICollection The collection to be examined
return void

Contains() public static method

Asserts that an object is contained in a collection.
public static Contains ( object expected, ICollection actual, string message ) : void
expected object The expected object
actual ICollection The collection to be examined
message string The message to display in case of failure
return void

Fail() static public method

Throws an AssertionException. This is used by the other Assert functions.
static public Fail ( ) : void
return void

Fail() static public method

Throws an AssertionException with the message and arguments that are passed in. This is used by the other Assert functions.
static public Fail ( string message ) : void
message string The message to initialize the with.
return void

Ignore() static public method

Throws an IgnoreException. This causes the test to be reported as ignored.
static public Ignore ( ) : void
return void

Ignore() static public method

Throws an IgnoreException with the message and arguments that are passed in. This causes the test to be reported as ignored.
static public Ignore ( string message ) : void
message string The message to initialize the with.
return void

Inconclusive() static public method

Throws an InconclusiveException. This causes the test to be reported as Inconclusive.
static public Inconclusive ( ) : void
return void

Inconclusive() static public method

Throws an InconclusiveException with the message and arguments that are passed in. This causes the test to be reported as inconclusive.
static public Inconclusive ( string message ) : void
message string The message to initialize the with.
return void

Multiple() public static method

Wraps code containing a series of assertions, which should all be executed, even if they fail. Failed results are saved and reported at the end of the code block.
public static Multiple ( TestDelegate testDelegate ) : void
testDelegate TestDelegate A TestDelegate to be executed in Multiple Assertion mode.
return void

Pass() static public method

Throws a SuccessException with the message and arguments that are passed in. This allows a test to be cut short, with a result of success returned to NUnit.
static public Pass ( ) : void
return void

Pass() static public method

Throws a SuccessException with the message and arguments that are passed in. This allows a test to be cut short, with a result of success returned to NUnit.
static public Pass ( string message ) : void
message string The message to initialize the with.
return void

Warn() static public method

Issues a warning using the message and arguments provided.
static public Warn ( string message ) : void
message string The message to display.
return void