Skip to content

Instantly share code, notes, and snippets.

Created January 17, 2013 23:05
  • Star 0 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?
Revision to an XUnit test for identifying bad mappings. Unlike the standard test (which would fail after the first bad/missing mapping), this will print out all the unmapped property names in the solution in context with the mapping they belong to.
public void AssertConfigurationIsValid()
catch (AutoMapperConfigurationException amce)
foreach (var e in amce.Errors)
Console.WriteLine("Source Type Name: {0}", e.TypeMap.SourceType.Name);
Console.WriteLine("Destination Type Name: {0}", e.TypeMap.DestinationType.Name);
Console.WriteLine("Unmapped Properties:");
foreach (var name in e.UnmappedPropertyNames)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment