Shouldly
  • Overview
  • Contributing
  • Documentation
    • Getting Started
    • Configuration
    • Equality
      • ShouldBe
      • NotBe
      • Null
      • Bool
      • Flags
      • AssignableTo
      • OfType
      • OneOf
      • Greater/Less Than
      • InRange
      • MatchApproved
      • Enumerable
      • SameAs
      • String
      • ExampleClasses
    • String
      • ShouldBe
      • Match
      • Contain
      • Null and Empty
      • StartWith
      • EndWith
    • Enumerable
      • ShouldBe
      • All
      • Empty
      • OneOf
      • Contain
      • Unique
      • SubsetOf
      • Have
    • Dictionary
      • ContainKey
      • ContainKeyAndValue
    • Exceptions
      • Throw
      • NotThrow
    • SatisfyAllConditions
    • CompleteIn
    • DynamicShould
    • Upgrade 3 to 4
Powered by GitBook
On this page
  • ShouldBeOfType
  • ShouldNotBeOfType
Edit on GitHub
  1. Documentation
  2. Equality

OfType

PreviousAssignableToNextOneOf

Last updated 2 years ago

ShouldBeOfType is the inverse of ShouldNotBeOfType.

ShouldBeOfType

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

|

Exception

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

ShouldNotBeOfType

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

|

Exception

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