OfType

ShouldBeOfType is the inverse of ShouldNotBeOfType.

ShouldBeOfType

var theSimpsonsDog = new Cat { Name = "Santas little helper" };
theSimpsonsDog.ShouldBeOfType<Dog>();

snippet source | anchor

Exception

theSimpsonsDog
    should be of type
Simpsons.Dog
    but was
Simpsons.Cat

ShouldNotBeOfType

var theSimpsonsDog = new Cat { Name = "Santas little helper" };
theSimpsonsDog.ShouldNotBeOfType<Cat>();

snippet source | anchor

Exception

theSimpsonsDog
    should not be of type
Simpsons.Cat
    but was
Santas little helper

Last updated