Skip to content

Instantly share code, notes, and snippets.

Created February 24, 2015 16:20
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
XUnit test for interface implementation
public class ValueObjectTest
public void AllValueObjectsImplementIEquatable()
var typeToFind = typeof (IValueObject);
var typesFound = AppDomain.CurrentDomain.GetAssemblies().ToList()
.SelectMany(s => s.GetTypes())
foreach ( var type in typesFound)
if (type.IsInterface) continue;
bool typeIsIEquatable = type.GetInterfaces().Any(
i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof (IEquatable <>));
Assert.True(typeIsIEquatable, string.Format( "{0} does not implement IEquatable<>",type));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment