Proving unit test results with xUnit.net assertions

xUnit.net assertions verify the behavior of methods under tests. An assertion validates the condition that is expected to be true for the results being expected. When an assertion fails, the current execution of the test is terminated and an exception is thrown. The following table explains the assertions available in xUnit.net:

Assertion

Description

Equal

Validates that an object equals another object

NotEqual

Validates that an object does not equal another object

Same

Verifies that two objects are of the same type

NotSame

Verifies that two objects are not of the same type

Contains

Is an overloaded assertion/method and verifies that a string

contains ...

Get C# and .NET Core Test Driven Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.