Type Assertions

These assertion extension methods can be applied to only Type object types.

ShouldBeAssignableFrom

Asserts that this type value is assignable from another type.

Usage

public static Type ShouldBeAssignableFrom(this Type source, Type comparer)
public static Type ShouldBeAssignableFrom(this Type source, Type comparer, string message)
public static Type ShouldBeAssignableFrom(this Type source, Type comparer, string message, params object[] parameters)
public static Type ShouldBeAssignableFrom<TComparer>(this Type source)
public static Type ShouldBeAssignableFrom<TComparer>((this Type source, string message)
public static Type ShouldBeAssignableFrom<TComparer>((this Type source, string message, params object[] parameters)

Example

[TestMethod]
public void Test()
{
   Type foo = typeof(ICollection);
   foo.ShouldBeAssignableFrom(IEnumerable);

   Type foo = typeof(IList);
   foo.ShouldBeAssignableFrom<IEnumerable>();
}
Supported Releases: 1.2 and later

Last edited Feb 7, 2012 at 3:43 PM by jeremiahclark, version 2

Comments

No comments yet.