A SameAsConstraint is used to test whether the object passed as an actual value has the same identity as the object supplied in its constructor.
Syntax Helper | Constructor | Operation |
---|---|---|
Is.SameAs( object ) | SameAsConstraint( null ) | tests that two object references refer to the same object |
Exception ex1 = new Exception(); Exception ex2 = ex1; Assert.That( ex2, Is.SameAs( ex1 ) ); Exception ex3 = new Exception(); Assert.That( ex3, Is.Not.SameAs( ex1 ) ); // Using inheritance Expect( ex2, SameAs( ex1 ) ); Expect( ex3, Not.SameAs( ex1 ) );