Method IsType
- Namespace
- Xunit
- Assembly
- xunit.v3.assert.dll
IsType<T>(object?)
Verifies that an object is exactly the given type (and not a derived type).
public static T IsType<T>(object? @object)
Parameters
objectobjectThe object to be evaluated
Returns
- T
The object, casted to type T when successful
Type Parameters
TThe type the object should be
Exceptions
Thrown when the object is not the given type
IsType<T>(object?, bool)
Verifies that an object of is the given type.
public static T IsType<T>(object? @object, bool exactMatch)
Parameters
objectobjectThe object to be evaluated
exactMatchboolWill only pass with an exact type match when
trueis passed; will pass with a compatible type match whenfalseis passed.
Returns
- T
The object, casted to type T when successful
Type Parameters
TThe type the object should be
Exceptions
Thrown when the object is not the given type
IsType(Type, object?)
Verifies that an object is exactly the given type (and not a derived type).
public static void IsType(Type expectedType, object? @object)
Parameters
Exceptions
Thrown when the object is not the given type
IsType(Type, object?, bool)
Verifies that an object is of the given type.
public static void IsType(Type expectedType, object? @object, bool exactMatch)
Parameters
expectedTypeTypeThe type the object should be
objectobjectThe object to be evaluated
exactMatchboolWill only pass with an exact type match when
trueis passed; will pass with a compatible type match whenfalseis passed.
Exceptions
Thrown when the object is not the given type