Skip to content
Cyrille DUPUYDAUBY edited this page Feb 2, 2018 · 6 revisions

Checks on reference type

The following checks are available only for reference types.

IsSameReferenceAs(expected)

Checks if a given instance is the same reference than a given instance. Fails otherwise

var sut = new MyClass();

// This check succeeds
Check.That(sut).IsSameReferenceAs(sut);
// This checks fails
Check.That(sut).IsSameReferenceAs(new object());

IsDistinctFrom(expected)

Checks if a given instance is a different reference than a given instance. Fails otherwise.

var sut = new MyClass();

// This check succeeds
Check.That(sut).IsDistinctFrom(new object());
// This checks fails
Check.That(sut).IsDistinctFrom(sut);
Clone this wiki locally